vendor: 6,428 bytes, lines 1-184
1/** 2 * @license 3 * Lodash <https://lodash.com/> 4 * Copyright JS Foundation and other contributors <https://js.foundation/> 5 * Released under MIT license <https://lodash.com/license> 6 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 7 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 8 */ 9;(function() { 10 11 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 12 var undefined; 13 14 /** Used as the semantic version number. */ 15 var VERSION = '4.17.4'; 16 17 /** Used as the size to enable large array optimizations. */ 18 var LARGE_ARRAY_SIZE = 200; 19 20 /** Error message constants. */ 21 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 22 FUNC_ERROR_TEXT = 'Expected a function'; 23 24 /** Used to stand-in for `undefined` hash values. */ 25 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 26 27 /** Used as the maximum memoize cache size. */ 28 var MAX_MEMOIZE_SIZE = 500; 29 30 /** Used as the internal argument placeholder. */ 31 var PLACEHOLDER = '__lodash_placeholder__'; 32 33 /** Used to compose bitmasks for cloning. */ 34 var CLONE_DEEP_FLAG = 1, 35 CLONE_FLAT_FLAG = 2, 36 CLONE_SYMBOLS_FLAG = 4; 37 38 /** Used to compose bitmasks for value comparisons. */ 39 var COMPARE_PARTIAL_FLAG = 1, 40 COMPARE_UNORDERED_FLAG = 2; 41 42 /** Used to compose bitmasks for function metadata. */ 43 var WRAP_BIND_FLAG = 1, 44 WRAP_BIND_KEY_FLAG = 2, 45 WRAP_CURRY_BOUND_FLAG = 4, 46 WRAP_CURRY_FLAG = 8, 47 WRAP_CURRY_RIGHT_FLAG = 16, 48 WRAP_PARTIAL_FLAG = 32, 49 WRAP_PARTIAL_RIGHT_FLAG = 64, 50 WRAP_ARY_FLAG = 128, 51 WRAP_REARG_FLAG = 256, 52 WRAP_FLIP_FLAG = 512; 53 54 /** Used as default options for `_.truncate`. */ 55 var DEFAULT_TRUNC_LENGTH = 30, 56 DEFAULT_TRUNC_OMISSION = '...'; 57 58 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 59 var HOT_COUNT = 800, 60 HOT_SPAN = 16; 61 62 /** Used to indicate the type of lazy iteratees. */ 63 var LAZY_FILTER_FLAG = 1, 64 LAZY_MAP_FLAG = 2, 65 LAZY_WHILE_FLAG = 3; 66 67 /** Used as references for various `Number` constants. */ 68 var INFINITY = 1 / 0, 69 MAX_SAFE_INTEGER = 9007199254740991, 70 MAX_INTEGER = 1.7976931348623157e+308, 71 NAN = 0 / 0; 72 73 /** Used as references for the maximum length and index of an array. */ 74 var MAX_ARRAY_LENGTH = 4294967295, 75 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 76 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 77 78 /** Used to associate wrap methods with their bit flags. */ 79 var wrapFlags = [ 80 ['ary', WRAP_ARY_FLAG], 81 ['bind', WRAP_BIND_FLAG], 82 ['bindKey', WRAP_BIND_KEY_FLAG], 83 ['curry', WRAP_CURRY_FLAG], 84 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 85 ['flip', WRAP_FLIP_FLAG], 86 ['partial', WRAP_PARTIAL_FLAG], 87 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 88 ['rearg', WRAP_REARG_FLAG] 89 ]; 90 91 /** `Object#toString` result references. */ 92 var argsTag = '[object Arguments]', 93 arrayTag = '[object Array]', 94 asyncTag = '[object AsyncFunction]', 95 boolTag = '[object Boolean]', 96 dateTag = '[object Date]', 97 domExcTag = '[object DOMException]', 98 errorTag = '[object Error]', 99 funcTag = '[object Function]', 100 genTag = '[object GeneratorFunction]', 101 mapTag = '[object Map]', 102 numberTag = '[object Number]', 103 nullTag = '[object Null]', 104 objectTag = '[object Object]', 105 promiseTag = '[object Promise]', 106 proxyTag = '[object Proxy]', 107 regexpTag = '[object RegExp]', 108 setTag = '[object Set]', 109 stringTag = '[object String]', 110 symbolTag = '[object Symbol]', 111 undefinedTag = '[object Undefined]', 112 weakMapTag = '[object WeakMap]', 113 weakSetTag = '[object WeakSet]'; 114 115 var arrayBufferTag = '[object ArrayBuffer]', 116 dataViewTag = '[object DataView]', 117 float32Tag = '[object Float32Array]', 118 float64Tag = '[object Float64Array]', 119 int8Tag = '[object Int8Array]', 120 int16Tag = '[object Int16Array]', 121 int32Tag = '[object Int32Array]', 122 uint8Tag = '[object Uint8Array]', 123 uint8ClampedTag = '[object Uint8ClampedArray]', 124 uint16Tag = '[object Uint16Array]', 125 uint32Tag = '[object Uint32Array]'; 126 127 /** Used to match empty string literals in compiled template source. */ 128 var reEmptyStringLeading = /\b__p \+= '';/g, 129 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 130 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 131 132 /** Used to match HTML entities and HTML characters. */ 133 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 134 reUnescapedHtml = /[&<>"']/g, 135 reHasEscapedHtml = RegExp(reEscapedHtml.source), 136 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 137 138 /** Used to match template delimiters. */ 139 var reEscape = /<%-([\s\S]+?)%>/g, 140 reEvaluate = /<%([\s\S]+?)%>/g, 141 reInterpolate = /<%=([\s\S]+?)%>/g; 142 143 /** Used to match property names within property paths. */ 144 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 145 reIsPlainProp = /^\w*$/, 146 reLeadingDot = /^\./, 147 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 148 149 /** 150 * Used to match `RegExp` 151 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 152 */ 153 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 154 reHasRegExpChar = RegExp(reRegExpChar.source); 155 156 /** Used to match leading and trailing whitespace. */ 157 var reTrim = /^\s+|\s+$/g, 158 reTrimStart = /^\s+/, 159 reTrimEnd = /\s+$/; 160 161 /** Used to match wrap detail comments. */ 162 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 163 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 164 reSplitDetails = /,? & /; 165 166 /** Used to match words composed of alphanumeric characters. */ 167 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 168 169 /** Used to match backslashes in property paths. */ 170 var reEscapeChar = /\\(\\)?/g; 171 172 /** 173 * Used to match 174 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 175 */ 176 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 177 178 /** Used to match `RegExp` flags from their coerced string values. */ 179 var reFlags = /\w*$/; 180 181 /** Used to detect bad signed hexadecimal string values. */ 182 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 183 184 /** Used to detect binary string values. */
vendor: 4,600 bytes, lines 185-280
185 var reIsBinary = /^0b[01]+$/i; 186 187 /** Used to detect host constructors (Safari). */ 188 var reIsHostCtor = /^\[object .+?Constructor\]$/; 189 190 /** Used to detect octal string values. */ 191 var reIsOctal = /^0o[0-7]+$/i; 192 193 /** Used to detect unsigned integer values. */ 194 var reIsUint = /^(?:0|[1-9]\d*)$/; 195 196 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 197 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 198 199 /** Used to ensure capturing order of template delimiters. */ 200 var reNoMatch = /($^)/; 201 202 /** Used to match unescaped characters in compiled string literals. */ 203 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 204 205 /** Used to compose unicode character classes. */ 206 var rsAstralRange = '\\ud800-\\udfff', 207 rsComboMarksRange = '\\u0300-\\u036f', 208 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 209 rsComboSymbolsRange = '\\u20d0-\\u20ff', 210 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 211 rsDingbatRange = '\\u2700-\\u27bf', 212 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 213 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 214 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 215 rsPunctuationRange = '\\u2000-\\u206f', 216 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', 217 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 218 rsVarRange = '\\ufe0e\\ufe0f', 219 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 220 221 /** Used to compose unicode capture groups. */ 222 var rsApos = "['\u2019]", 223 rsAstral = '[' + rsAstralRange + ']', 224 rsBreak = '[' + rsBreakRange + ']', 225 rsCombo = '[' + rsComboRange + ']', 226 rsDigits = '\\d+', 227 rsDingbat = '[' + rsDingbatRange + ']', 228 rsLower = '[' + rsLowerRange + ']', 229 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 230 rsFitz = '\\ud83c[\\udffb-\\udfff]', 231 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 232 rsNonAstral = '[^' + rsAstralRange + ']', 233 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 234 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 235 rsUpper = '[' + rsUpperRange + ']', 236 rsZWJ = '\\u200d'; 237 238 /** Used to compose unicode regexes. */ 239 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 240 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 241 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 242 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 243 reOptMod = rsModifier + '?', 244 rsOptVar = '[' + rsVarRange + ']?', 245 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 246 rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)', 247 rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)', 248 rsSeq = rsOptVar + reOptMod + rsOptJoin, 249 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 250 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 251 252 /** Used to match apostrophes. */ 253 var reApos = RegExp(rsApos, 'g'); 254 255 /** 256 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 257 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 258 */ 259 var reComboMark = RegExp(rsCombo, 'g'); 260 261 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 262 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 263 264 /** Used to match complex or compound words. */ 265 var reUnicodeWord = RegExp([ 266 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 267 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 268 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 269 rsUpper + '+' + rsOptContrUpper, 270 rsOrdUpper, 271 rsOrdLower, 272 rsDigits, 273 rsEmoji 274 ].join('|'), 'g'); 275 276 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ 277 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 278 279 /** Used to detect strings that need a more robust regexp to match words. */ 280 var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,
vendor: 7,054 bytes, lines 280-440
280}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; 281 282 /** Used to assign default `context` object properties. */ 283 var contextProps = [ 284 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 285 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 286 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 287 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 288 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 289 ]; 290 291 /** Used to make template sourceURLs easier to identify. */ 292 var templateCounter = -1; 293 294 /** Used to identify `toStringTag` values of typed arrays. */ 295 var typedArrayTags = {}; 296 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 297 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 298 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 299 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 300 typedArrayTags[uint32Tag] = true; 301 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 302 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 303 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 304 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 305 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 306 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 307 typedArrayTags[setTag] = typedArrayTags[stringTag] = 308 typedArrayTags[weakMapTag] = false; 309 310 /** Used to identify `toStringTag` values supported by `_.clone`. */ 311 var cloneableTags = {}; 312 cloneableTags[argsTag] = cloneableTags[arrayTag] = 313 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 314 cloneableTags[boolTag] = cloneableTags[dateTag] = 315 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 316 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 317 cloneableTags[int32Tag] = cloneableTags[mapTag] = 318 cloneableTags[numberTag] = cloneableTags[objectTag] = 319 cloneableTags[regexpTag] = cloneableTags[setTag] = 320 cloneableTags[stringTag] = cloneableTags[symbolTag] = 321 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 322 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 323 cloneableTags[errorTag] = cloneableTags[funcTag] = 324 cloneableTags[weakMapTag] = false; 325 326 /** Used to map Latin Unicode letters to basic Latin letters. */ 327 var deburredLetters = { 328 // Latin-1 Supplement block. 329 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 330 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 331 '\xc7': 'C', '\xe7': 'c', 332 '\xd0': 'D', '\xf0': 'd', 333 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 334 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 335 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 336 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 337 '\xd1': 'N', '\xf1': 'n', 338 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 339 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 340 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 341 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 342 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 343 '\xc6': 'Ae', '\xe6': 'ae', 344 '\xde': 'Th', '\xfe': 'th', 345 '\xdf': 'ss', 346 // Latin Extended-A block. 347 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 348 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 349 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 350 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 351 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 352 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 353 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 354 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 355 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 356 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 357 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 358 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 359 '\u0134': 'J', '\u0135': 'j', 360 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 361 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 362 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 363 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 364 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 365 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 366 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 367 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 368 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 369 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 370 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 371 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 372 '\u0163': 't', '\u0165': 't', '\u0167': 't', 373 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 374 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 375 '\u0174': 'W', '\u0175': 'w', 376 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 377 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 378 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 379 '\u0132': 'IJ', '\u0133': 'ij', 380 '\u0152': 'Oe', '\u0153': 'oe', 381 '\u0149': "'n", '\u017f': 's' 382 }; 383 384 /** Used to map characters to HTML entities. */ 385 var htmlEscapes = { 386 '&': '&', 387 '<': '<', 388 '>': '>', 389 '"': '"', 390 "'": ''' 391 }; 392 393 /** Used to map HTML entities to characters. */ 394 var htmlUnescapes = { 395 '&': '&', 396 '<': '<', 397 '>': '>', 398 '"': '"', 399 ''': "'" 400 }; 401 402 /** Used to escape characters for inclusion in compiled string literals. */ 403 var stringEscapes = { 404 '\\': '\\', 405 "'": "'", 406 '\n': 'n', 407 '\r': 'r', 408 '\u2028': 'u2028', 409 '\u2029': 'u2029' 410 }; 411 412 /** Built-in method references without a dependency on `root`. */ 413 var freeParseFloat = parseFloat, 414 freeParseInt = parseInt; 415 416 /** Detect free variable `global` from Node.js. */ 417 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; 418 419 /** Detect free variable `self`. */ 420 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 421 422 /** Used as a reference to the global object. */ 423 var root = freeGlobal || freeSelf || Function('return this')(); 424 425 /** Detect free variable `exports`. */ 426 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; 427 428 /** Detect free variable `module`. */ 429 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; 430 431 /** Detect the popular CommonJS extension `module.exports`. */ 432 var moduleExports = freeModule && freeModule.exports === freeExports; 433 434 /** Detect free variable `process` from Node.js. */ 435 var freeProcess = moduleExports && freeGlobal.process; 436 437 /** Used to access faster Node.js helpers. */ 438 var nodeUtil = (function() { 439 try { 440
440return freeProcess && freeProcess.binding && freeProcess.binding('util'); 441 } catch (e) {} 442 }()); 443 444 /* Node.js helper references. */ 445 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 446 nodeIsDate = nodeUtil && nodeUtil.isDate, 447 nodeIsMap = nodeUtil && nodeUtil.isMap, 448 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 449 nodeIsSet = nodeUtil && nodeUtil.isSet, 450 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 451 452 /*--------------------------------------------------------------------------*/ 453 454 /** 455 * Adds the key-value `pair` to `map`. 456 * 457 * @private 458 * @param {Object} map The map to modify. 459 * @param {Array} pair The key-value pair to add. 460 * @returns {Object} Returns `map`. 461 */ 462 function addMapEntry(map, pair) { 463 // Don't return `map.set` because it's not chainable in IE 11. 464 map.set(pair[0], pair[1]); 465 return map; 466 } 467 468 /** 469 * Adds `value` to `set`. 470 * 471 * @private 472 * @param {Object} set The set to modify. 473 * @param {*} value The value to add. 474 * @returns {Object} Returns `set`. 475 */ 476 function addSetEntry(set, value) { 477 // Don't return `set.add` because it's not chainable in IE 11. 478 set.add(value); 479 return set; 480 }
vendor: 15,023 bytes, lines 480-983
480 481 482 /** 483 * A faster alternative to `Function#apply`, this function invokes `func` 484 * with the `this` binding of `thisArg` and the arguments of `args`. 485 * 486 * @private 487 * @param {Function} func The function to invoke. 488 * @param {*} thisArg The `this` binding of `func`. 489 * @param {Array} args The arguments to invoke `func` with. 490 * @returns {*} Returns the result of `func`. 491 */ 492 function apply(func, thisArg, args) { 493 switch (args.length) { 494 case 0: return func.call(thisArg); 495 case 1: return func.call(thisArg, args[0]); 496 case 2: return func.call(thisArg, args[0], args[1]); 497 case 3: return func.call(thisArg, args[0], args[1], args[2]); 498 } 499 return func.apply(thisArg, args); 500 } 501 502 /** 503 * A specialized version of `baseAggregator` for arrays. 504 * 505 * @private 506 * @param {Array} [array] The array to iterate over. 507 * @param {Function} setter The function to set `accumulator` values. 508 * @param {Function} iteratee The iteratee to transform keys. 509 * @param {Object} accumulator The initial aggregated object. 510 * @returns {Function} Returns `accumulator`. 511 */ 512 function arrayAggregator(array, setter, iteratee, accumulator) { 513 var index = -1, 514 length = array == null ? 0 : array.length; 515 516 while (++index < length) { 517 var value = array[index]; 518 setter(accumulator, value, iteratee(value), array); 519 } 520 return accumulator; 521 } 522 523 /** 524 * A specialized version of `_.forEach` for arrays without support for 525 * iteratee shorthands. 526 * 527 * @private 528 * @param {Array} [array] The array to iterate over. 529 * @param {Function} iteratee The function invoked per iteration. 530 * @returns {Array} Returns `array`. 531 */ 532 function arrayEach(array, iteratee) { 533 var index = -1, 534 length = array == null ? 0 : array.length; 535 536 while (++index < length) { 537 if (iteratee(array[index], index, array) === false) { 538 break; 539 } 540 } 541 return array; 542 } 543 544 /** 545 * A specialized version of `_.forEachRight` for arrays without support for 546 * iteratee shorthands. 547 * 548 * @private 549 * @param {Array} [array] The array to iterate over. 550 * @param {Function} iteratee The function invoked per iteration. 551 * @returns {Array} Returns `array`. 552 */ 553 function arrayEachRight(array, iteratee) { 554 var length = array == null ? 0 : array.length; 555 556 while (length--) { 557 if (iteratee(array[length], length, array) === false) { 558 break; 559 } 560 } 561 return array; 562 } 563 564 /** 565 * A specialized version of `_.every` for arrays without support for 566 * iteratee shorthands. 567 * 568 * @private 569 * @param {Array} [array] The array to iterate over. 570 * @param {Function} predicate The function invoked per iteration. 571 * @returns {boolean} Returns `true` if all elements pass the predicate check, 572 * else `false`. 573 */ 574 function arrayEvery(array, predicate) { 575 var index = -1, 576 length = array == null ? 0 : array.length; 577 578 while (++index < length) { 579 if (!predicate(array[index], index, array)) { 580 return false; 581 } 582 } 583 return true; 584 } 585 586 /** 587 * A specialized version of `_.filter` for arrays without support for 588 * iteratee shorthands. 589 * 590 * @private 591 * @param {Array} [array] The array to iterate over. 592 * @param {Function} predicate The function invoked per iteration. 593 * @returns {Array} Returns the new filtered array. 594 */ 595 function arrayFilter(array, predicate) { 596 var index = -1, 597 length = array == null ? 0 : array.length, 598 resIndex = 0, 599 result = []; 600 601 while (++index < length) { 602 var value = array[index]; 603 if (predicate(value, index, array)) { 604 result[resIndex++] = value; 605 } 606 } 607 return result; 608 } 609 610 /** 611 * A specialized version of `_.includes` for arrays without support for 612 * specifying an index to search from. 613 * 614 * @private 615 * @param {Array} [array] The array to inspect. 616 * @param {*} target The value to search for. 617 * @returns {boolean} Returns `true` if `target` is found, else `false`. 618 */ 619 function arrayIncludes(array, value) { 620 var length = array == null ? 0 : array.length; 621 return !!length && baseIndexOf(array, value, 0) > -1; 622 } 623 624 /** 625 * This function is like `arrayIncludes` except that it accepts a comparator. 626 * 627 * @private 628 * @param {Array} [array] The array to inspect. 629 * @param {*} target The value to search for. 630 * @param {Function} comparator The comparator invoked per element. 631 * @returns {boolean} Returns `true` if `target` is found, else `false`. 632 */ 633 function arrayIncludesWith(array, value, comparator) { 634 var index = -1, 635 length = array == null ? 0 : array.length; 636 637 while (++index < length) { 638 if (comparator(value, array[index])) { 639 return true; 640 } 641 } 642 return false; 643 } 644 645 /** 646 * A specialized version of `_.map` for arrays without support for iteratee 647 * shorthands. 648 * 649 * @private 650 * @param {Array} [array] The array to iterate over. 651 * @param {Function} iteratee The function invoked per iteration. 652 * @returns {Array} Returns the new mapped array. 653 */ 654 function arrayMap(array, iteratee) { 655 var index = -1, 656 length = array == null ? 0 : array.length, 657 result = Array(length); 658 659 while (++index < length) { 660 result[index] = iteratee(array[index], index, array); 661 } 662 return result; 663 } 664 665 /** 666 * Appends the elements of `values` to `array`. 667 * 668 * @private 669 * @param {Array} array The array to modify. 670 * @param {Array} values The values to append. 671 * @returns {Array} Returns `array`. 672 */ 673 function arrayPush(array, values) { 674 var index = -1, 675 length = values.length, 676 offset = array.length; 677 678 while (++index < length) { 679 array[offset + index] = values[index]; 680 } 681 return array; 682 } 683 684 /** 685 * A specialized version of `_.reduce` for arrays without support for 686 * iteratee shorthands. 687 * 688 * @private 689 * @param {Array} [array] The array to iterate over. 690 * @param {Function} iteratee The function invoked per iteration. 691 * @param {*} [accumulator] The initial value. 692 * @param {boolean} [initAccum] Specify using the first element of `array` as 693 * the initial value. 694 * @returns {*} Returns the accumulated value. 695 */ 696 function arrayReduce(array, iteratee, accumulator, initAccum) { 697 var index = -1, 698 length = array == null ? 0 : array.length; 699 700 if (initAccum && length) { 701 accumulator = array[++index]; 702 } 703 while (++index < length) { 704 accumulator = iteratee(accumulator, array[index], index, array); 705 } 706 return accumulator; 707 } 708 709 /** 710 * A specialized version of `_.reduceRight` for arrays without support for 711 * iteratee shorthands. 712 * 713 * @private 714 * @param {Array} [array] The array to iterate over. 715 * @param {Function} iteratee The function invoked per iteration. 716 * @param {*} [accumulator] The initial value. 717 * @param {boolean} [initAccum] Specify using the last element of `array` as 718 * the initial value. 719 * @returns {*} Returns the accumulated value. 720 */ 721 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 722 var length = array == null ? 0 : array.length; 723 if (initAccum && length) { 724 accumulator = array[--length]; 725 } 726 while (length--) { 727 accumulator = iteratee(accumulator, array[length], length, array); 728 } 729 return accumulator; 730 } 731 732 /** 733 * A specialized version of `_.some` for arrays without support for iteratee 734 * shorthands. 735 * 736 * @private 737 * @param {Array} [array] The array to iterate over. 738 * @param {Function} predicate The function invoked per iteration. 739 * @returns {boolean} Returns `true` if any element passes the predicate check, 740 * else `false`. 741 */ 742 function arraySome(array, predicate) { 743 var index = -1, 744 length = array == null ? 0 : array.length; 745 746 while (++index < length) { 747 if (predicate(array[index], index, array)) { 748 return true; 749 } 750 } 751 return false; 752 } 753 754 /** 755 * Gets the size of an ASCII `string`. 756 * 757 * @private 758 * @param {string} string The string inspect. 759 * @returns {number} Returns the string size. 760 */ 761 var asciiSize = baseProperty('length'); 762 763 /** 764 * Converts an ASCII `string` to an array. 765 * 766 * @private 767 * @param {string} string The string to convert. 768 * @returns {Array} Returns the converted array. 769 */ 770 function asciiToArray(string) { 771 return string.split(''); 772 } 773 774 /** 775 * Splits an ASCII `string` into an array of its words. 776 * 777 * @private 778 * @param {string} The string to inspect. 779 * @returns {Array} Returns the words of `string`. 780 */ 781 function asciiWords(string) { 782 return string.match(reAsciiWord) || []; 783 } 784 785 /** 786 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 787 * without support for iteratee shorthands, which iterates over `collection` 788 * using `eachFunc`. 789 * 790 * @private 791 * @param {Array|Object} collection The collection to inspect. 792 * @param {Function} predicate The function invoked per iteration. 793 * @param {Function} eachFunc The function to iterate over `collection`. 794 * @returns {*} Returns the found element or its key, else `undefined`. 795 */ 796 function baseFindKey(collection, predicate, eachFunc) { 797 var result; 798 eachFunc(collection, function(value, key, collection) { 799 if (predicate(value, key, collection)) { 800 result = key; 801 return false; 802 } 803 }); 804 return result; 805 } 806 807 /** 808 * The base implementation of `_.findIndex` and `_.findLastIndex` without 809 * support for iteratee shorthands. 810 * 811 * @private 812 * @param {Array} array The array to inspect. 813 * @param {Function} predicate The function invoked per iteration. 814 * @param {number} fromIndex The index to search from. 815 * @param {boolean} [fromRight] Specify iterating from right to left. 816 * @returns {number} Returns the index of the matched value, else `-1`. 817 */ 818 function baseFindIndex(array, predicate, fromIndex, fromRight) { 819 var length = array.length, 820 index = fromIndex + (fromRight ? 1 : -1); 821 822 while ((fromRight ? index-- : ++index < length)) { 823 if (predicate(array[index], index, array)) { 824 return index; 825 } 826 } 827 return -1; 828 } 829 830 /** 831 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 832 * 833 * @private 834 * @param {Array} array The array to inspect. 835 * @param {*} value The value to search for. 836 * @param {number} fromIndex The index to search from. 837 * @returns {number} Returns the index of the matched value, else `-1`. 838 */ 839 function baseIndexOf(array, value, fromIndex) { 840 return value === value 841 ? strictIndexOf(array, value, fromIndex) 842 : baseFindIndex(array, baseIsNaN, fromIndex); 843 } 844 845 /** 846 * This function is like `baseIndexOf` except that it accepts a comparator. 847 * 848 * @private 849 * @param {Array} array The array to inspect. 850 * @param {*} value The value to search for. 851 * @param {number} fromIndex The index to search from. 852 * @param {Function} comparator The comparator invoked per element. 853 * @returns {number} Returns the index of the matched value, else `-1`. 854 */ 855 function baseIndexOfWith(array, value, fromIndex, comparator) { 856 var index = fromIndex - 1, 857 length = array.length; 858 859 while (++index < length) { 860 if (comparator(array[index], value)) { 861 return index; 862 } 863 } 864 return -1; 865 } 866 867 /** 868 * The base implementation of `_.isNaN` without support for number objects. 869 * 870 * @private 871 * @param {*} value The value to check. 872 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 873 */ 874 function baseIsNaN(value) { 875 return value !== value; 876 } 877 878 /** 879 * The base implementation of `_.mean` and `_.meanBy` without support for 880 * iteratee shorthands. 881 * 882 * @private 883 * @param {Array} array The array to iterate over. 884 * @param {Function} iteratee The function invoked per iteration. 885 * @returns {number} Returns the mean. 886 */ 887 function baseMean(array, iteratee) { 888 var length = array == null ? 0 : array.length; 889 return length ? (baseSum(array, iteratee) / length) : NAN; 890 } 891 892 /** 893 * The base implementation of `_.property` without support for deep paths. 894 * 895 * @private 896 * @param {string} key The key of the property to get. 897 * @returns {Function} Returns the new accessor function. 898 */ 899 function baseProperty(key) { 900 return function(object) { 901 return object == null ? undefined : object[key]; 902 }; 903 } 904 905 /** 906 * The base implementation of `_.propertyOf` without support for deep paths. 907 * 908 * @private 909 * @param {Object} object The object to query. 910 * @returns {Function} Returns the new accessor function. 911 */ 912 function basePropertyOf(object) { 913 return function(key) { 914 return object == null ? undefined : object[key]; 915 }; 916 } 917 918 /** 919 * The base implementation of `_.reduce` and `_.reduceRight`, without support 920 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 921 * 922 * @private 923 * @param {Array|Object} collection The collection to iterate over. 924 * @param {Function} iteratee The function invoked per iteration. 925 * @param {*} accumulator The initial value. 926 * @param {boolean} initAccum Specify using the first or last element of 927 * `collection` as the initial value. 928 * @param {Function} eachFunc The function to iterate over `collection`. 929 * @returns {*} Returns the accumulated value. 930 */ 931 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 932 eachFunc(collection, function(value, index, collection) { 933 accumulator = initAccum 934 ? (initAccum = false, value) 935 : iteratee(accumulator, value, index, collection); 936 }); 937 return accumulator; 938 } 939 940 /** 941 * The base implementation of `_.sortBy` which uses `comparer` to define the 942 * sort order of `array` and replaces criteria objects with their corresponding 943 * values. 944 * 945 * @private 946 * @param {Array} array The array to sort. 947 * @param {Function} comparer The function to define sort order. 948 * @returns {Array} Returns `array`. 949 */ 950 function baseSortBy(array, comparer) { 951 var length = array.length; 952 953 array.sort(comparer); 954 while (length--) { 955 array[length] = array[length].value; 956 } 957 return array; 958 } 959 960 /** 961 * The base implementation of `_.sum` and `_.sumBy` without support for 962 * iteratee shorthands. 963 * 964 * @private 965 * @param {Array} array The array to iterate over. 966 * @param {Function} iteratee The function invoked per iteration. 967 * @returns {number} Returns the sum. 968 */ 969 function baseSum(array, iteratee) { 970 var result, 971 index = -1, 972 length = array.length; 973 974 while (++index < length) { 975 var current = iteratee(array[index]); 976 if (current !== undefined) { 977 result = result === undefined ? current : (result + current); 978 } 979 } 980 return result; 981 } 982 983 /**
vendor: 5,596 bytes, lines 984-1176
984 * The base implementation of `_.times` without support for iteratee shorthands 985 * or max array length checks. 986 * 987 * @private 988 * @param {number} n The number of times to invoke `iteratee`. 989 * @param {Function} iteratee The function invoked per iteration. 990 * @returns {Array} Returns the array of results. 991 */ 992 function baseTimes(n, iteratee) { 993 var index = -1, 994 result = Array(n); 995 996 while (++index < n) { 997 result[index] = iteratee(index); 998 } 999 return result; 1000 } 1001 1002 /** 1003 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 1004 * of key-value pairs for `object` corresponding to the property names of `props`. 1005 * 1006 * @private 1007 * @param {Object} object The object to query. 1008 * @param {Array} props The property names to get values for. 1009 * @returns {Object} Returns the key-value pairs. 1010 */ 1011 function baseToPairs(object, props) { 1012 return arrayMap(props, function(key) { 1013 return [key, object[key]]; 1014 }); 1015 } 1016 1017 /** 1018 * The base implementation of `_.unary` without support for storing metadata. 1019 * 1020 * @private 1021 * @param {Function} func The function to cap arguments for. 1022 * @returns {Function} Returns the new capped function. 1023 */ 1024 function baseUnary(func) { 1025 return function(value) { 1026 return func(value); 1027 }; 1028 } 1029 1030 /** 1031 * The base implementation of `_.values` and `_.valuesIn` which creates an 1032 * array of `object` property values corresponding to the property names 1033 * of `props`. 1034 * 1035 * @private 1036 * @param {Object} object The object to query. 1037 * @param {Array} props The property names to get values for. 1038 * @returns {Object} Returns the array of property values. 1039 */ 1040 function baseValues(object, props) { 1041 return arrayMap(props, function(key) { 1042 return object[key]; 1043 }); 1044 } 1045 1046 /** 1047 * Checks if a `cache` value for `key` exists. 1048 * 1049 * @private 1050 * @param {Object} cache The cache to query. 1051 * @param {string} key The key of the entry to check. 1052 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 1053 */ 1054 function cacheHas(cache, key) { 1055 return cache.has(key); 1056 } 1057 1058 /** 1059 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 1060 * that is not found in the character symbols. 1061 * 1062 * @private 1063 * @param {Array} strSymbols The string symbols to inspect. 1064 * @param {Array} chrSymbols The character symbols to find. 1065 * @returns {number} Returns the index of the first unmatched string symbol. 1066 */ 1067 function charsStartIndex(strSymbols, chrSymbols) { 1068 var index = -1, 1069 length = strSymbols.length; 1070 1071 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 1072 return index; 1073 } 1074 1075 /** 1076 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 1077 * that is not found in the character symbols. 1078 * 1079 * @private 1080 * @param {Array} strSymbols The string symbols to inspect. 1081 * @param {Array} chrSymbols The character symbols to find. 1082 * @returns {number} Returns the index of the last unmatched string symbol. 1083 */ 1084 function charsEndIndex(strSymbols, chrSymbols) { 1085 var index = strSymbols.length; 1086 1087 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 1088 return index; 1089 } 1090 1091 /** 1092 * Gets the number of `placeholder` occurrences in `array`. 1093 * 1094 * @private 1095 * @param {Array} array The array to inspect. 1096 * @param {*} placeholder The placeholder to search for. 1097 * @returns {number} Returns the placeholder count. 1098 */ 1099 function countHolders(array, placeholder) { 1100 var length = array.length, 1101 result = 0; 1102 1103 while (length--) { 1104 if (array[length] === placeholder) { 1105 ++result; 1106 } 1107 } 1108 return result; 1109 } 1110 1111 /** 1112 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 1113 * letters to basic Latin letters. 1114 * 1115 * @private 1116 * @param {string} letter The matched letter to deburr. 1117 * @returns {string} Returns the deburred letter. 1118 */ 1119 var deburrLetter = basePropertyOf(deburredLetters); 1120 1121 /** 1122 * Used by `_.escape` to convert characters to HTML entities. 1123 * 1124 * @private 1125 * @param {string} chr The matched character to escape. 1126 * @returns {string} Returns the escaped character. 1127 */ 1128 var escapeHtmlChar = basePropertyOf(htmlEscapes); 1129 1130 /** 1131 * Used by `_.template` to escape characters for inclusion in compiled string literals. 1132 * 1133 * @private 1134 * @param {string} chr The matched character to escape. 1135 * @returns {string} Returns the escaped character. 1136 */ 1137 function escapeStringChar(chr) { 1138 return '\\' + stringEscapes[chr]; 1139 } 1140 1141 /** 1142 * Gets the value at `key` of `object`. 1143 * 1144 * @private 1145 * @param {Object} [object] The object to query. 1146 * @param {string} key The key of the property to get. 1147 * @returns {*} Returns the property value. 1148 */ 1149 function getValue(object, key) { 1150 return object == null ? undefined : object[key]; 1151 } 1152 1153 /** 1154 * Checks if `string` contains Unicode symbols. 1155 * 1156 * @private 1157 * @param {string} string The string to inspect. 1158 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 1159 */ 1160 function hasUnicode(string) { 1161 return reHasUnicode.test(string); 1162 } 1163 1164 /** 1165 * Checks if `string` contains a word composed of Unicode symbols. 1166 * 1167 * @private 1168 * @param {string} string The string to inspect. 1169 * @returns {boolean} Returns `true` if a word is found, else `false`. 1170 */ 1171 function hasUnicodeWord(string) { 1172 return reHasUnicodeWord.test(string); 1173 } 1174 1175 /** 1176 * Converts `iterator` to an array.
vendor: 4,118 bytes, lines 1177-1342
1177 * 1178 * @private 1179 * @param {Object} iterator The iterator to convert. 1180 * @returns {Array} Returns the converted array. 1181 */ 1182 function iteratorToArray(iterator) { 1183 var data, 1184 result = []; 1185 1186 while (!(data = iterator.next()).done) { 1187 result.push(data.value); 1188 } 1189 return result; 1190 } 1191 1192 /** 1193 * Converts `map` to its key-value pairs. 1194 * 1195 * @private 1196 * @param {Object} map The map to convert. 1197 * @returns {Array} Returns the key-value pairs. 1198 */ 1199 function mapToArray(map) { 1200 var index = -1, 1201 result = Array(map.size); 1202 1203 map.forEach(function(value, key) { 1204 result[++index] = [key, value]; 1205 }); 1206 return result; 1207 } 1208 1209 /** 1210 * Creates a unary function that invokes `func` with its argument transformed. 1211 * 1212 * @private 1213 * @param {Function} func The function to wrap. 1214 * @param {Function} transform The argument transform. 1215 * @returns {Function} Returns the new function. 1216 */ 1217 function overArg(func, transform) { 1218 return function(arg) { 1219 return func(transform(arg)); 1220 }; 1221 } 1222 1223 /** 1224 * Replaces all `placeholder` elements in `array` with an internal placeholder 1225 * and returns an array of their indexes. 1226 * 1227 * @private 1228 * @param {Array} array The array to modify. 1229 * @param {*} placeholder The placeholder to replace. 1230 * @returns {Array} Returns the new array of placeholder indexes. 1231 */ 1232 function replaceHolders(array, placeholder) { 1233 var index = -1, 1234 length = array.length, 1235 resIndex = 0, 1236 result = []; 1237 1238 while (++index < length) { 1239 var value = array[index]; 1240 if (value === placeholder || value === PLACEHOLDER) { 1241 array[index] = PLACEHOLDER; 1242 result[resIndex++] = index; 1243 } 1244 } 1245 return result; 1246 } 1247 1248 /** 1249 * Converts `set` to an array of its values. 1250 * 1251 * @private 1252 * @param {Object} set The set to convert. 1253 * @returns {Array} Returns the values. 1254 */ 1255 function setToArray(set) { 1256 var index = -1, 1257 result = Array(set.size); 1258 1259 set.forEach(function(value) { 1260 result[++index] = value; 1261 }); 1262 return result; 1263 } 1264 1265 /** 1266 * Converts `set` to its value-value pairs. 1267 * 1268 * @private 1269 * @param {Object} set The set to convert. 1270 * @returns {Array} Returns the value-value pairs. 1271 */ 1272 function setToPairs(set) { 1273 var index = -1, 1274 result = Array(set.size); 1275 1276 set.forEach(function(value) { 1277 result[++index] = [value, value]; 1278 }); 1279 return result; 1280 } 1281 1282 /** 1283 * A specialized version of `_.indexOf` which performs strict equality 1284 * comparisons of values, i.e. `===`. 1285 * 1286 * @private 1287 * @param {Array} array The array to inspect. 1288 * @param {*} value The value to search for. 1289 * @param {number} fromIndex The index to search from. 1290 * @returns {number} Returns the index of the matched value, else `-1`. 1291 */ 1292 function strictIndexOf(array, value, fromIndex) { 1293 var index = fromIndex - 1, 1294 length = array.length; 1295 1296 while (++index < length) { 1297 if (array[index] === value) { 1298 return index; 1299 } 1300 } 1301 return -1; 1302 } 1303 1304 /** 1305 * A specialized version of `_.lastIndexOf` which performs strict equality 1306 * comparisons of values, i.e. `===`. 1307 * 1308 * @private 1309 * @param {Array} array The array to inspect. 1310 * @param {*} value The value to search for. 1311 * @param {number} fromIndex The index to search from. 1312 * @returns {number} Returns the index of the matched value, else `-1`. 1313 */ 1314 function strictLastIndexOf(array, value, fromIndex) { 1315 var index = fromIndex + 1; 1316 while (index--) { 1317 if (array[index] === value) { 1318 return index; 1319 } 1320 } 1321 return index; 1322 } 1323 1324 /** 1325 * Gets the number of symbols in `string`. 1326 * 1327 * @private 1328 * @param {string} string The string to inspect. 1329 * @returns {number} Returns the string size. 1330 */ 1331 function stringSize(string) { 1332 return hasUnicode(string) 1333 ? unicodeSize(string) 1334 : asciiSize(string); 1335 } 1336 1337 /** 1338 * Converts `string` to an array. 1339 * 1340 * @private 1341 * @param {string} string The string to convert. 1342 * @returns {Array} Returns the converted array.
vendor: 10,876 bytes, lines 1343-1616
1343 */ 1344 function stringToArray(string) { 1345 return hasUnicode(string) 1346 ? unicodeToArray(string) 1347 : asciiToArray(string); 1348 } 1349 1350 /** 1351 * Used by `_.unescape` to convert HTML entities to characters. 1352 * 1353 * @private 1354 * @param {string} chr The matched character to unescape. 1355 * @returns {string} Returns the unescaped character. 1356 */ 1357 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 1358 1359 /** 1360 * Gets the size of a Unicode `string`. 1361 * 1362 * @private 1363 * @param {string} string The string inspect. 1364 * @returns {number} Returns the string size. 1365 */ 1366 function unicodeSize(string) { 1367 var result = reUnicode.lastIndex = 0; 1368 while (reUnicode.test(string)) { 1369 ++result; 1370 } 1371 return result; 1372 } 1373 1374 /** 1375 * Converts a Unicode `string` to an array. 1376 * 1377 * @private 1378 * @param {string} string The string to convert. 1379 * @returns {Array} Returns the converted array. 1380 */ 1381 function unicodeToArray(string) { 1382 return string.match(reUnicode) || []; 1383 } 1384 1385 /** 1386 * Splits a Unicode `string` into an array of its words. 1387 * 1388 * @private 1389 * @param {string} The string to inspect. 1390 * @returns {Array} Returns the words of `string`. 1391 */ 1392 function unicodeWords(string) { 1393 return string.match(reUnicodeWord) || []; 1394 } 1395 1396 /*--------------------------------------------------------------------------*/ 1397 1398 /** 1399 * Create a new pristine `lodash` function using the `context` object. 1400 * 1401 * @static 1402 * @memberOf _ 1403 * @since 1.1.0 1404 * @category Util 1405 * @param {Object} [context=root] The context object. 1406 * @returns {Function} Returns a new `lodash` function. 1407 * @example 1408 * 1409 * _.mixin({ 'foo': _.constant('foo') }); 1410 * 1411 * var lodash = _.runInContext(); 1412 * lodash.mixin({ 'bar': lodash.constant('bar') }); 1413 * 1414 * _.isFunction(_.foo); 1415 * // => true 1416 * _.isFunction(_.bar); 1417 * // => false 1418 * 1419 * lodash.isFunction(lodash.foo); 1420 * // => false 1421 * lodash.isFunction(lodash.bar); 1422 * // => true 1423 * 1424 * // Create a suped-up `defer` in Node.js. 1425 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 1426 */ 1427 var runInContext = (function runInContext(context) { 1428 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 1429 1430 /** Built-in constructor references. */ 1431 var Array = context.Array, 1432 Date = context.Date, 1433 Error = context.Error, 1434 Function = context.Function, 1435 Math = context.Math, 1436 Object = context.Object, 1437 RegExp = context.RegExp, 1438 String = context.String, 1439 TypeError = context.TypeError; 1440 1441 /** Used for built-in method references. */ 1442 var arrayProto = Array.prototype, 1443 funcProto = Function.prototype, 1444 objectProto = Object.prototype; 1445 1446 /** Used to detect overreaching core-js shims. */ 1447 var coreJsData = context['__core-js_shared__']; 1448 1449 /** Used to resolve the decompiled source of functions. */ 1450 var funcToString = funcProto.toString; 1451 1452 /** Used to check objects for own properties. */ 1453 var hasOwnProperty = objectProto.hasOwnProperty; 1454 1455 /** Used to generate unique IDs. */ 1456 var idCounter = 0; 1457 1458 /** Used to detect methods masquerading as native. */ 1459 var maskSrcKey = (function() { 1460 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 1461 return uid ? ('Symbol(src)_1.' + uid) : ''; 1462 }()); 1463 1464 /** 1465 * Used to resolve the 1466 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 1467 * of values. 1468 */ 1469 var nativeObjectToString = objectProto.toString; 1470 1471 /** Used to infer the `Object` constructor. */ 1472 var objectCtorString = funcToString.call(Object); 1473 1474 /** Used to restore the original `_` reference in `_.noConflict`. */ 1475 var oldDash = root._; 1476 1477 /** Used to detect if a method is native. */ 1478 var reIsNative = RegExp('^' + 1479 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 1480 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 1481 ); 1482 1483 /** Built-in value references. */ 1484 var Buffer = moduleExports ? context.Buffer : undefined, 1485 Symbol = context.Symbol, 1486 Uint8Array = context.Uint8Array, 1487 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 1488 getPrototype = overArg(Object.getPrototypeOf, Object), 1489 objectCreate = Object.create, 1490 propertyIsEnumerable = objectProto.propertyIsEnumerable, 1491 splice = arrayProto.splice, 1492 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 1493 symIterator = Symbol ? Symbol.iterator : undefined, 1494 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 1495 1496 var defineProperty = (function() { 1497 try { 1498 var func = getNative(Object, 'defineProperty'); 1499 func({}, '', {}); 1500 return func; 1501 } catch (e) {} 1502 }()); 1503 1504 /** Mocked built-ins. */ 1505 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 1506 ctxNow = Date && Date.now !== root.Date.now && Date.now, 1507 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 1508 1509 /* Built-in method references for those with the same name as other `lodash` methods. */ 1510 var nativeCeil = Math.ceil, 1511 nativeFloor = Math.floor, 1512 nativeGetSymbols = Object.getOwnPropertySymbols, 1513 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 1514 nativeIsFinite = context.isFinite, 1515 nativeJoin = arrayProto.join, 1516 nativeKeys = overArg(Object.keys, Object), 1517 nativeMax = Math.max, 1518 nativeMin = Math.min, 1519 nativeNow = Date.now, 1520 nativeParseInt = context.parseInt, 1521 nativeRandom = Math.random, 1522 nativeReverse = arrayProto.reverse; 1523 1524 /* Built-in method references that are verified to be native. */ 1525 var DataView = getNative(context, 'DataView'), 1526 Map = getNative(context, 'Map'), 1527 Promise = getNative(context, 'Promise'), 1528 Set = getNative(context, 'Set'), 1529 WeakMap = getNative(context, 'WeakMap'), 1530 nativeCreate = getNative(Object, 'create'); 1531 1532 /** Used to store function metadata. */ 1533 var metaMap = WeakMap && new WeakMap; 1534 1535 /** Used to lookup unminified function names. */ 1536 var realNames = {}; 1537 1538 /** Used to detect maps, sets, and weakmaps. */ 1539 var dataViewCtorString = toSource(DataView), 1540 mapCtorString = toSource(Map), 1541 promiseCtorString = toSource(Promise), 1542 setCtorString = toSource(Set), 1543 weakMapCtorString = toSource(WeakMap); 1544 1545 /** Used to convert symbols to primitives and strings. */ 1546 var symbolProto = Symbol ? Symbol.prototype : undefined, 1547 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 1548 symbolToString = symbolProto ? symbolProto.toString : undefined; 1549 1550 /*------------------------------------------------------------------------*/ 1551 1552 /** 1553 * Creates a `lodash` object which wraps `value` to enable implicit method 1554 * chain sequences. Methods that operate on and return arrays, collections, 1555 * and functions can be chained together. Methods that retrieve a single value 1556 * or may return a primitive value will automatically end the chain sequence 1557 * and return the unwrapped value. Otherwise, the value must be unwrapped 1558 * with `_#value`. 1559 * 1560 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 1561 * enabled using `_.chain`. 1562 * 1563 * The execution of chained methods is lazy, that is, it's deferred until 1564 * `_#value` is implicitly or explicitly called. 1565 * 1566 * Lazy evaluation allows several methods to support shortcut fusion. 1567 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 1568 * the creation of intermediate arrays and can greatly reduce the number of 1569 * iteratee executions. Sections of a chain sequence qualify for shortcut 1570 * fusion if the section is applied to an array and iteratees accept only 1571 * one argument. The heuristic for whether a section qualifies for shortcut 1572 * fusion is subject to change. 1573 * 1574 * Chaining is supported in custom builds as long as the `_#value` method is 1575 * directly or indirectly included in the build. 1576 * 1577 * In addition to lodash methods, wrappers have `Array` and `String` methods. 1578 * 1579 * The wrapper `Array` methods are: 1580 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 1581 * 1582 * The wrapper `String` methods are: 1583 * `replace` and `split` 1584 * 1585 * The wrapper methods that support shortcut fusion are: 1586 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 1587 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 1588 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 1589 * 1590 * The chainable wrapper methods are: 1591 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 1592 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 1593 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 1594 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 1595 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 1596 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 1597 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 1598 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 1599 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 1600 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 1601 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 1602 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 1603 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 1604 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 1605 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 1606 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 1607 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 1608 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 1609 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 1610 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 1611 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 1612 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 1613 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 1614 * `zipObject`, `zipObjectDeep`, and `zipWith` 1615 * 1616 * The wrapper methods that are **not** chainable by default are:
vendor: 18,450 bytes, lines 1617-2269
1617 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 1618 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 1619 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 1620 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 1621 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 1622 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 1623 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 1624 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 1625 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 1626 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 1627 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 1628 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 1629 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 1630 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 1631 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 1632 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 1633 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 1634 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 1635 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 1636 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 1637 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 1638 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 1639 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 1640 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 1641 * `upperFirst`, `value`, and `words` 1642 * 1643 * @name _ 1644 * @constructor 1645 * @category Seq 1646 * @param {*} value The value to wrap in a `lodash` instance. 1647 * @returns {Object} Returns the new `lodash` wrapper instance. 1648 * @example 1649 * 1650 * function square(n) { 1651 * return n * n; 1652 * } 1653 * 1654 * var wrapped = _([1, 2, 3]); 1655 * 1656 * // Returns an unwrapped value. 1657 * wrapped.reduce(_.add); 1658 * // => 6 1659 * 1660 * // Returns a wrapped value. 1661 * var squares = wrapped.map(square); 1662 * 1663 * _.isArray(squares); 1664 * // => false 1665 * 1666 * _.isArray(squares.value()); 1667 * // => true 1668 */ 1669 function lodash(value) { 1670 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 1671 if (value instanceof LodashWrapper) { 1672 return value; 1673 } 1674 if (hasOwnProperty.call(value, '__wrapped__')) { 1675 return wrapperClone(value); 1676 } 1677 } 1678 return new LodashWrapper(value); 1679 } 1680 1681 /** 1682 * The base implementation of `_.create` without support for assigning 1683 * properties to the created object. 1684 * 1685 * @private 1686 * @param {Object} proto The object to inherit from. 1687 * @returns {Object} Returns the new object. 1688 */ 1689 var baseCreate = (function() { 1690 function object() {} 1691 return function(proto) { 1692 if (!isObject(proto)) { 1693 return {}; 1694 } 1695 if (objectCreate) { 1696 return objectCreate(proto); 1697 } 1698 object.prototype = proto; 1699 var result = new object; 1700 object.prototype = undefined; 1701 return result; 1702 }; 1703 }()); 1704 1705 /** 1706 * The function whose prototype chain sequence wrappers inherit from. 1707 * 1708 * @private 1709 */ 1710 function baseLodash() { 1711 // No operation performed. 1712 } 1713 1714 /** 1715 * The base constructor for creating `lodash` wrapper objects. 1716 * 1717 * @private 1718 * @param {*} value The value to wrap. 1719 * @param {boolean} [chainAll] Enable explicit method chain sequences. 1720 */ 1721 function LodashWrapper(value, chainAll) { 1722 this.__wrapped__ = value; 1723 this.__actions__ = []; 1724 this.__chain__ = !!chainAll; 1725 this.__index__ = 0; 1726 this.__values__ = undefined; 1727 } 1728 1729 /** 1730 * By default, the template delimiters used by lodash are like those in 1731 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 1732 * following template settings to use alternative delimiters. 1733 * 1734 * @static 1735 * @memberOf _ 1736 * @type {Object} 1737 */ 1738 lodash.templateSettings = { 1739 1740 /** 1741 * Used to detect `data` property values to be HTML-escaped. 1742 * 1743 * @memberOf _.templateSettings 1744 * @type {RegExp} 1745 */ 1746 'escape': reEscape, 1747 1748 /** 1749 * Used to detect code to be evaluated. 1750 * 1751 * @memberOf _.templateSettings 1752 * @type {RegExp} 1753 */ 1754 'evaluate': reEvaluate, 1755 1756 /** 1757 * Used to detect `data` property values to inject. 1758 * 1759 * @memberOf _.templateSettings 1760 * @type {RegExp} 1761 */ 1762 'interpolate': reInterpolate, 1763 1764 /** 1765 * Used to reference the data object in the template text. 1766 * 1767 * @memberOf _.templateSettings 1768 * @type {string} 1769 */ 1770 'variable': '', 1771 1772 /** 1773 * Used to import variables into the compiled template. 1774 * 1775 * @memberOf _.templateSettings 1776 * @type {Object} 1777 */ 1778 'imports': { 1779 1780 /** 1781 * A reference to the `lodash` function. 1782 * 1783 * @memberOf _.templateSettings.imports 1784 * @type {Function} 1785 */ 1786 '_': lodash 1787 } 1788 }; 1789 1790 // Ensure wrappers are instances of `baseLodash`. 1791 lodash.prototype = baseLodash.prototype; 1792 lodash.prototype.constructor = lodash; 1793 1794 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 1795 LodashWrapper.prototype.constructor = LodashWrapper; 1796 1797 /*------------------------------------------------------------------------*/ 1798 1799 /** 1800 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 1801 * 1802 * @private 1803 * @constructor 1804 * @param {*} value The value to wrap. 1805 */ 1806 function LazyWrapper(value) { 1807 this.__wrapped__ = value; 1808 this.__actions__ = []; 1809 this.__dir__ = 1; 1810 this.__filtered__ = false; 1811 this.__iteratees__ = []; 1812 this.__takeCount__ = MAX_ARRAY_LENGTH; 1813 this.__views__ = []; 1814 } 1815 1816 /** 1817 * Creates a clone of the lazy wrapper object. 1818 * 1819 * @private 1820 * @name clone 1821 * @memberOf LazyWrapper 1822 * @returns {Object} Returns the cloned `LazyWrapper` object. 1823 */ 1824 function lazyClone() { 1825 var result = new LazyWrapper(this.__wrapped__); 1826 result.__actions__ = copyArray(this.__actions__); 1827 result.__dir__ = this.__dir__; 1828 result.__filtered__ = this.__filtered__; 1829 result.__iteratees__ = copyArray(this.__iteratees__); 1830 result.__takeCount__ = this.__takeCount__; 1831 result.__views__ = copyArray(this.__views__); 1832 return result; 1833 } 1834 1835 /** 1836 * Reverses the direction of lazy iteration. 1837 * 1838 * @private 1839 * @name reverse 1840 * @memberOf LazyWrapper 1841 * @returns {Object} Returns the new reversed `LazyWrapper` object. 1842 */ 1843 function lazyReverse() { 1844 if (this.__filtered__) { 1845 var result = new LazyWrapper(this); 1846 result.__dir__ = -1; 1847 result.__filtered__ = true; 1848 } else { 1849 result = this.clone(); 1850 result.__dir__ *= -1; 1851 } 1852 return result; 1853 } 1854 1855 /** 1856 * Extracts the unwrapped value from its lazy wrapper. 1857 * 1858 * @private 1859 * @name value 1860 * @memberOf LazyWrapper 1861 * @returns {*} Returns the unwrapped value. 1862 */ 1863 function lazyValue() { 1864 var array = this.__wrapped__.value(), 1865 dir = this.__dir__, 1866 isArr = isArray(array), 1867 isRight = dir < 0, 1868 arrLength = isArr ? array.length : 0, 1869 view = getView(0, arrLength, this.__views__), 1870 start = view.start, 1871 end = view.end, 1872 length = end - start, 1873 index = isRight ? end : (start - 1), 1874 iteratees = this.__iteratees__, 1875 iterLength = iteratees.length, 1876 resIndex = 0, 1877 takeCount = nativeMin(length, this.__takeCount__); 1878 1879 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 1880 return baseWrapperValue(array, this.__actions__); 1881 } 1882 var result = []; 1883 1884 outer: 1885 while (length-- && resIndex < takeCount) { 1886 index += dir; 1887 1888 var iterIndex = -1, 1889 value = array[index]; 1890 1891 while (++iterIndex < iterLength) { 1892 var data = iteratees[iterIndex], 1893 iteratee = data.iteratee, 1894 type = data.type, 1895 computed = iteratee(value); 1896 1897 if (type == LAZY_MAP_FLAG) { 1898 value = computed; 1899 } else if (!computed) { 1900 if (type == LAZY_FILTER_FLAG) { 1901 continue outer; 1902 } else { 1903 break outer; 1904 } 1905 } 1906 } 1907 result[resIndex++] = value; 1908 } 1909 return result; 1910 } 1911 1912 // Ensure `LazyWrapper` is an instance of `baseLodash`. 1913 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 1914 LazyWrapper.prototype.constructor = LazyWrapper; 1915 1916 /*------------------------------------------------------------------------*/ 1917 1918 /** 1919 * Creates a hash object. 1920 * 1921 * @private 1922 * @constructor 1923 * @param {Array} [entries] The key-value pairs to cache. 1924 */ 1925 function Hash(entries) { 1926 var index = -1, 1927 length = entries == null ? 0 : entries.length; 1928 1929 this.clear(); 1930 while (++index < length) { 1931 var entry = entries[index]; 1932 this.set(entry[0], entry[1]); 1933 } 1934 } 1935 1936 /** 1937 * Removes all key-value entries from the hash. 1938 * 1939 * @private 1940 * @name clear 1941 * @memberOf Hash 1942 */ 1943 function hashClear() { 1944 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 1945 this.size = 0; 1946 } 1947 1948 /** 1949 * Removes `key` and its value from the hash. 1950 * 1951 * @private 1952 * @name delete 1953 * @memberOf Hash 1954 * @param {Object} hash The hash to modify. 1955 * @param {string} key The key of the value to remove. 1956 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 1957 */ 1958 function hashDelete(key) { 1959 var result = this.has(key) && delete this.__data__[key]; 1960 this.size -= result ? 1 : 0; 1961 return result; 1962 } 1963 1964 /** 1965 * Gets the hash value for `key`. 1966 * 1967 * @private 1968 * @name get 1969 * @memberOf Hash 1970 * @param {string} key The key of the value to get. 1971 * @returns {*} Returns the entry value. 1972 */ 1973 function hashGet(key) { 1974 var data = this.__data__; 1975 if (nativeCreate) { 1976 var result = data[key]; 1977 return result === HASH_UNDEFINED ? undefined : result; 1978 } 1979 return hasOwnProperty.call(data, key) ? data[key] : undefined; 1980 } 1981 1982 /** 1983 * Checks if a hash value for `key` exists. 1984 * 1985 * @private 1986 * @name has 1987 * @memberOf Hash 1988 * @param {string} key The key of the entry to check. 1989 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 1990 */ 1991 function hashHas(key) { 1992 var data = this.__data__; 1993 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 1994 } 1995 1996 /** 1997 * Sets the hash `key` to `value`. 1998 * 1999 * @private 2000 * @name set 2001 * @memberOf Hash 2002 * @param {string} key The key of the value to set. 2003 * @param {*} value The value to set. 2004 * @returns {Object} Returns the hash instance. 2005 */ 2006 function hashSet(key, value) { 2007 var data = this.__data__; 2008 this.size += this.has(key) ? 0 : 1; 2009 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 2010 return this; 2011 } 2012 2013 // Add methods to `Hash`. 2014 Hash.prototype.clear = hashClear; 2015 Hash.prototype['delete'] = hashDelete; 2016 Hash.prototype.get = hashGet; 2017 Hash.prototype.has = hashHas; 2018 Hash.prototype.set = hashSet; 2019 2020 /*------------------------------------------------------------------------*/ 2021 2022 /** 2023 * Creates an list cache object. 2024 * 2025 * @private 2026 * @constructor 2027 * @param {Array} [entries] The key-value pairs to cache. 2028 */ 2029 function ListCache(entries) { 2030 var index = -1, 2031 length = entries == null ? 0 : entries.length; 2032 2033 this.clear(); 2034 while (++index < length) { 2035 var entry = entries[index]; 2036 this.set(entry[0], entry[1]); 2037 } 2038 } 2039 2040 /** 2041 * Removes all key-value entries from the list cache. 2042 * 2043 * @private 2044 * @name clear 2045 * @memberOf ListCache 2046 */ 2047 function listCacheClear() { 2048 this.__data__ = []; 2049 this.size = 0; 2050 } 2051 2052 /** 2053 * Removes `key` and its value from the list cache. 2054 * 2055 * @private 2056 * @name delete 2057 * @memberOf ListCache 2058 * @param {string} key The key of the value to remove. 2059 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 2060 */ 2061 function listCacheDelete(key) { 2062 var data = this.__data__, 2063 index = assocIndexOf(data, key); 2064 2065 if (index < 0) { 2066 return false; 2067 } 2068 var lastIndex = data.length - 1; 2069 if (index == lastIndex) { 2070 data.pop(); 2071 } else { 2072 splice.call(data, index, 1); 2073 } 2074 --this.size; 2075 return true; 2076 } 2077 2078 /** 2079 * Gets the list cache value for `key`. 2080 * 2081 * @private 2082 * @name get 2083 * @memberOf ListCache 2084 * @param {string} key The key of the value to get. 2085 * @returns {*} Returns the entry value. 2086 */ 2087 function listCacheGet(key) { 2088 var data = this.__data__, 2089 index = assocIndexOf(data, key); 2090 2091 return index < 0 ? undefined : data[index][1]; 2092 } 2093 2094 /** 2095 * Checks if a list cache value for `key` exists. 2096 * 2097 * @private 2098 * @name has 2099 * @memberOf ListCache 2100 * @param {string} key The key of the entry to check. 2101 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2102 */ 2103 function listCacheHas(key) { 2104 return assocIndexOf(this.__data__, key) > -1; 2105 } 2106 2107 /** 2108 * Sets the list cache `key` to `value`. 2109 * 2110 * @private 2111 * @name set 2112 * @memberOf ListCache 2113 * @param {string} key The key of the value to set. 2114 * @param {*} value The value to set. 2115 * @returns {Object} Returns the list cache instance. 2116 */ 2117 function listCacheSet(key, value) { 2118 var data = this.__data__, 2119 index = assocIndexOf(data, key); 2120 2121 if (index < 0) { 2122 ++this.size; 2123 data.push([key, value]); 2124 } else { 2125 data[index][1] = value; 2126 } 2127 return this; 2128 } 2129 2130 // Add methods to `ListCache`. 2131 ListCache.prototype.clear = listCacheClear; 2132 ListCache.prototype['delete'] = listCacheDelete; 2133 ListCache.prototype.get = listCacheGet; 2134 ListCache.prototype.has = listCacheHas; 2135 ListCache.prototype.set = listCacheSet; 2136 2137 /*------------------------------------------------------------------------*/ 2138 2139 /** 2140 * Creates a map cache object to store key-value pairs. 2141 * 2142 * @private 2143 * @constructor 2144 * @param {Array} [entries] The key-value pairs to cache. 2145 */ 2146 function MapCache(entries) { 2147 var index = -1, 2148 length = entries == null ? 0 : entries.length; 2149 2150 this.clear(); 2151 while (++index < length) { 2152 var entry = entries[index]; 2153 this.set(entry[0], entry[1]); 2154 } 2155 } 2156 2157 /** 2158 * Removes all key-value entries from the map. 2159 * 2160 * @private 2161 * @name clear 2162 * @memberOf MapCache 2163 */ 2164 function mapCacheClear() { 2165 this.size = 0; 2166 this.__data__ = { 2167 'hash': new Hash, 2168 'map': new (Map || ListCache), 2169 'string': new Hash 2170 }; 2171 } 2172 2173 /** 2174 * Removes `key` and its value from the map. 2175 * 2176 * @private 2177 * @name delete 2178 * @memberOf MapCache 2179 * @param {string} key The key of the value to remove. 2180 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 2181 */ 2182 function mapCacheDelete(key) { 2183 var result = getMapData(this, key)['delete'](key); 2184 this.size -= result ? 1 : 0; 2185 return result; 2186 } 2187 2188 /** 2189 * Gets the map value for `key`. 2190 * 2191 * @private 2192 * @name get 2193 * @memberOf MapCache 2194 * @param {string} key The key of the value to get. 2195 * @returns {*} Returns the entry value. 2196 */ 2197 function mapCacheGet(key) { 2198 return getMapData(this, key).get(key); 2199 } 2200 2201 /** 2202 * Checks if a map value for `key` exists. 2203 * 2204 * @private 2205 * @name has 2206 * @memberOf MapCache 2207 * @param {string} key The key of the entry to check. 2208 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2209 */ 2210 function mapCacheHas(key) { 2211 return getMapData(this, key).has(key); 2212 } 2213 2214 /** 2215 * Sets the map `key` to `value`. 2216 * 2217 * @private 2218 * @name set 2219 * @memberOf MapCache 2220 * @param {string} key The key of the value to set. 2221 * @param {*} value The value to set. 2222 * @returns {Object} Returns the map cache instance. 2223 */ 2224 function mapCacheSet(key, value) { 2225 var data = getMapData(this, key), 2226 size = data.size; 2227 2228 data.set(key, value); 2229 this.size += data.size == size ? 0 : 1; 2230 return this; 2231 } 2232 2233 // Add methods to `MapCache`. 2234 MapCache.prototype.clear = mapCacheClear; 2235 MapCache.prototype['delete'] = mapCacheDelete; 2236 MapCache.prototype.get = mapCacheGet; 2237 MapCache.prototype.has = mapCacheHas; 2238 MapCache.prototype.set = mapCacheSet; 2239 2240 /*------------------------------------------------------------------------*/ 2241 2242 /** 2243 * 2244 * Creates an array cache object to store unique values. 2245 * 2246 * @private 2247 * @constructor 2248 * @param {Array} [values] The values to cache. 2249 */ 2250 function SetCache(values) { 2251 var index = -1, 2252 length = values == null ? 0 : values.length; 2253 2254 this.__data__ = new MapCache; 2255 while (++index < length) { 2256 this.add(values[index]); 2257 } 2258 } 2259 2260 /** 2261 * Adds `value` to the array cache. 2262 * 2263 * @private 2264 * @name add 2265 * @memberOf SetCache 2266 * @alias push 2267 * @param {*} value The value to cache. 2268 * @returns {Object} Returns the cache instance. 2269 */
vendor: 3,741 bytes, lines 2270-2406
2270 function setCacheAdd(value) { 2271 this.__data__.set(value, HASH_UNDEFINED); 2272 return this; 2273 } 2274 2275 /** 2276 * Checks if `value` is in the array cache. 2277 * 2278 * @private 2279 * @name has 2280 * @memberOf SetCache 2281 * @param {*} value The value to search for. 2282 * @returns {number} Returns `true` if `value` is found, else `false`. 2283 */ 2284 function setCacheHas(value) { 2285 return this.__data__.has(value); 2286 } 2287 2288 // Add methods to `SetCache`. 2289 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 2290 SetCache.prototype.has = setCacheHas; 2291 2292 /*------------------------------------------------------------------------*/ 2293 2294 /** 2295 * Creates a stack cache object to store key-value pairs. 2296 * 2297 * @private 2298 * @constructor 2299 * @param {Array} [entries] The key-value pairs to cache. 2300 */ 2301 function Stack(entries) { 2302 var data = this.__data__ = new ListCache(entries); 2303 this.size = data.size; 2304 } 2305 2306 /** 2307 * Removes all key-value entries from the stack. 2308 * 2309 * @private 2310 * @name clear 2311 * @memberOf Stack 2312 */ 2313 function stackClear() { 2314 this.__data__ = new ListCache; 2315 this.size = 0; 2316 } 2317 2318 /** 2319 * Removes `key` and its value from the stack. 2320 * 2321 * @private 2322 * @name delete 2323 * @memberOf Stack 2324 * @param {string} key The key of the value to remove. 2325 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 2326 */ 2327 function stackDelete(key) { 2328 var data = this.__data__, 2329 result = data['delete'](key); 2330 2331 this.size = data.size; 2332 return result; 2333 } 2334 2335 /** 2336 * Gets the stack value for `key`. 2337 * 2338 * @private 2339 * @name get 2340 * @memberOf Stack 2341 * @param {string} key The key of the value to get. 2342 * @returns {*} Returns the entry value. 2343 */ 2344 function stackGet(key) { 2345 return this.__data__.get(key); 2346 } 2347 2348 /** 2349 * Checks if a stack value for `key` exists. 2350 * 2351 * @private 2352 * @name has 2353 * @memberOf Stack 2354 * @param {string} key The key of the entry to check. 2355 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2356 */ 2357 function stackHas(key) { 2358 return this.__data__.has(key); 2359 } 2360 2361 /** 2362 * Sets the stack `key` to `value`. 2363 * 2364 * @private 2365 * @name set 2366 * @memberOf Stack 2367 * @param {string} key The key of the value to set. 2368 * @param {*} value The value to set. 2369 * @returns {Object} Returns the stack cache instance. 2370 */ 2371 function stackSet(key, value) { 2372 var data = this.__data__; 2373 if (data instanceof ListCache) { 2374 var pairs = data.__data__; 2375 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 2376 pairs.push([key, value]); 2377 this.size = ++data.size; 2378 return this; 2379 } 2380 data = this.__data__ = new MapCache(pairs); 2381 } 2382 data.set(key, value); 2383 this.size = data.size; 2384 return this; 2385 } 2386 2387 // Add methods to `Stack`. 2388 Stack.prototype.clear = stackClear; 2389 Stack.prototype['delete'] = stackDelete; 2390 Stack.prototype.get = stackGet; 2391 Stack.prototype.has = stackHas; 2392 Stack.prototype.set = stackSet; 2393 2394 /*------------------------------------------------------------------------*/ 2395 2396 /** 2397 * Creates an array of the enumerable property names of the array-like `value`. 2398 * 2399 * @private 2400 * @param {*} value The value to query. 2401 * @param {boolean} inherited Specify returning inherited property names. 2402 * @returns {Array} Returns the array of property names. 2403 */ 2404 function arrayLikeKeys(value, inherited) { 2405 var isArr = isArray(value), 2406 isArg = !isArr && isArguments(value),
vendor: 9,093 bytes, lines 2407-2680
2407 isBuff = !isArr && !isArg && isBuffer(value), 2408 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 2409 skipIndexes = isArr || isArg || isBuff || isType, 2410 result = skipIndexes ? baseTimes(value.length, String) : [], 2411 length = result.length; 2412 2413 for (var key in value) { 2414 if ((inherited || hasOwnProperty.call(value, key)) && 2415 !(skipIndexes && ( 2416 // Safari 9 has enumerable `arguments.length` in strict mode. 2417 key == 'length' || 2418 // Node.js 0.10 has enumerable non-index properties on buffers. 2419 (isBuff && (key == 'offset' || key == 'parent')) || 2420 // PhantomJS 2 has enumerable non-index properties on typed arrays. 2421 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 2422 // Skip index properties. 2423 isIndex(key, length) 2424 ))) { 2425 result.push(key); 2426 } 2427 } 2428 return result; 2429 } 2430 2431 /** 2432 * A specialized version of `_.sample` for arrays. 2433 * 2434 * @private 2435 * @param {Array} array The array to sample. 2436 * @returns {*} Returns the random element. 2437 */ 2438 function arraySample(array) { 2439 var length = array.length; 2440 return length ? array[baseRandom(0, length - 1)] : undefined; 2441 } 2442 2443 /** 2444 * A specialized version of `_.sampleSize` for arrays. 2445 * 2446 * @private 2447 * @param {Array} array The array to sample. 2448 * @param {number} n The number of elements to sample. 2449 * @returns {Array} Returns the random elements. 2450 */ 2451 function arraySampleSize(array, n) { 2452 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 2453 } 2454 2455 /** 2456 * A specialized version of `_.shuffle` for arrays. 2457 * 2458 * @private 2459 * @param {Array} array The array to shuffle. 2460 * @returns {Array} Returns the new shuffled array. 2461 */ 2462 function arrayShuffle(array) { 2463 return shuffleSelf(copyArray(array)); 2464 } 2465 2466 /** 2467 * This function is like `assignValue` except that it doesn't assign 2468 * `undefined` values. 2469 * 2470 * @private 2471 * @param {Object} object The object to modify. 2472 * @param {string} key The key of the property to assign. 2473 * @param {*} value The value to assign. 2474 */ 2475 function assignMergeValue(object, key, value) { 2476 if ((value !== undefined && !eq(object[key], value)) || 2477 (value === undefined && !(key in object))) { 2478 baseAssignValue(object, key, value); 2479 } 2480 } 2481 2482 /** 2483 * Assigns `value` to `key` of `object` if the existing value is not equivalent 2484 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 2485 * for equality comparisons. 2486 * 2487 * @private 2488 * @param {Object} object The object to modify. 2489 * @param {string} key The key of the property to assign. 2490 * @param {*} value The value to assign. 2491 */ 2492 function assignValue(object, key, value) { 2493 var objValue = object[key]; 2494 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 2495 (value === undefined && !(key in object))) { 2496 baseAssignValue(object, key, value); 2497 } 2498 } 2499 2500 /** 2501 * Gets the index at which the `key` is found in `array` of key-value pairs. 2502 * 2503 * @private 2504 * @param {Array} array The array to inspect. 2505 * @param {*} key The key to search for. 2506 * @returns {number} Returns the index of the matched value, else `-1`. 2507 */ 2508 function assocIndexOf(array, key) { 2509 var length = array.length; 2510 while (length--) { 2511 if (eq(array[length][0], key)) { 2512 return length; 2513 } 2514 } 2515 return -1; 2516 } 2517 2518 /** 2519 * Aggregates elements of `collection` on `accumulator` with keys transformed 2520 * by `iteratee` and values set by `setter`. 2521 * 2522 * @private 2523 * @param {Array|Object} collection The collection to iterate over. 2524 * @param {Function} setter The function to set `accumulator` values. 2525 * @param {Function} iteratee The iteratee to transform keys. 2526 * @param {Object} accumulator The initial aggregated object. 2527 * @returns {Function} Returns `accumulator`. 2528 */ 2529 function baseAggregator(collection, setter, iteratee, accumulator) { 2530 baseEach(collection, function(value, key, collection) { 2531 setter(accumulator, value, iteratee(value), collection); 2532 }); 2533 return accumulator; 2534 } 2535 2536 /** 2537 * The base implementation of `_.assign` without support for multiple sources 2538 * or `customizer` functions. 2539 * 2540 * @private 2541 * @param {Object} object The destination object. 2542 * @param {Object} source The source object. 2543 * @returns {Object} Returns `object`. 2544 */ 2545 function baseAssign(object, source) { 2546 return object && copyObject(source, keys(source), object); 2547 } 2548 2549 /** 2550 * The base implementation of `_.assignIn` without support for multiple sources 2551 * or `customizer` functions. 2552 * 2553 * @private 2554 * @param {Object} object The destination object. 2555 * @param {Object} source The source object. 2556 * @returns {Object} Returns `object`. 2557 */ 2558 function baseAssignIn(object, source) { 2559 return object && copyObject(source, keysIn(source), object); 2560 } 2561 2562 /** 2563 * The base implementation of `assignValue` and `assignMergeValue` without 2564 * value checks. 2565 * 2566 * @private 2567 * @param {Object} object The object to modify. 2568 * @param {string} key The key of the property to assign. 2569 * @param {*} value The value to assign. 2570 */ 2571 function baseAssignValue(object, key, value) { 2572 if (key == '__proto__' && defineProperty) { 2573 defineProperty(object, key, { 2574 'configurable': true, 2575 'enumerable': true, 2576 'value': value, 2577 'writable': true 2578 }); 2579 } else { 2580 object[key] = value; 2581 } 2582 } 2583 2584 /** 2585 * The base implementation of `_.at` without support for individual paths. 2586 * 2587 * @private 2588 * @param {Object} object The object to iterate over. 2589 * @param {string[]} paths The property paths to pick. 2590 * @returns {Array} Returns the picked elements. 2591 */ 2592 function baseAt(object, paths) { 2593 var index = -1, 2594 length = paths.length, 2595 result = Array(length), 2596 skip = object == null; 2597 2598 while (++index < length) { 2599 result[index] = skip ? undefined : get(object, paths[index]); 2600 } 2601 return result; 2602 } 2603 2604 /** 2605 * The base implementation of `_.clamp` which doesn't coerce arguments. 2606 * 2607 * @private 2608 * @param {number} number The number to clamp. 2609 * @param {number} [lower] The lower bound. 2610 * @param {number} upper The upper bound. 2611 * @returns {number} Returns the clamped number. 2612 */ 2613 function baseClamp(number, lower, upper) { 2614 if (number === number) { 2615 if (upper !== undefined) { 2616 number = number <= upper ? number : upper; 2617 } 2618 if (lower !== undefined) { 2619 number = number >= lower ? number : lower; 2620 } 2621 } 2622 return number; 2623 } 2624 2625 /** 2626 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 2627 * traversed objects. 2628 * 2629 * @private 2630 * @param {*} value The value to clone. 2631 * @param {boolean} bitmask The bitmask flags. 2632 * 1 - Deep clone 2633 * 2 - Flatten inherited properties 2634 * 4 - Clone symbols 2635 * @param {Function} [customizer] The function to customize cloning. 2636 * @param {string} [key] The key of `value`. 2637 * @param {Object} [object] The parent object of `value`. 2638 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 2639 * @returns {*} Returns the cloned value. 2640 */ 2641 function baseClone(value, bitmask, customizer, key, object, stack) { 2642 var result, 2643 isDeep = bitmask & CLONE_DEEP_FLAG, 2644 isFlat = bitmask & CLONE_FLAT_FLAG, 2645 isFull = bitmask & CLONE_SYMBOLS_FLAG; 2646 2647 if (customizer) { 2648 result = object ? customizer(value, key, object, stack) : customizer(value); 2649 } 2650 if (result !== undefined) { 2651 return result; 2652 } 2653 if (!isObject(value)) { 2654 return value; 2655 } 2656 var isArr = isArray(value); 2657 if (isArr) { 2658 result = initCloneArray(value); 2659 if (!isDeep) { 2660 return copyArray(value, result); 2661 } 2662 } else { 2663 var tag = getTag(value), 2664 isFunc = tag == funcTag || tag == genTag; 2665 2666 if (isBuffer(value)) { 2667 return cloneBuffer(value, isDeep); 2668 } 2669 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 2670 result = (isFlat || isFunc) ? {} : initCloneObject(value); 2671 if (!isDeep) { 2672 return isFlat 2673 ? copySymbolsIn(value, baseAssignIn(result, value)) 2674 : copySymbols(value, baseAssign(result, value)); 2675 } 2676 } else { 2677 if (!cloneableTags[tag]) { 2678 return object ? value : {}; 2679 } 2680 result = initCloneByTag(value, tag,
2680baseClone, isDeep); 2681 } 2682 } 2683 // Check for circular references and return its corresponding clone. 2684 stack || (stack = new Stack); 2685 var stacked = stack.get(value); 2686 if (stacked) { 2687 return stacked; 2688 } 2689 stack.set(value, result);
vendor: 31,223 bytes, lines 2689-3612
2689 2690 2691 var keysFunc = isFull 2692 ? (isFlat ? getAllKeysIn : getAllKeys) 2693 : (isFlat ? keysIn : keys); 2694 2695 var props = isArr ? undefined : keysFunc(value); 2696 arrayEach(props || value, function(subValue, key) { 2697 if (props) { 2698 key = subValue; 2699 subValue = value[key]; 2700 } 2701 // Recursively populate clone (susceptible to call stack limits). 2702 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 2703 }); 2704 return result; 2705 } 2706 2707 /** 2708 * The base implementation of `_.conforms` which doesn't clone `source`. 2709 * 2710 * @private 2711 * @param {Object} source The object of property predicates to conform to. 2712 * @returns {Function} Returns the new spec function. 2713 */ 2714 function baseConforms(source) { 2715 var props = keys(source); 2716 return function(object) { 2717 return baseConformsTo(object, source, props); 2718 }; 2719 } 2720 2721 /** 2722 * The base implementation of `_.conformsTo` which accepts `props` to check. 2723 * 2724 * @private 2725 * @param {Object} object The object to inspect. 2726 * @param {Object} source The object of property predicates to conform to. 2727 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 2728 */ 2729 function baseConformsTo(object, source, props) { 2730 var length = props.length; 2731 if (object == null) { 2732 return !length; 2733 } 2734 object = Object(object); 2735 while (length--) { 2736 var key = props[length], 2737 predicate = source[key], 2738 value = object[key]; 2739 2740 if ((value === undefined && !(key in object)) || !predicate(value)) { 2741 return false; 2742 } 2743 } 2744 return true; 2745 } 2746 2747 /** 2748 * The base implementation of `_.delay` and `_.defer` which accepts `args` 2749 * to provide to `func`. 2750 * 2751 * @private 2752 * @param {Function} func The function to delay. 2753 * @param {number} wait The number of milliseconds to delay invocation. 2754 * @param {Array} args The arguments to provide to `func`. 2755 * @returns {number|Object} Returns the timer id or timeout object. 2756 */ 2757 function baseDelay(func, wait, args) { 2758 if (typeof func != 'function') { 2759 throw new TypeError(FUNC_ERROR_TEXT); 2760 } 2761 return setTimeout(function() { func.apply(undefined, args); }, wait); 2762 } 2763 2764 /** 2765 * The base implementation of methods like `_.difference` without support 2766 * for excluding multiple arrays or iteratee shorthands. 2767 * 2768 * @private 2769 * @param {Array} array The array to inspect. 2770 * @param {Array} values The values to exclude. 2771 * @param {Function} [iteratee] The iteratee invoked per element. 2772 * @param {Function} [comparator] The comparator invoked per element. 2773 * @returns {Array} Returns the new array of filtered values. 2774 */ 2775 function baseDifference(array, values, iteratee, comparator) { 2776 var index = -1, 2777 includes = arrayIncludes, 2778 isCommon = true, 2779 length = array.length, 2780 result = [], 2781 valuesLength = values.length; 2782 2783 if (!length) { 2784 return result; 2785 } 2786 if (iteratee) { 2787 values = arrayMap(values, baseUnary(iteratee)); 2788 } 2789 if (comparator) { 2790 includes = arrayIncludesWith; 2791 isCommon = false; 2792 } 2793 else if (values.length >= LARGE_ARRAY_SIZE) { 2794 includes = cacheHas; 2795 isCommon = false; 2796 values = new SetCache(values); 2797 } 2798 outer: 2799 while (++index < length) { 2800 var value = array[index], 2801 computed = iteratee == null ? value : iteratee(value); 2802 2803 value = (comparator || value !== 0) ? value : 0; 2804 if (isCommon && computed === computed) { 2805 var valuesIndex = valuesLength; 2806 while (valuesIndex--) { 2807 if (values[valuesIndex] === computed) { 2808 continue outer; 2809 } 2810 } 2811 result.push(value); 2812 } 2813 else if (!includes(values, computed, comparator)) { 2814 result.push(value); 2815 } 2816 } 2817 return result; 2818 } 2819 2820 /** 2821 * The base implementation of `_.forEach` without support for iteratee shorthands. 2822 * 2823 * @private 2824 * @param {Array|Object} collection The collection to iterate over. 2825 * @param {Function} iteratee The function invoked per iteration. 2826 * @returns {Array|Object} Returns `collection`. 2827 */ 2828 var baseEach = createBaseEach(baseForOwn); 2829 2830 /** 2831 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 2832 * 2833 * @private 2834 * @param {Array|Object} collection The collection to iterate over. 2835 * @param {Function} iteratee The function invoked per iteration. 2836 * @returns {Array|Object} Returns `collection`. 2837 */ 2838 var baseEachRight = createBaseEach(baseForOwnRight, true); 2839 2840 /** 2841 * The base implementation of `_.every` without support for iteratee shorthands. 2842 * 2843 * @private 2844 * @param {Array|Object} collection The collection to iterate over. 2845 * @param {Function} predicate The function invoked per iteration. 2846 * @returns {boolean} Returns `true` if all elements pass the predicate check, 2847 * else `false` 2848 */ 2849 function baseEvery(collection, predicate) { 2850 var result = true; 2851 baseEach(collection, function(value, index, collection) { 2852 result = !!predicate(value, index, collection); 2853 return result; 2854 }); 2855 return result; 2856 } 2857 2858 /** 2859 * The base implementation of methods like `_.max` and `_.min` which accepts a 2860 * `comparator` to determine the extremum value. 2861 * 2862 * @private 2863 * @param {Array} array The array to iterate over. 2864 * @param {Function} iteratee The iteratee invoked per iteration. 2865 * @param {Function} comparator The comparator used to compare values. 2866 * @returns {*} Returns the extremum value. 2867 */ 2868 function baseExtremum(array, iteratee, comparator) { 2869 var index = -1, 2870 length = array.length; 2871 2872 while (++index < length) { 2873 var value = array[index], 2874 current = iteratee(value); 2875 2876 if (current != null && (computed === undefined 2877 ? (current === current && !isSymbol(current)) 2878 : comparator(current, computed) 2879 )) { 2880 var computed = current, 2881 result = value; 2882 } 2883 } 2884 return result; 2885 } 2886 2887 /** 2888 * The base implementation of `_.fill` without an iteratee call guard. 2889 * 2890 * @private 2891 * @param {Array} array The array to fill. 2892 * @param {*} value The value to fill `array` with. 2893 * @param {number} [start=0] The start position. 2894 * @param {number} [end=array.length] The end position. 2895 * @returns {Array} Returns `array`. 2896 */ 2897 function baseFill(array, value, start, end) { 2898 var length = array.length; 2899 2900 start = toInteger(start); 2901 if (start < 0) { 2902 start = -start > length ? 0 : (length + start); 2903 } 2904 end = (end === undefined || end > length) ? length : toInteger(end); 2905 if (end < 0) { 2906 end += length; 2907 } 2908 end = start > end ? 0 : toLength(end); 2909 while (start < end) { 2910 array[start++] = value; 2911 } 2912 return array; 2913 } 2914 2915 /** 2916 * The base implementation of `_.filter` without support for iteratee shorthands. 2917 * 2918 * @private 2919 * @param {Array|Object} collection The collection to iterate over. 2920 * @param {Function} predicate The function invoked per iteration. 2921 * @returns {Array} Returns the new filtered array. 2922 */ 2923 function baseFilter(collection, predicate) { 2924 var result = []; 2925 baseEach(collection, function(value, index, collection) { 2926 if (predicate(value, index, collection)) { 2927 result.push(value); 2928 } 2929 }); 2930 return result; 2931 } 2932 2933 /** 2934 * The base implementation of `_.flatten` with support for restricting flattening. 2935 * 2936 * @private 2937 * @param {Array} array The array to flatten. 2938 * @param {number} depth The maximum recursion depth. 2939 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 2940 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 2941 * @param {Array} [result=[]] The initial result value. 2942 * @returns {Array} Returns the new flattened array. 2943 */ 2944 function baseFlatten(array, depth, predicate, isStrict, result) { 2945 var index = -1, 2946 length = array.length; 2947 2948 predicate || (predicate = isFlattenable); 2949 result || (result = []); 2950 2951 while (++index < length) { 2952 var value = array[index]; 2953 if (depth > 0 && predicate(value)) { 2954 if (depth > 1) { 2955 // Recursively flatten arrays (susceptible to call stack limits). 2956 baseFlatten(value, depth - 1, predicate, isStrict, result); 2957 } else { 2958 arrayPush(result, value); 2959 } 2960 } else if (!isStrict) { 2961 result[result.length] = value; 2962 } 2963 } 2964 return result; 2965 } 2966 2967 /** 2968 * The base implementation of `baseForOwn` which iterates over `object` 2969 * properties returned by `keysFunc` and invokes `iteratee` for each property. 2970 * Iteratee functions may exit iteration early by explicitly returning `false`. 2971 * 2972 * @private 2973 * @param {Object} object The object to iterate over. 2974 * @param {Function} iteratee The function invoked per iteration. 2975 * @param {Function} keysFunc The function to get the keys of `object`. 2976 * @returns {Object} Returns `object`. 2977 */ 2978 var baseFor = createBaseFor(); 2979 2980 /** 2981 * This function is like `baseFor` except that it iterates over properties 2982 * in the opposite order. 2983 * 2984 * @private 2985 * @param {Object} object The object to iterate over. 2986 * @param {Function} iteratee The function invoked per iteration. 2987 * @param {Function} keysFunc The function to get the keys of `object`. 2988 * @returns {Object} Returns `object`. 2989 */ 2990 var baseForRight = createBaseFor(true); 2991 2992 /** 2993 * The base implementation of `_.forOwn` without support for iteratee shorthands. 2994 * 2995 * @private 2996 * @param {Object} object The object to iterate over. 2997 * @param {Function} iteratee The function invoked per iteration. 2998 * @returns {Object} Returns `object`. 2999 */ 3000 function baseForOwn(object, iteratee) { 3001 return object && baseFor(object, iteratee, keys); 3002 } 3003 3004 /** 3005 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 3006 * 3007 * @private 3008 * @param {Object} object The object to iterate over. 3009 * @param {Function} iteratee The function invoked per iteration. 3010 * @returns {Object} Returns `object`. 3011 */ 3012 function baseForOwnRight(object, iteratee) { 3013 return object && baseForRight(object, iteratee, keys); 3014 } 3015 3016 /** 3017 * The base implementation of `_.functions` which creates an array of 3018 * `object` function property names filtered from `props`. 3019 * 3020 * @private 3021 * @param {Object} object The object to inspect. 3022 * @param {Array} props The property names to filter. 3023 * @returns {Array} Returns the function names. 3024 */ 3025 function baseFunctions(object, props) { 3026 return arrayFilter(props, function(key) { 3027 return isFunction(object[key]); 3028 }); 3029 } 3030 3031 /** 3032 * The base implementation of `_.get` without support for default values. 3033 * 3034 * @private 3035 * @param {Object} object The object to query. 3036 * @param {Array|string} path The path of the property to get. 3037 * @returns {*} Returns the resolved value. 3038 */ 3039 function baseGet(object, path) { 3040 path = castPath(path, object); 3041 3042 var index = 0, 3043 length = path.length; 3044 3045 while (object != null && index < length) { 3046 object = object[toKey(path[index++])]; 3047 } 3048 return (index && index == length) ? object : undefined; 3049 } 3050 3051 /** 3052 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 3053 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 3054 * symbols of `object`. 3055 * 3056 * @private 3057 * @param {Object} object The object to query. 3058 * @param {Function} keysFunc The function to get the keys of `object`. 3059 * @param {Function} symbolsFunc The function to get the symbols of `object`. 3060 * @returns {Array} Returns the array of property names and symbols. 3061 */ 3062 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 3063 var result = keysFunc(object); 3064 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 3065 } 3066 3067 /** 3068 * The base implementation of `getTag` without fallbacks for buggy environments. 3069 * 3070 * @private 3071 * @param {*} value The value to query. 3072 * @returns {string} Returns the `toStringTag`. 3073 */ 3074 function baseGetTag(value) { 3075 if (value == null) { 3076 return value === undefined ? undefinedTag : nullTag; 3077 } 3078 return (symToStringTag && symToStringTag in Object(value)) 3079 ? getRawTag(value) 3080 : objectToString(value); 3081 } 3082 3083 /** 3084 * The base implementation of `_.gt` which doesn't coerce arguments. 3085 * 3086 * @private 3087 * @param {*} value The value to compare. 3088 * @param {*} other The other value to compare. 3089 * @returns {boolean} Returns `true` if `value` is greater than `other`, 3090 * else `false`. 3091 */ 3092 function baseGt(value, other) { 3093 return value > other; 3094 } 3095 3096 /** 3097 * The base implementation of `_.has` without support for deep paths. 3098 * 3099 * @private 3100 * @param {Object} [object] The object to query. 3101 * @param {Array|string} key The key to check. 3102 * @returns {boolean} Returns `true` if `key` exists, else `false`. 3103 */ 3104 function baseHas(object, key) { 3105 return object != null && hasOwnProperty.call(object, key); 3106 } 3107 3108 /** 3109 * The base implementation of `_.hasIn` without support for deep paths. 3110 * 3111 * @private 3112 * @param {Object} [object] The object to query. 3113 * @param {Array|string} key The key to check. 3114 * @returns {boolean} Returns `true` if `key` exists, else `false`. 3115 */ 3116 function baseHasIn(object, key) { 3117 return object != null && key in Object(object); 3118 } 3119 3120 /** 3121 * The base implementation of `_.inRange` which doesn't coerce arguments. 3122 * 3123 * @private 3124 * @param {number} number The number to check. 3125 * @param {number} start The start of the range. 3126 * @param {number} end The end of the range. 3127 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 3128 */ 3129 function baseInRange(number, start, end) { 3130 return number >= nativeMin(start, end) && number < nativeMax(start, end); 3131 } 3132 3133 /** 3134 * The base implementation of methods like `_.intersection`, without support 3135 * for iteratee shorthands, that accepts an array of arrays to inspect. 3136 * 3137 * @private 3138 * @param {Array} arrays The arrays to inspect. 3139 * @param {Function} [iteratee] The iteratee invoked per element. 3140 * @param {Function} [comparator] The comparator invoked per element. 3141 * @returns {Array} Returns the new array of shared values. 3142 */ 3143 function baseIntersection(arrays, iteratee, comparator) { 3144 var includes = comparator ? arrayIncludesWith : arrayIncludes, 3145 length = arrays[0].length, 3146 othLength = arrays.length, 3147 othIndex = othLength, 3148 caches = Array(othLength), 3149 maxLength = Infinity, 3150 result = []; 3151 3152 while (othIndex--) { 3153 var array = arrays[othIndex]; 3154 if (othIndex && iteratee) { 3155 array = arrayMap(array, baseUnary(iteratee)); 3156 } 3157 maxLength = nativeMin(array.length, maxLength); 3158 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 3159 ? new SetCache(othIndex && array) 3160 : undefined; 3161 } 3162 array = arrays[0]; 3163 3164 var index = -1, 3165 seen = caches[0]; 3166 3167 outer: 3168 while (++index < length && result.length < maxLength) { 3169 var value = array[index], 3170 computed = iteratee ? iteratee(value) : value; 3171 3172 value = (comparator || value !== 0) ? value : 0; 3173 if (!(seen 3174 ? cacheHas(seen, computed) 3175 : includes(result, computed, comparator) 3176 )) { 3177 othIndex = othLength; 3178 while (--othIndex) { 3179 var cache = caches[othIndex]; 3180 if (!(cache 3181 ? cacheHas(cache, computed) 3182 : includes(arrays[othIndex], computed, comparator)) 3183 ) { 3184 continue outer; 3185 } 3186 } 3187 if (seen) { 3188 seen.push(computed); 3189 } 3190 result.push(value); 3191 } 3192 } 3193 return result; 3194 } 3195 3196 /** 3197 * The base implementation of `_.invert` and `_.invertBy` which inverts 3198 * `object` with values transformed by `iteratee` and set by `setter`. 3199 * 3200 * @private 3201 * @param {Object} object The object to iterate over. 3202 * @param {Function} setter The function to set `accumulator` values. 3203 * @param {Function} iteratee The iteratee to transform values. 3204 * @param {Object} accumulator The initial inverted object. 3205 * @returns {Function} Returns `accumulator`. 3206 */ 3207 function baseInverter(object, setter, iteratee, accumulator) { 3208 baseForOwn(object, function(value, key, object) { 3209 setter(accumulator, iteratee(value), key, object); 3210 }); 3211 return accumulator; 3212 } 3213 3214 /** 3215 * The base implementation of `_.invoke` without support for individual 3216 * method arguments. 3217 * 3218 * @private 3219 * @param {Object} object The object to query. 3220 * @param {Array|string} path The path of the method to invoke. 3221 * @param {Array} args The arguments to invoke the method with. 3222 * @returns {*} Returns the result of the invoked method. 3223 */ 3224 function baseInvoke(object, path, args) { 3225 path = castPath(path, object); 3226 object = parent(object, path); 3227 var func = object == null ? object : object[toKey(last(path))]; 3228 return func == null ? undefined : apply(func, object, args); 3229 } 3230 3231 /** 3232 * The base implementation of `_.isArguments`. 3233 * 3234 * @private 3235 * @param {*} value The value to check. 3236 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 3237 */ 3238 function baseIsArguments(value) { 3239 return isObjectLike(value) && baseGetTag(value) == argsTag; 3240 } 3241 3242 /** 3243 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 3244 * 3245 * @private 3246 * @param {*} value The value to check. 3247 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 3248 */ 3249 function baseIsArrayBuffer(value) { 3250 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 3251 } 3252 3253 /** 3254 * The base implementation of `_.isDate` without Node.js optimizations. 3255 * 3256 * @private 3257 * @param {*} value The value to check. 3258 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 3259 */ 3260 function baseIsDate(value) { 3261 return isObjectLike(value) && baseGetTag(value) == dateTag; 3262 } 3263 3264 /** 3265 * The base implementation of `_.isEqual` which supports partial comparisons 3266 * and tracks traversed objects. 3267 * 3268 * @private 3269 * @param {*} value The value to compare. 3270 * @param {*} other The other value to compare. 3271 * @param {boolean} bitmask The bitmask flags. 3272 * 1 - Unordered comparison 3273 * 2 - Partial comparison 3274 * @param {Function} [customizer] The function to customize comparisons. 3275 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 3276 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 3277 */ 3278 function baseIsEqual(value, other, bitmask, customizer, stack) { 3279 if (value === other) { 3280 return true; 3281 } 3282 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 3283 return value !== value && other !== other; 3284 } 3285 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 3286 } 3287 3288 /** 3289 * A specialized version of `baseIsEqual` for arrays and objects which performs 3290 * deep comparisons and tracks traversed objects enabling objects with circular 3291 * references to be compared. 3292 * 3293 * @private 3294 * @param {Object} object The object to compare. 3295 * @param {Object} other The other object to compare. 3296 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 3297 * @param {Function} customizer The function to customize comparisons. 3298 * @param {Function} equalFunc The function to determine equivalents of values. 3299 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 3300 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 3301 */ 3302 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 3303 var objIsArr = isArray(object), 3304 othIsArr = isArray(other), 3305 objTag = objIsArr ? arrayTag : getTag(object), 3306 othTag = othIsArr ? arrayTag : getTag(other); 3307 3308 objTag = objTag == argsTag ? objectTag : objTag; 3309 othTag = othTag == argsTag ? objectTag : othTag; 3310 3311 var objIsObj = objTag == objectTag, 3312 othIsObj = othTag == objectTag, 3313 isSameTag = objTag == othTag; 3314 3315 if (isSameTag && isBuffer(object)) { 3316 if (!isBuffer(other)) { 3317 return false; 3318 } 3319 objIsArr = true; 3320 objIsObj = false; 3321 } 3322 if (isSameTag && !objIsObj) { 3323 stack || (stack = new Stack); 3324 return (objIsArr || isTypedArray(object)) 3325 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 3326 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 3327 } 3328 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 3329 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 3330 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 3331 3332 if (objIsWrapped || othIsWrapped) { 3333 var objUnwrapped = objIsWrapped ? object.value() : object, 3334 othUnwrapped = othIsWrapped ? other.value() : other; 3335 3336 stack || (stack = new Stack); 3337 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 3338 } 3339 } 3340 if (!isSameTag) { 3341 return false; 3342 } 3343 stack || (stack = new Stack); 3344 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 3345 } 3346 3347 /** 3348 * The base implementation of `_.isMap` without Node.js optimizations. 3349 * 3350 * @private 3351 * @param {*} value The value to check. 3352 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 3353 */ 3354 function baseIsMap(value) { 3355 return isObjectLike(value) && getTag(value) == mapTag; 3356 } 3357 3358 /** 3359 * The base implementation of `_.isMatch` without support for iteratee shorthands. 3360 * 3361 * @private 3362 * @param {Object} object The object to inspect. 3363 * @param {Object} source The object of property values to match. 3364 * @param {Array} matchData The property names, values, and compare flags to match. 3365 * @param {Function} [customizer] The function to customize comparisons. 3366 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 3367 */ 3368 function baseIsMatch(object, source, matchData, customizer) { 3369 var index = matchData.length, 3370 length = index, 3371 noCustomizer = !customizer; 3372 3373 if (object == null) { 3374 return !length; 3375 } 3376 object = Object(object); 3377 while (index--) { 3378 var data = matchData[index]; 3379 if ((noCustomizer && data[2]) 3380 ? data[1] !== object[data[0]] 3381 : !(data[0] in object) 3382 ) { 3383 return false; 3384 } 3385 } 3386 while (++index < length) { 3387 data = matchData[index]; 3388 var key = data[0], 3389 objValue = object[key], 3390 srcValue = data[1]; 3391 3392 if (noCustomizer && data[2]) { 3393 if (objValue === undefined && !(key in object)) { 3394 return false; 3395 } 3396 } else { 3397 var stack = new Stack; 3398 if (customizer) { 3399 var result = customizer(objValue, srcValue, key, object, source, stack); 3400 } 3401 if (!(result === undefined 3402 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 3403 : result 3404 )) { 3405 return false; 3406 } 3407 } 3408 } 3409 return true; 3410 } 3411 3412 /** 3413 * The base implementation of `_.isNative` without bad shim checks. 3414 * 3415 * @private 3416 * @param {*} value The value to check. 3417 * @returns {boolean} Returns `true` if `value` is a native function, 3418 * else `false`. 3419 */ 3420 function baseIsNative(value) { 3421 if (!isObject(value) || isMasked(value)) { 3422 return false; 3423 } 3424 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 3425 return pattern.test(toSource(value)); 3426 } 3427 3428 /** 3429 * The base implementation of `_.isRegExp` without Node.js optimizations. 3430 * 3431 * @private 3432 * @param {*} value The value to check. 3433 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 3434 */ 3435 function baseIsRegExp(value) { 3436 return isObjectLike(value) && baseGetTag(value) == regexpTag; 3437 } 3438 3439 /** 3440 * The base implementation of `_.isSet` without Node.js optimizations. 3441 * 3442 * @private 3443 * @param {*} value The value to check. 3444 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 3445 */ 3446 function baseIsSet(value) { 3447 return isObjectLike(value) && getTag(value) == setTag; 3448 } 3449 3450 /** 3451 * The base implementation of `_.isTypedArray` without Node.js optimizations. 3452 * 3453 * @private 3454 * @param {*} value The value to check. 3455 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 3456 */ 3457 function baseIsTypedArray(value) { 3458 return isObjectLike(value) && 3459 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 3460 } 3461 3462 /** 3463 * The base implementation of `_.iteratee`. 3464 * 3465 * @private 3466 * @param {*} [value=_.identity] The value to convert to an iteratee. 3467 * @returns {Function} Returns the iteratee. 3468 */ 3469 function baseIteratee(value) { 3470 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 3471 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 3472 if (typeof value == 'function') { 3473 return value; 3474 } 3475 if (value == null) { 3476 return identity; 3477 } 3478 if (typeof value == 'object') { 3479 return isArray(value) 3480 ? baseMatchesProperty(value[0], value[1]) 3481 : baseMatches(value); 3482 } 3483 return property(value); 3484 } 3485 3486 /** 3487 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 3488 * 3489 * @private 3490 * @param {Object} object The object to query. 3491 * @returns {Array} Returns the array of property names. 3492 */ 3493 function baseKeys(object) { 3494 if (!isPrototype(object)) { 3495 return nativeKeys(object); 3496 } 3497 var result = []; 3498 for (var key in Object(object)) { 3499 if (hasOwnProperty.call(object, key) && key != 'constructor') { 3500 result.push(key); 3501 } 3502 } 3503 return result; 3504 } 3505 3506 /** 3507 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 3508 * 3509 * @private 3510 * @param {Object} object The object to query. 3511 * @returns {Array} Returns the array of property names. 3512 */ 3513 function baseKeysIn(object) { 3514 if (!isObject(object)) { 3515 return nativeKeysIn(object); 3516 } 3517 var isProto = isPrototype(object), 3518 result = []; 3519 3520 for (var key in object) { 3521 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 3522 result.push(key); 3523 } 3524 } 3525 return result; 3526 } 3527 3528 /** 3529 * The base implementation of `_.lt` which doesn't coerce arguments. 3530 * 3531 * @private 3532 * @param {*} value The value to compare. 3533 * @param {*} other The other value to compare. 3534 * @returns {boolean} Returns `true` if `value` is less than `other`, 3535 * else `false`. 3536 */ 3537 function baseLt(value, other) { 3538 return value < other; 3539 } 3540 3541 /** 3542 * The base implementation of `_.map` without support for iteratee shorthands. 3543 * 3544 * @private 3545 * @param {Array|Object} collection The collection to iterate over. 3546 * @param {Function} iteratee The function invoked per iteration. 3547 * @returns {Array} Returns the new mapped array. 3548 */ 3549 function baseMap(collection, iteratee) { 3550 var index = -1, 3551 result = isArrayLike(collection) ? Array(collection.length) : []; 3552 3553 baseEach(collection, function(value, key, collection) { 3554 result[++index] = iteratee(value, key, collection); 3555 }); 3556 return result; 3557 } 3558 3559 /** 3560 * The base implementation of `_.matches` which doesn't clone `source`. 3561 * 3562 * @private 3563 * @param {Object} source The object of property values to match. 3564 * @returns {Function} Returns the new spec function. 3565 */ 3566 function baseMatches(source) { 3567 var matchData = getMatchData(source); 3568 if (matchData.length == 1 && matchData[0][2]) { 3569 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 3570 } 3571 return function(object) { 3572 return object === source || baseIsMatch(object, source, matchData); 3573 }; 3574 } 3575 3576 /** 3577 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 3578 * 3579 * @private 3580 * @param {string} path The path of the property to get. 3581 * @param {*} srcValue The value to match. 3582 * @returns {Function} Returns the new spec function. 3583 */ 3584 function baseMatchesProperty(path, srcValue) { 3585 if (isKey(path) && isStrictComparable(srcValue)) { 3586 return matchesStrictComparable(toKey(path), srcValue); 3587 } 3588 return function(object) { 3589 var objValue = get(object, path); 3590 return (objValue === undefined && objValue === srcValue) 3591 ? hasIn(object, path) 3592 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 3593 }; 3594 } 3595 3596 /** 3597 * The base implementation of `_.merge` without support for multiple sources. 3598 * 3599 * @private 3600 * @param {Object} object The destination object. 3601 * @param {Object} source The source object. 3602 * @param {number} srcIndex The index of `source`. 3603 * @param {Function} [customizer] The function to customize merged values. 3604 * @param {Object} [stack] Tracks traversed source values and their merged 3605 * counterparts. 3606 */ 3607 function baseMerge(object, source, srcIndex, customizer, stack) { 3608 if (object === source) { 3609 return; 3610 } 3611 baseFor(source, function(srcValue, key) { 3612
vendor: 2,153 bytes, lines 3612-3673
3612if (isObject(srcValue)) { 3613 stack || (stack = new Stack); 3614 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 3615 } 3616 else { 3617 var newValue = customizer 3618 ? customizer(object[key], srcValue, (key + ''), object, source, stack) 3619 : undefined; 3620 3621 if (newValue === undefined) { 3622 newValue = srcValue; 3623 } 3624 assignMergeValue(object, key, newValue); 3625 } 3626 }, keysIn); 3627 } 3628 3629 /** 3630 * A specialized version of `baseMerge` for arrays and objects which performs 3631 * deep merges and tracks traversed objects enabling objects with circular 3632 * references to be merged. 3633 * 3634 * @private 3635 * @param {Object} object The destination object. 3636 * @param {Object} source The source object. 3637 * @param {string} key The key of the value to merge. 3638 * @param {number} srcIndex The index of `source`. 3639 * @param {Function} mergeFunc The function to merge values. 3640 * @param {Function} [customizer] The function to customize assigned values. 3641 * @param {Object} [stack] Tracks traversed source values and their merged 3642 * counterparts. 3643 */ 3644 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 3645 var objValue = object[key], 3646 srcValue = source[key], 3647 stacked = stack.get(srcValue); 3648 3649 if (stacked) { 3650 assignMergeValue(object, key, stacked); 3651 return; 3652 } 3653 var newValue = customizer 3654 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 3655 : undefined; 3656 3657 var isCommon = newValue === undefined; 3658 3659 if (isCommon) { 3660 var isArr = isArray(srcValue), 3661 isBuff = !isArr && isBuffer(srcValue), 3662 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 3663 3664 newValue = srcValue; 3665 if (isArr || isBuff || isTyped) { 3666 if (isArray(objValue)) { 3667 newValue = objValue; 3668 } 3669 else if (isArrayLikeObject(objValue)) { 3670 newValue = copyArray(objValue); 3671 } 3672 else if (isBuff) { 3673 isCommon = false;
3674 newValue = cloneBuffer(srcValue, true); 3675 } 3676 else if (isTyped) { 3677 isCommon = false; 3678 newValue = cloneTypedArray(srcValue, true); 3679 } 3680 else { 3681 newValue = []; 3682 } 3683 } 3684 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 3685 newValue = objValue; 3686 if (isArguments(objValue)) { 3687 newValue = toPlainObject(objValue); 3688 } 3689 else if (!isObject(objValue) || (srcIndex && isFunction(objValue)
vendor: 14,715 bytes, lines 3689-4152
3689)) { 3690 newValue = initCloneObject(srcValue); 3691 } 3692 } 3693 else { 3694 isCommon = false; 3695 } 3696 } 3697 if (isCommon) { 3698 // Recursively merge objects and arrays (susceptible to call stack limits). 3699 stack.set(srcValue, newValue); 3700 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 3701 stack['delete'](srcValue); 3702 } 3703 assignMergeValue(object, key, newValue); 3704 } 3705 3706 /** 3707 * The base implementation of `_.nth` which doesn't coerce arguments. 3708 * 3709 * @private 3710 * @param {Array} array The array to query. 3711 * @param {number} n The index of the element to return. 3712 * @returns {*} Returns the nth element of `array`. 3713 */ 3714 function baseNth(array, n) { 3715 var length = array.length; 3716 if (!length) { 3717 return; 3718 } 3719 n += n < 0 ? length : 0; 3720 return isIndex(n, length) ? array[n] : undefined; 3721 } 3722 3723 /** 3724 * The base implementation of `_.orderBy` without param guards. 3725 * 3726 * @private 3727 * @param {Array|Object} collection The collection to iterate over. 3728 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 3729 * @param {string[]} orders The sort orders of `iteratees`. 3730 * @returns {Array} Returns the new sorted array. 3731 */ 3732 function baseOrderBy(collection, iteratees, orders) { 3733 var index = -1; 3734 iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); 3735 3736 var result = baseMap(collection, function(value, key, collection) { 3737 var criteria = arrayMap(iteratees, function(iteratee) { 3738 return iteratee(value); 3739 }); 3740 return { 'criteria': criteria, 'index': ++index, 'value': value }; 3741 }); 3742 3743 return baseSortBy(result, function(object, other) { 3744 return compareMultiple(object, other, orders); 3745 }); 3746 } 3747 3748 /** 3749 * The base implementation of `_.pick` without support for individual 3750 * property identifiers. 3751 * 3752 * @private 3753 * @param {Object} object The source object. 3754 * @param {string[]} paths The property paths to pick. 3755 * @returns {Object} Returns the new object. 3756 */ 3757 function basePick(object, paths) { 3758 return basePickBy(object, paths, function(value, path) { 3759 return hasIn(object, path); 3760 }); 3761 } 3762 3763 /** 3764 * The base implementation of `_.pickBy` without support for iteratee shorthands. 3765 * 3766 * @private 3767 * @param {Object} object The source object. 3768 * @param {string[]} paths The property paths to pick. 3769 * @param {Function} predicate The function invoked per property. 3770 * @returns {Object} Returns the new object. 3771 */ 3772 function basePickBy(object, paths, predicate) { 3773 var index = -1, 3774 length = paths.length, 3775 result = {}; 3776 3777 while (++index < length) { 3778 var path = paths[index], 3779 value = baseGet(object, path); 3780 3781 if (predicate(value, path)) { 3782 baseSet(result, castPath(path, object), value); 3783 } 3784 } 3785 return result; 3786 } 3787 3788 /** 3789 * A specialized version of `baseProperty` which supports deep paths. 3790 * 3791 * @private 3792 * @param {Array|string} path The path of the property to get. 3793 * @returns {Function} Returns the new accessor function. 3794 */ 3795 function basePropertyDeep(path) { 3796 return function(object) { 3797 return baseGet(object, path); 3798 }; 3799 } 3800 3801 /** 3802 * The base implementation of `_.pullAllBy` without support for iteratee 3803 * shorthands. 3804 * 3805 * @private 3806 * @param {Array} array The array to modify. 3807 * @param {Array} values The values to remove. 3808 * @param {Function} [iteratee] The iteratee invoked per element. 3809 * @param {Function} [comparator] The comparator invoked per element. 3810 * @returns {Array} Returns `array`. 3811 */ 3812 function basePullAll(array, values, iteratee, comparator) { 3813 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 3814 index = -1, 3815 length = values.length, 3816 seen = array; 3817 3818 if (array === values) { 3819 values = copyArray(values); 3820 } 3821 if (iteratee) { 3822 seen = arrayMap(array, baseUnary(iteratee)); 3823 } 3824 while (++index < length) { 3825 var fromIndex = 0, 3826 value = values[index], 3827 computed = iteratee ? iteratee(value) : value; 3828 3829 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 3830 if (seen !== array) { 3831 splice.call(seen, fromIndex, 1); 3832 } 3833 splice.call(array, fromIndex, 1); 3834 } 3835 } 3836 return array; 3837 } 3838 3839 /** 3840 * The base implementation of `_.pullAt` without support for individual 3841 * indexes or capturing the removed elements. 3842 * 3843 * @private 3844 * @param {Array} array The array to modify. 3845 * @param {number[]} indexes The indexes of elements to remove. 3846 * @returns {Array} Returns `array`. 3847 */ 3848 function basePullAt(array, indexes) { 3849 var length = array ? indexes.length : 0, 3850 lastIndex = length - 1; 3851 3852 while (length--) { 3853 var index = indexes[length]; 3854 if (length == lastIndex || index !== previous) { 3855 var previous = index; 3856 if (isIndex(index)) { 3857 splice.call(array, index, 1); 3858 } else { 3859 baseUnset(array, index); 3860 } 3861 } 3862 } 3863 return array; 3864 } 3865 3866 /** 3867 * The base implementation of `_.random` without support for returning 3868 * floating-point numbers. 3869 * 3870 * @private 3871 * @param {number} lower The lower bound. 3872 * @param {number} upper The upper bound. 3873 * @returns {number} Returns the random number. 3874 */ 3875 function baseRandom(lower, upper) { 3876 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 3877 } 3878 3879 /** 3880 * The base implementation of `_.range` and `_.rangeRight` which doesn't 3881 * coerce arguments. 3882 * 3883 * @private 3884 * @param {number} start The start of the range. 3885 * @param {number} end The end of the range. 3886 * @param {number} step The value to increment or decrement by. 3887 * @param {boolean} [fromRight] Specify iterating from right to left. 3888 * @returns {Array} Returns the range of numbers. 3889 */ 3890 function baseRange(start, end, step, fromRight) { 3891 var index = -1, 3892 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 3893 result = Array(length); 3894 3895 while (length--) { 3896 result[fromRight ? length : ++index] = start; 3897 start += step; 3898 } 3899 return result; 3900 } 3901 3902 /** 3903 * The base implementation of `_.repeat` which doesn't coerce arguments. 3904 * 3905 * @private 3906 * @param {string} string The string to repeat. 3907 * @param {number} n The number of times to repeat the string. 3908 * @returns {string} Returns the repeated string. 3909 */ 3910 function baseRepeat(string, n) { 3911 var result = ''; 3912 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 3913 return result; 3914 } 3915 // Leverage the exponentiation by squaring algorithm for a faster repeat. 3916 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 3917 do { 3918 if (n % 2) { 3919 result += string; 3920 } 3921 n = nativeFloor(n / 2); 3922 if (n) { 3923 string += string; 3924 } 3925 } while (n); 3926 3927 return result; 3928 } 3929 3930 /** 3931 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 3932 * 3933 * @private 3934 * @param {Function} func The function to apply a rest parameter to. 3935 * @param {number} [start=func.length-1] The start position of the rest parameter. 3936 * @returns {Function} Returns the new function. 3937 */ 3938 function baseRest(func, start) { 3939 return setToString(overRest(func, start, identity), func + ''); 3940 } 3941 3942 /** 3943 * The base implementation of `_.sample`. 3944 * 3945 * @private 3946 * @param {Array|Object} collection The collection to sample. 3947 * @returns {*} Returns the random element. 3948 */ 3949 function baseSample(collection) { 3950 return arraySample(values(collection)); 3951 } 3952 3953 /** 3954 * The base implementation of `_.sampleSize` without param guards. 3955 * 3956 * @private 3957 * @param {Array|Object} collection The collection to sample. 3958 * @param {number} n The number of elements to sample. 3959 * @returns {Array} Returns the random elements. 3960 */ 3961 function baseSampleSize(collection, n) { 3962 var array = values(collection); 3963 return shuffleSelf(array, baseClamp(n, 0, array.length)); 3964 } 3965 3966 /** 3967 * The base implementation of `_.set`. 3968 * 3969 * @private 3970 * @param {Object} object The object to modify. 3971 * @param {Array|string} path The path of the property to set. 3972 * @param {*} value The value to set. 3973 * @param {Function} [customizer] The function to customize path creation. 3974 * @returns {Object} Returns `object`. 3975 */ 3976 function baseSet(object, path, value, customizer) { 3977 if (!isObject(object)) { 3978 return object; 3979 } 3980 path = castPath(path, object); 3981 3982 var index = -1, 3983 length = path.length, 3984 lastIndex = length - 1, 3985 nested = object; 3986 3987 while (nested != null && ++index < length) { 3988 var key = toKey(path[index]), 3989 newValue = value; 3990 3991 if (index != lastIndex) { 3992 var objValue = nested[key]; 3993 newValue = customizer ? customizer(objValue, key, nested) : undefined; 3994 if (newValue === undefined) { 3995 newValue = isObject(objValue) 3996 ? objValue 3997 : (isIndex(path[index + 1]) ? [] : {}); 3998 } 3999 } 4000 assignValue(nested, key, newValue); 4001 nested = nested[key]; 4002 } 4003 return object; 4004 } 4005 4006 /** 4007 * The base implementation of `setData` without support for hot loop shorting. 4008 * 4009 * @private 4010 * @param {Function} func The function to associate metadata with. 4011 * @param {*} data The metadata. 4012 * @returns {Function} Returns `func`. 4013 */ 4014 var baseSetData = !metaMap ? identity : function(func, data) { 4015 metaMap.set(func, data); 4016 return func; 4017 }; 4018 4019 /** 4020 * The base implementation of `setToString` without support for hot loop shorting. 4021 * 4022 * @private 4023 * @param {Function} func The function to modify. 4024 * @param {Function} string The `toString` result. 4025 * @returns {Function} Returns `func`. 4026 */ 4027 var baseSetToString = !defineProperty ? identity : function(func, string) { 4028 return defineProperty(func, 'toString', { 4029 'configurable': true, 4030 'enumerable': false, 4031 'value': constant(string), 4032 'writable': true 4033 }); 4034 }; 4035 4036 /** 4037 * The base implementation of `_.shuffle`. 4038 * 4039 * @private 4040 * @param {Array|Object} collection The collection to shuffle. 4041 * @returns {Array} Returns the new shuffled array. 4042 */ 4043 function baseShuffle(collection) { 4044 return shuffleSelf(values(collection)); 4045 } 4046 4047 /** 4048 * The base implementation of `_.slice` without an iteratee call guard. 4049 * 4050 * @private 4051 * @param {Array} array The array to slice. 4052 * @param {number} [start=0] The start position. 4053 * @param {number} [end=array.length] The end position. 4054 * @returns {Array} Returns the slice of `array`. 4055 */ 4056 function baseSlice(array, start, end) { 4057 var index = -1, 4058 length = array.length; 4059 4060 if (start < 0) { 4061 start = -start > length ? 0 : (length + start); 4062 } 4063 end = end > length ? length : end; 4064 if (end < 0) { 4065 end += length; 4066 } 4067 length = start > end ? 0 : ((end - start) >>> 0); 4068 start >>>= 0; 4069 4070 var result = Array(length); 4071 while (++index < length) { 4072 result[index] = array[index + start]; 4073 } 4074 return result; 4075 } 4076 4077 /** 4078 * The base implementation of `_.some` without support for iteratee shorthands. 4079 * 4080 * @private 4081 * @param {Array|Object} collection The collection to iterate over. 4082 * @param {Function} predicate The function invoked per iteration. 4083 * @returns {boolean} Returns `true` if any element passes the predicate check, 4084 * else `false`. 4085 */ 4086 function baseSome(collection, predicate) { 4087 var result; 4088 4089 baseEach(collection, function(value, index, collection) { 4090 result = predicate(value, index, collection); 4091 return !result; 4092 }); 4093 return !!result; 4094 } 4095 4096 /** 4097 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 4098 * performs a binary search of `array` to determine the index at which `value` 4099 * should be inserted into `array` in order to maintain its sort order. 4100 * 4101 * @private 4102 * @param {Array} array The sorted array to inspect. 4103 * @param {*} value The value to evaluate. 4104 * @param {boolean} [retHighest] Specify returning the highest qualified index. 4105 * @returns {number} Returns the index at which `value` should be inserted 4106 * into `array`. 4107 */ 4108 function baseSortedIndex(array, value, retHighest) { 4109 var low = 0, 4110 high = array == null ? low : array.length; 4111 4112 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 4113 while (low < high) { 4114 var mid = (low + high) >>> 1, 4115 computed = array[mid]; 4116 4117 if (computed !== null && !isSymbol(computed) && 4118 (retHighest ? (computed <= value) : (computed < value))) { 4119 low = mid + 1; 4120 } else { 4121 high = mid; 4122 } 4123 } 4124 return high; 4125 } 4126 return baseSortedIndexBy(array, value, identity, retHighest); 4127 } 4128 4129 /** 4130 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 4131 * which invokes `iteratee` for `value` and each element of `array` to compute 4132 * their sort ranking. The iteratee is invoked with one argument; (value). 4133 * 4134 * @private 4135 * @param {Array} array The sorted array to inspect. 4136 * @param {*} value The value to evaluate. 4137 * @param {Function} iteratee The iteratee invoked per element. 4138 * @param {boolean} [retHighest] Specify returning the highest qualified index. 4139 * @returns {number} Returns the index at which `value` should be inserted 4140 * into `array`. 4141 */ 4142 function baseSortedIndexBy(array, value, iteratee, retHighest) { 4143 value = iteratee(value); 4144 4145 var low = 0, 4146 high = array == null ? 0 : array.length, 4147 valIsNaN = value !== value, 4148 valIsNull = value === null, 4149 valIsSymbol = isSymbol(value), 4150 valIsUndefined = value === undefined; 4151 4152 while (low < high) {
vendor: 12,977 bytes, lines 4153-4555
4153 var mid = nativeFloor((low + high) / 2), 4154 computed = iteratee(array[mid]), 4155 othIsDefined = computed !== undefined, 4156 othIsNull = computed === null, 4157 othIsReflexive = computed === computed, 4158 othIsSymbol = isSymbol(computed); 4159 4160 if (valIsNaN) { 4161 var setLow = retHighest || othIsReflexive; 4162 } else if (valIsUndefined) { 4163 setLow = othIsReflexive && (retHighest || othIsDefined); 4164 } else if (valIsNull) { 4165 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 4166 } else if (valIsSymbol) { 4167 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 4168 } else if (othIsNull || othIsSymbol) { 4169 setLow = false; 4170 } else { 4171 setLow = retHighest ? (computed <= value) : (computed < value); 4172 } 4173 if (setLow) { 4174 low = mid + 1; 4175 } else { 4176 high = mid; 4177 } 4178 } 4179 return nativeMin(high, MAX_ARRAY_INDEX); 4180 } 4181 4182 /** 4183 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 4184 * support for iteratee shorthands. 4185 * 4186 * @private 4187 * @param {Array} array The array to inspect. 4188 * @param {Function} [iteratee] The iteratee invoked per element. 4189 * @returns {Array} Returns the new duplicate free array. 4190 */ 4191 function baseSortedUniq(array, iteratee) { 4192 var index = -1, 4193 length = array.length, 4194 resIndex = 0, 4195 result = []; 4196 4197 while (++index < length) { 4198 var value = array[index], 4199 computed = iteratee ? iteratee(value) : value; 4200 4201 if (!index || !eq(computed, seen)) { 4202 var seen = computed; 4203 result[resIndex++] = value === 0 ? 0 : value; 4204 } 4205 } 4206 return result; 4207 } 4208 4209 /** 4210 * The base implementation of `_.toNumber` which doesn't ensure correct 4211 * conversions of binary, hexadecimal, or octal string values. 4212 * 4213 * @private 4214 * @param {*} value The value to process. 4215 * @returns {number} Returns the number. 4216 */ 4217 function baseToNumber(value) { 4218 if (typeof value == 'number') { 4219 return value; 4220 } 4221 if (isSymbol(value)) { 4222 return NAN; 4223 } 4224 return +value; 4225 } 4226 4227 /** 4228 * The base implementation of `_.toString` which doesn't convert nullish 4229 * values to empty strings. 4230 * 4231 * @private 4232 * @param {*} value The value to process. 4233 * @returns {string} Returns the string. 4234 */ 4235 function baseToString(value) { 4236 // Exit early for strings to avoid a performance hit in some environments. 4237 if (typeof value == 'string') { 4238 return value; 4239 } 4240 if (isArray(value)) { 4241 // Recursively convert values (susceptible to call stack limits). 4242 return arrayMap(value, baseToString) + ''; 4243 } 4244 if (isSymbol(value)) { 4245 return symbolToString ? symbolToString.call(value) : ''; 4246 } 4247 var result = (value + ''); 4248 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 4249 } 4250 4251 /** 4252 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 4253 * 4254 * @private 4255 * @param {Array} array The array to inspect. 4256 * @param {Function} [iteratee] The iteratee invoked per element. 4257 * @param {Function} [comparator] The comparator invoked per element. 4258 * @returns {Array} Returns the new duplicate free array. 4259 */ 4260 function baseUniq(array, iteratee, comparator) { 4261 var index = -1, 4262 includes = arrayIncludes, 4263 length = array.length, 4264 isCommon = true, 4265 result = [], 4266 seen = result; 4267 4268 if (comparator) { 4269 isCommon = false; 4270 includes = arrayIncludesWith; 4271 } 4272 else if (length >= LARGE_ARRAY_SIZE) { 4273 var set = iteratee ? null : createSet(array); 4274 if (set) { 4275 return setToArray(set); 4276 } 4277 isCommon = false; 4278 includes = cacheHas; 4279 seen = new SetCache; 4280 } 4281 else { 4282 seen = iteratee ? [] : result; 4283 } 4284 outer: 4285 while (++index < length) { 4286 var value = array[index], 4287 computed = iteratee ? iteratee(value) : value; 4288 4289 value = (comparator || value !== 0) ? value : 0; 4290 if (isCommon && computed === computed) { 4291 var seenIndex = seen.length; 4292 while (seenIndex--) { 4293 if (seen[seenIndex] === computed) { 4294 continue outer; 4295 } 4296 } 4297 if (iteratee) { 4298 seen.push(computed); 4299 } 4300 result.push(value); 4301 } 4302 else if (!includes(seen, computed, comparator)) { 4303 if (seen !== result) { 4304 seen.push(computed); 4305 } 4306 result.push(value); 4307 } 4308 } 4309 return result; 4310 } 4311 4312 /** 4313 * The base implementation of `_.unset`. 4314 * 4315 * @private 4316 * @param {Object} object The object to modify. 4317 * @param {Array|string} path The property path to unset. 4318 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 4319 */ 4320 function baseUnset(object, path) { 4321 path = castPath(path, object); 4322 object = parent(object, path); 4323 return object == null || delete object[toKey(last(path))]; 4324 } 4325 4326 /** 4327 * The base implementation of `_.update`. 4328 * 4329 * @private 4330 * @param {Object} object The object to modify. 4331 * @param {Array|string} path The path of the property to update. 4332 * @param {Function} updater The function to produce the updated value. 4333 * @param {Function} [customizer] The function to customize path creation. 4334 * @returns {Object} Returns `object`. 4335 */ 4336 function baseUpdate(object, path, updater, customizer) { 4337 return baseSet(object, path, updater(baseGet(object, path)), customizer); 4338 } 4339 4340 /** 4341 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 4342 * without support for iteratee shorthands. 4343 * 4344 * @private 4345 * @param {Array} array The array to query. 4346 * @param {Function} predicate The function invoked per iteration. 4347 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 4348 * @param {boolean} [fromRight] Specify iterating from right to left. 4349 * @returns {Array} Returns the slice of `array`. 4350 */ 4351 function baseWhile(array, predicate, isDrop, fromRight) { 4352 var length = array.length, 4353 index = fromRight ? length : -1; 4354 4355 while ((fromRight ? index-- : ++index < length) && 4356 predicate(array[index], index, array)) {} 4357 4358 return isDrop 4359 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 4360 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 4361 } 4362 4363 /** 4364 * The base implementation of `wrapperValue` which returns the result of 4365 * performing a sequence of actions on the unwrapped `value`, where each 4366 * successive action is supplied the return value of the previous. 4367 * 4368 * @private 4369 * @param {*} value The unwrapped value. 4370 * @param {Array} actions Actions to perform to resolve the unwrapped value. 4371 * @returns {*} Returns the resolved value. 4372 */ 4373 function baseWrapperValue(value, actions) { 4374 var result = value; 4375 if (result instanceof LazyWrapper) { 4376 result = result.value(); 4377 } 4378 return arrayReduce(actions, function(result, action) { 4379 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 4380 }, result); 4381 } 4382 4383 /** 4384 * The base implementation of methods like `_.xor`, without support for 4385 * iteratee shorthands, that accepts an array of arrays to inspect. 4386 * 4387 * @private 4388 * @param {Array} arrays The arrays to inspect. 4389 * @param {Function} [iteratee] The iteratee invoked per element. 4390 * @param {Function} [comparator] The comparator invoked per element. 4391 * @returns {Array} Returns the new array of values. 4392 */ 4393 function baseXor(arrays, iteratee, comparator) { 4394 var length = arrays.length; 4395 if (length < 2) { 4396 return length ? baseUniq(arrays[0]) : []; 4397 } 4398 var index = -1, 4399 result = Array(length); 4400 4401 while (++index < length) { 4402 var array = arrays[index], 4403 othIndex = -1; 4404 4405 while (++othIndex < length) { 4406 if (othIndex != index) { 4407 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 4408 } 4409 } 4410 } 4411 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 4412 } 4413 4414 /** 4415 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 4416 * 4417 * @private 4418 * @param {Array} props The property identifiers. 4419 * @param {Array} values The property values. 4420 * @param {Function} assignFunc The function to assign values. 4421 * @returns {Object} Returns the new object. 4422 */ 4423 function baseZipObject(props, values, assignFunc) { 4424 var index = -1, 4425 length = props.length, 4426 valsLength = values.length, 4427 result = {}; 4428 4429 while (++index < length) { 4430 var value = index < valsLength ? values[index] : undefined; 4431 assignFunc(result, props[index], value); 4432 } 4433 return result; 4434 } 4435 4436 /** 4437 * Casts `value` to an empty array if it's not an array like object. 4438 * 4439 * @private 4440 * @param {*} value The value to inspect. 4441 * @returns {Array|Object} Returns the cast array-like object. 4442 */ 4443 function castArrayLikeObject(value) { 4444 return isArrayLikeObject(value) ? value : []; 4445 } 4446 4447 /** 4448 * Casts `value` to `identity` if it's not a function. 4449 * 4450 * @private 4451 * @param {*} value The value to inspect. 4452 * @returns {Function} Returns cast function. 4453 */ 4454 function castFunction(value) { 4455 return typeof value == 'function' ? value : identity; 4456 } 4457 4458 /** 4459 * Casts `value` to a path array if it's not one. 4460 * 4461 * @private 4462 * @param {*} value The value to inspect. 4463 * @param {Object} [object] The object to query keys on. 4464 * @returns {Array} Returns the cast property path array. 4465 */ 4466 function castPath(value, object) { 4467 if (isArray(value)) { 4468 return value; 4469 } 4470 return isKey(value, object) ? [value] : stringToPath(toString(value)); 4471 } 4472 4473 /** 4474 * A `baseRest` alias which can be replaced with `identity` by module 4475 * replacement plugins. 4476 * 4477 * @private 4478 * @type {Function} 4479 * @param {Function} func The function to apply a rest parameter to. 4480 * @returns {Function} Returns the new function. 4481 */ 4482 var castRest = baseRest; 4483 4484 /** 4485 * Casts `array` to a slice if it's needed. 4486 * 4487 * @private 4488 * @param {Array} array The array to inspect. 4489 * @param {number} start The start position. 4490 * @param {number} [end=array.length] The end position. 4491 * @returns {Array} Returns the cast slice. 4492 */ 4493 function castSlice(array, start, end) { 4494 var length = array.length; 4495 end = end === undefined ? length : end; 4496 return (!start && end >= length) ? array : baseSlice(array, start, end); 4497 } 4498 4499 /** 4500 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 4501 * 4502 * @private 4503 * @param {number|Object} id The timer id or timeout object of the timer to clear. 4504 */ 4505 var clearTimeout = ctxClearTimeout || function(id) { 4506 return root.clearTimeout(id); 4507 }; 4508 4509 /** 4510 * Creates a clone of `buffer`. 4511 * 4512 * @private 4513 * @param {Buffer} buffer The buffer to clone. 4514 * @param {boolean} [isDeep] Specify a deep clone. 4515 * @returns {Buffer} Returns the cloned buffer. 4516 */ 4517 function cloneBuffer(buffer, isDeep) { 4518 if (isDeep) { 4519 return buffer.slice(); 4520 } 4521 var length = buffer.length, 4522 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 4523 4524 buffer.copy(result); 4525 return result; 4526 } 4527 4528 /** 4529 * Creates a clone of `arrayBuffer`. 4530 * 4531 * @private 4532 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 4533 * @returns {ArrayBuffer} Returns the cloned array buffer. 4534 */ 4535 function cloneArrayBuffer(arrayBuffer) { 4536 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 4537 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 4538 return result; 4539 } 4540 4541 /** 4542 * Creates a clone of `dataView`. 4543 * 4544 * @private 4545 * @param {Object} dataView The data view to clone. 4546 * @param {boolean} [isDeep] Specify a deep clone. 4547 * @returns {Object} Returns the cloned data view. 4548 */ 4549 function cloneDataView(dataView, isDeep) { 4550 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 4551 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 4552 } 4553 4554 /** 4555 * Creates a clone of `
4555map`. 4556 * 4557 * @private 4558 * @param {Object} map The map to clone. 4559 * @param {Function} cloneFunc The function to clone values. 4560 * @param {boolean} [isDeep] Specify a deep clone. 4561 * @returns {Object} Returns the cloned map. 4562 */ 4563 function cloneMap(map, isDeep, cloneFunc) { 4564 var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map); 4565 return arrayReduce(array, addMapEntry, new map.constructor); 4566 } 4567 4568 /** 4569 * Creates a clone of `regexp`. 4570 * 4571 * @private 4572 * @param {Object} regexp The regexp to clone. 4573 * @returns {Object} Returns the cloned regexp. 4574 */ 4575 function cloneRegExp(regexp) { 4576 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 4577 result.lastIndex = regexp.lastIndex; 4578 return result; 4579 } 4580 4581 /** 4582 * Creates a clone of `set`. 4583 * 4584 * @private 4585 * @param {Object} set The set to clone. 4586 * @param {Function} cloneFunc The function to clone values. 4587 * @param {boolean} [isDeep] Specify a deep clone. 4588 * @returns {Object} Returns the cloned set. 4589 */ 4590 function cloneSet(set, isDeep, cloneFunc) { 4591 var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set); 4592 return arrayReduce(array, addSetEntry, new set.constructor)
vendor: 37,974 bytes, lines 4592-5658
4592; 4593 } 4594 4595 /** 4596 * Creates a clone of the `symbol` object. 4597 * 4598 * @private 4599 * @param {Object} symbol The symbol object to clone. 4600 * @returns {Object} Returns the cloned symbol object. 4601 */ 4602 function cloneSymbol(symbol) { 4603 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 4604 } 4605 4606 /** 4607 * Creates a clone of `typedArray`. 4608 * 4609 * @private 4610 * @param {Object} typedArray The typed array to clone. 4611 * @param {boolean} [isDeep] Specify a deep clone. 4612 * @returns {Object} Returns the cloned typed array. 4613 */ 4614 function cloneTypedArray(typedArray, isDeep) { 4615 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 4616 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 4617 } 4618 4619 /** 4620 * Compares values to sort them in ascending order. 4621 * 4622 * @private 4623 * @param {*} value The value to compare. 4624 * @param {*} other The other value to compare. 4625 * @returns {number} Returns the sort order indicator for `value`. 4626 */ 4627 function compareAscending(value, other) { 4628 if (value !== other) { 4629 var valIsDefined = value !== undefined, 4630 valIsNull = value === null, 4631 valIsReflexive = value === value, 4632 valIsSymbol = isSymbol(value); 4633 4634 var othIsDefined = other !== undefined, 4635 othIsNull = other === null, 4636 othIsReflexive = other === other, 4637 othIsSymbol = isSymbol(other); 4638 4639 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 4640 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 4641 (valIsNull && othIsDefined && othIsReflexive) || 4642 (!valIsDefined && othIsReflexive) || 4643 !valIsReflexive) { 4644 return 1; 4645 } 4646 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 4647 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 4648 (othIsNull && valIsDefined && valIsReflexive) || 4649 (!othIsDefined && valIsReflexive) || 4650 !othIsReflexive) { 4651 return -1; 4652 } 4653 } 4654 return 0; 4655 } 4656 4657 /** 4658 * Used by `_.orderBy` to compare multiple properties of a value to another 4659 * and stable sort them. 4660 * 4661 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 4662 * specify an order of "desc" for descending or "asc" for ascending sort order 4663 * of corresponding values. 4664 * 4665 * @private 4666 * @param {Object} object The object to compare. 4667 * @param {Object} other The other object to compare. 4668 * @param {boolean[]|string[]} orders The order to sort by for each property. 4669 * @returns {number} Returns the sort order indicator for `object`. 4670 */ 4671 function compareMultiple(object, other, orders) { 4672 var index = -1, 4673 objCriteria = object.criteria, 4674 othCriteria = other.criteria, 4675 length = objCriteria.length, 4676 ordersLength = orders.length; 4677 4678 while (++index < length) { 4679 var result = compareAscending(objCriteria[index], othCriteria[index]); 4680 if (result) { 4681 if (index >= ordersLength) { 4682 return result; 4683 } 4684 var order = orders[index]; 4685 return result * (order == 'desc' ? -1 : 1); 4686 } 4687 } 4688 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 4689 // that causes it, under certain circumstances, to provide the same value for 4690 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 4691 // for more details. 4692 // 4693 // This also ensures a stable sort in V8 and other engines. 4694 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 4695 return object.index - other.index; 4696 } 4697 4698 /** 4699 * Creates an array that is the composition of partially applied arguments, 4700 * placeholders, and provided arguments into a single array of arguments. 4701 * 4702 * @private 4703 * @param {Array} args The provided arguments. 4704 * @param {Array} partials The arguments to prepend to those provided. 4705 * @param {Array} holders The `partials` placeholder indexes. 4706 * @params {boolean} [isCurried] Specify composing for a curried function. 4707 * @returns {Array} Returns the new array of composed arguments. 4708 */ 4709 function composeArgs(args, partials, holders, isCurried) { 4710 var argsIndex = -1, 4711 argsLength = args.length, 4712 holdersLength = holders.length, 4713 leftIndex = -1, 4714 leftLength = partials.length, 4715 rangeLength = nativeMax(argsLength - holdersLength, 0), 4716 result = Array(leftLength + rangeLength), 4717 isUncurried = !isCurried; 4718 4719 while (++leftIndex < leftLength) { 4720 result[leftIndex] = partials[leftIndex]; 4721 } 4722 while (++argsIndex < holdersLength) { 4723 if (isUncurried || argsIndex < argsLength) { 4724 result[holders[argsIndex]] = args[argsIndex]; 4725 } 4726 } 4727 while (rangeLength--) { 4728 result[leftIndex++] = args[argsIndex++]; 4729 } 4730 return result; 4731 } 4732 4733 /** 4734 * This function is like `composeArgs` except that the arguments composition 4735 * is tailored for `_.partialRight`. 4736 * 4737 * @private 4738 * @param {Array} args The provided arguments. 4739 * @param {Array} partials The arguments to append to those provided. 4740 * @param {Array} holders The `partials` placeholder indexes. 4741 * @params {boolean} [isCurried] Specify composing for a curried function. 4742 * @returns {Array} Returns the new array of composed arguments. 4743 */ 4744 function composeArgsRight(args, partials, holders, isCurried) { 4745 var argsIndex = -1, 4746 argsLength = args.length, 4747 holdersIndex = -1, 4748 holdersLength = holders.length, 4749 rightIndex = -1, 4750 rightLength = partials.length, 4751 rangeLength = nativeMax(argsLength - holdersLength, 0), 4752 result = Array(rangeLength + rightLength), 4753 isUncurried = !isCurried; 4754 4755 while (++argsIndex < rangeLength) { 4756 result[argsIndex] = args[argsIndex]; 4757 } 4758 var offset = argsIndex; 4759 while (++rightIndex < rightLength) { 4760 result[offset + rightIndex] = partials[rightIndex]; 4761 } 4762 while (++holdersIndex < holdersLength) { 4763 if (isUncurried || argsIndex < argsLength) { 4764 result[offset + holders[holdersIndex]] = args[argsIndex++]; 4765 } 4766 } 4767 return result; 4768 } 4769 4770 /** 4771 * Copies the values of `source` to `array`. 4772 * 4773 * @private 4774 * @param {Array} source The array to copy values from. 4775 * @param {Array} [array=[]] The array to copy values to. 4776 * @returns {Array} Returns `array`. 4777 */ 4778 function copyArray(source, array) { 4779 var index = -1, 4780 length = source.length; 4781 4782 array || (array = Array(length)); 4783 while (++index < length) { 4784 array[index] = source[index]; 4785 } 4786 return array; 4787 } 4788 4789 /** 4790 * Copies properties of `source` to `object`. 4791 * 4792 * @private 4793 * @param {Object} source The object to copy properties from. 4794 * @param {Array} props The property identifiers to copy. 4795 * @param {Object} [object={}] The object to copy properties to. 4796 * @param {Function} [customizer] The function to customize copied values. 4797 * @returns {Object} Returns `object`. 4798 */ 4799 function copyObject(source, props, object, customizer) { 4800 var isNew = !object; 4801 object || (object = {}); 4802 4803 var index = -1, 4804 length = props.length; 4805 4806 while (++index < length) { 4807 var key = props[index]; 4808 4809 var newValue = customizer 4810 ? customizer(object[key], source[key], key, object, source) 4811 : undefined; 4812 4813 if (newValue === undefined) { 4814 newValue = source[key]; 4815 } 4816 if (isNew) { 4817 baseAssignValue(object, key, newValue); 4818 } else { 4819 assignValue(object, key, newValue); 4820 } 4821 } 4822 return object; 4823 } 4824 4825 /** 4826 * Copies own symbols of `source` to `object`. 4827 * 4828 * @private 4829 * @param {Object} source The object to copy symbols from. 4830 * @param {Object} [object={}] The object to copy symbols to. 4831 * @returns {Object} Returns `object`. 4832 */ 4833 function copySymbols(source, object) { 4834 return copyObject(source, getSymbols(source), object); 4835 } 4836 4837 /** 4838 * Copies own and inherited symbols of `source` to `object`. 4839 * 4840 * @private 4841 * @param {Object} source The object to copy symbols from. 4842 * @param {Object} [object={}] The object to copy symbols to. 4843 * @returns {Object} Returns `object`. 4844 */ 4845 function copySymbolsIn(source, object) { 4846 return copyObject(source, getSymbolsIn(source), object); 4847 } 4848 4849 /** 4850 * Creates a function like `_.groupBy`. 4851 * 4852 * @private 4853 * @param {Function} setter The function to set accumulator values. 4854 * @param {Function} [initializer] The accumulator object initializer. 4855 * @returns {Function} Returns the new aggregator function. 4856 */ 4857 function createAggregator(setter, initializer) { 4858 return function(collection, iteratee) { 4859 var func = isArray(collection) ? arrayAggregator : baseAggregator, 4860 accumulator = initializer ? initializer() : {}; 4861 4862 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 4863 }; 4864 } 4865 4866 /** 4867 * Creates a function like `_.assign`. 4868 * 4869 * @private 4870 * @param {Function} assigner The function to assign values. 4871 * @returns {Function} Returns the new assigner function. 4872 */ 4873 function createAssigner(assigner) { 4874 return baseRest(function(object, sources) { 4875 var index = -1, 4876 length = sources.length, 4877 customizer = length > 1 ? sources[length - 1] : undefined, 4878 guard = length > 2 ? sources[2] : undefined; 4879 4880 customizer = (assigner.length > 3 && typeof customizer == 'function') 4881 ? (length--, customizer) 4882 : undefined; 4883 4884 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 4885 customizer = length < 3 ? undefined : customizer; 4886 length = 1; 4887 } 4888 object = Object(object); 4889 while (++index < length) { 4890 var source = sources[index]; 4891 if (source) { 4892 assigner(object, source, index, customizer); 4893 } 4894 } 4895 return object; 4896 }); 4897 } 4898 4899 /** 4900 * Creates a `baseEach` or `baseEachRight` function. 4901 * 4902 * @private 4903 * @param {Function} eachFunc The function to iterate over a collection. 4904 * @param {boolean} [fromRight] Specify iterating from right to left. 4905 * @returns {Function} Returns the new base function. 4906 */ 4907 function createBaseEach(eachFunc, fromRight) { 4908 return function(collection, iteratee) { 4909 if (collection == null) { 4910 return collection; 4911 } 4912 if (!isArrayLike(collection)) { 4913 return eachFunc(collection, iteratee); 4914 } 4915 var length = collection.length, 4916 index = fromRight ? length : -1, 4917 iterable = Object(collection); 4918 4919 while ((fromRight ? index-- : ++index < length)) { 4920 if (iteratee(iterable[index], index, iterable) === false) { 4921 break; 4922 } 4923 } 4924 return collection; 4925 }; 4926 } 4927 4928 /** 4929 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 4930 * 4931 * @private 4932 * @param {boolean} [fromRight] Specify iterating from right to left. 4933 * @returns {Function} Returns the new base function. 4934 */ 4935 function createBaseFor(fromRight) { 4936 return function(object, iteratee, keysFunc) { 4937 var index = -1, 4938 iterable = Object(object), 4939 props = keysFunc(object), 4940 length = props.length; 4941 4942 while (length--) { 4943 var key = props[fromRight ? length : ++index]; 4944 if (iteratee(iterable[key], key, iterable) === false) { 4945 break; 4946 } 4947 } 4948 return object; 4949 }; 4950 } 4951 4952 /** 4953 * Creates a function that wraps `func` to invoke it with the optional `this` 4954 * binding of `thisArg`. 4955 * 4956 * @private 4957 * @param {Function} func The function to wrap. 4958 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 4959 * @param {*} [thisArg] The `this` binding of `func`. 4960 * @returns {Function} Returns the new wrapped function. 4961 */ 4962 function createBind(func, bitmask, thisArg) { 4963 var isBind = bitmask & WRAP_BIND_FLAG, 4964 Ctor = createCtor(func); 4965 4966 function wrapper() { 4967 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 4968 return fn.apply(isBind ? thisArg : this, arguments); 4969 } 4970 return wrapper; 4971 } 4972 4973 /** 4974 * Creates a function like `_.lowerFirst`. 4975 * 4976 * @private 4977 * @param {string} methodName The name of the `String` case method to use. 4978 * @returns {Function} Returns the new case function. 4979 */ 4980 function createCaseFirst(methodName) { 4981 return function(string) { 4982 string = toString(string); 4983 4984 var strSymbols = hasUnicode(string) 4985 ? stringToArray(string) 4986 : undefined; 4987 4988 var chr = strSymbols 4989 ? strSymbols[0] 4990 : string.charAt(0); 4991 4992 var trailing = strSymbols 4993 ? castSlice(strSymbols, 1).join('') 4994 : string.slice(1); 4995 4996 return chr[methodName]() + trailing; 4997 }; 4998 } 4999 5000 /** 5001 * Creates a function like `_.camelCase`. 5002 * 5003 * @private 5004 * @param {Function} callback The function to combine each word. 5005 * @returns {Function} Returns the new compounder function. 5006 */ 5007 function createCompounder(callback) { 5008 return function(string) { 5009 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 5010 }; 5011 } 5012 5013 /** 5014 * Creates a function that produces an instance of `Ctor` regardless of 5015 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 5016 * 5017 * @private 5018 * @param {Function} Ctor The constructor to wrap. 5019 * @returns {Function} Returns the new wrapped function. 5020 */ 5021 function createCtor(Ctor) { 5022 return function() { 5023 // Use a `switch` statement to work with class constructors. See 5024 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 5025 // for more details. 5026 var args = arguments; 5027 switch (args.length) { 5028 case 0: return new Ctor; 5029 case 1: return new Ctor(args[0]); 5030 case 2: return new Ctor(args[0], args[1]); 5031 case 3: return new Ctor(args[0], args[1], args[2]); 5032 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 5033 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 5034 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 5035 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 5036 } 5037 var thisBinding = baseCreate(Ctor.prototype), 5038 result = Ctor.apply(thisBinding, args); 5039 5040 // Mimic the constructor's `return` behavior. 5041 // See https://es5.github.io/#x13.2.2 for more details. 5042 return isObject(result) ? result : thisBinding; 5043 }; 5044 } 5045 5046 /** 5047 * Creates a function that wraps `func` to enable currying. 5048 * 5049 * @private 5050 * @param {Function} func The function to wrap. 5051 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 5052 * @param {number} arity The arity of `func`. 5053 * @returns {Function} Returns the new wrapped function. 5054 */ 5055 function createCurry(func, bitmask, arity) { 5056 var Ctor = createCtor(func); 5057 5058 function wrapper() { 5059 var length = arguments.length, 5060 args = Array(length), 5061 index = length, 5062 placeholder = getHolder(wrapper); 5063 5064 while (index--) { 5065 args[index] = arguments[index]; 5066 } 5067 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 5068 ? [] 5069 : replaceHolders(args, placeholder); 5070 5071 length -= holders.length; 5072 if (length < arity) { 5073 return createRecurry( 5074 func, bitmask, createHybrid, wrapper.placeholder, undefined, 5075 args, holders, undefined, undefined, arity - length); 5076 } 5077 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 5078 return apply(fn, this, args); 5079 } 5080 return wrapper; 5081 } 5082 5083 /** 5084 * Creates a `_.find` or `_.findLast` function. 5085 * 5086 * @private 5087 * @param {Function} findIndexFunc The function to find the collection index. 5088 * @returns {Function} Returns the new find function. 5089 */ 5090 function createFind(findIndexFunc) { 5091 return function(collection, predicate, fromIndex) { 5092 var iterable = Object(collection); 5093 if (!isArrayLike(collection)) { 5094 var iteratee = getIteratee(predicate, 3); 5095 collection = keys(collection); 5096 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 5097 } 5098 var index = findIndexFunc(collection, predicate, fromIndex); 5099 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 5100 }; 5101 } 5102 5103 /** 5104 * Creates a `_.flow` or `_.flowRight` function. 5105 * 5106 * @private 5107 * @param {boolean} [fromRight] Specify iterating from right to left. 5108 * @returns {Function} Returns the new flow function. 5109 */ 5110 function createFlow(fromRight) { 5111 return flatRest(function(funcs) { 5112 var length = funcs.length, 5113 index = length, 5114 prereq = LodashWrapper.prototype.thru; 5115 5116 if (fromRight) { 5117 funcs.reverse(); 5118 } 5119 while (index--) { 5120 var func = funcs[index]; 5121 if (typeof func != 'function') { 5122 throw new TypeError(FUNC_ERROR_TEXT); 5123 } 5124 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 5125 var wrapper = new LodashWrapper([], true); 5126 } 5127 } 5128 index = wrapper ? index : length; 5129 while (++index < length) { 5130 func = funcs[index]; 5131 5132 var funcName = getFuncName(func), 5133 data = funcName == 'wrapper' ? getData(func) : undefined; 5134 5135 if (data && isLaziable(data[0]) && 5136 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 5137 !data[4].length && data[9] == 1 5138 ) { 5139 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 5140 } else { 5141 wrapper = (func.length == 1 && isLaziable(func)) 5142 ? wrapper[funcName]() 5143 : wrapper.thru(func); 5144 } 5145 } 5146 return function() { 5147 var args = arguments, 5148 value = args[0]; 5149 5150 if (wrapper && args.length == 1 && isArray(value)) { 5151 return wrapper.plant(value).value(); 5152 } 5153 var index = 0, 5154 result = length ? funcs[index].apply(this, args) : value; 5155 5156 while (++index < length) { 5157 result = funcs[index].call(this, result); 5158 } 5159 return result; 5160 }; 5161 }); 5162 } 5163 5164 /** 5165 * Creates a function that wraps `func` to invoke it with optional `this` 5166 * binding of `thisArg`, partial application, and currying. 5167 * 5168 * @private 5169 * @param {Function|string} func The function or method name to wrap. 5170 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 5171 * @param {*} [thisArg] The `this` binding of `func`. 5172 * @param {Array} [partials] The arguments to prepend to those provided to 5173 * the new function. 5174 * @param {Array} [holders] The `partials` placeholder indexes. 5175 * @param {Array} [partialsRight] The arguments to append to those provided 5176 * to the new function. 5177 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 5178 * @param {Array} [argPos] The argument positions of the new function. 5179 * @param {number} [ary] The arity cap of `func`. 5180 * @param {number} [arity] The arity of `func`. 5181 * @returns {Function} Returns the new wrapped function. 5182 */ 5183 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 5184 var isAry = bitmask & WRAP_ARY_FLAG, 5185 isBind = bitmask & WRAP_BIND_FLAG, 5186 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 5187 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 5188 isFlip = bitmask & WRAP_FLIP_FLAG, 5189 Ctor = isBindKey ? undefined : createCtor(func); 5190 5191 function wrapper() { 5192 var length = arguments.length, 5193 args = Array(length), 5194 index = length; 5195 5196 while (index--) { 5197 args[index] = arguments[index]; 5198 } 5199 if (isCurried) { 5200 var placeholder = getHolder(wrapper), 5201 holdersCount = countHolders(args, placeholder); 5202 } 5203 if (partials) { 5204 args = composeArgs(args, partials, holders, isCurried); 5205 } 5206 if (partialsRight) { 5207 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 5208 } 5209 length -= holdersCount; 5210 if (isCurried && length < arity) { 5211 var newHolders = replaceHolders(args, placeholder); 5212 return createRecurry( 5213 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 5214 args, newHolders, argPos, ary, arity - length 5215 ); 5216 } 5217 var thisBinding = isBind ? thisArg : this, 5218 fn = isBindKey ? thisBinding[func] : func; 5219 5220 length = args.length; 5221 if (argPos) { 5222 args = reorder(args, argPos); 5223 } else if (isFlip && length > 1) { 5224 args.reverse(); 5225 } 5226 if (isAry && ary < length) { 5227 args.length = ary; 5228 } 5229 if (this && this !== root && this instanceof wrapper) { 5230 fn = Ctor || createCtor(fn); 5231 } 5232 return fn.apply(thisBinding, args); 5233 } 5234 return wrapper; 5235 } 5236 5237 /** 5238 * Creates a function like `_.invertBy`. 5239 * 5240 * @private 5241 * @param {Function} setter The function to set accumulator values. 5242 * @param {Function} toIteratee The function to resolve iteratees. 5243 * @returns {Function} Returns the new inverter function. 5244 */ 5245 function createInverter(setter, toIteratee) { 5246 return function(object, iteratee) { 5247 return baseInverter(object, setter, toIteratee(iteratee), {}); 5248 }; 5249 } 5250 5251 /** 5252 * Creates a function that performs a mathematical operation on two values. 5253 * 5254 * @private 5255 * @param {Function} operator The function to perform the operation. 5256 * @param {number} [defaultValue] The value used for `undefined` arguments. 5257 * @returns {Function} Returns the new mathematical operation function. 5258 */ 5259 function createMathOperation(operator, defaultValue) { 5260 return function(value, other) { 5261 var result; 5262 if (value === undefined && other === undefined) { 5263 return defaultValue; 5264 } 5265 if (value !== undefined) { 5266 result = value; 5267 } 5268 if (other !== undefined) { 5269 if (result === undefined) { 5270 return other; 5271 } 5272 if (typeof value == 'string' || typeof other == 'string') { 5273 value = baseToString(value); 5274 other = baseToString(other); 5275 } else { 5276 value = baseToNumber(value); 5277 other = baseToNumber(other); 5278 } 5279 result = operator(value, other); 5280 } 5281 return result; 5282 }; 5283 } 5284 5285 /** 5286 * Creates a function like `_.over`. 5287 * 5288 * @private 5289 * @param {Function} arrayFunc The function to iterate over iteratees. 5290 * @returns {Function} Returns the new over function. 5291 */ 5292 function createOver(arrayFunc) { 5293 return flatRest(function(iteratees) { 5294 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 5295 return baseRest(function(args) { 5296 var thisArg = this; 5297 return arrayFunc(iteratees, function(iteratee) { 5298 return apply(iteratee, thisArg, args); 5299 }); 5300 }); 5301 }); 5302 } 5303 5304 /** 5305 * Creates the padding for `string` based on `length`. The `chars` string 5306 * is truncated if the number of characters exceeds `length`. 5307 * 5308 * @private 5309 * @param {number} length The padding length. 5310 * @param {string} [chars=' '] The string used as padding. 5311 * @returns {string} Returns the padding for `string`. 5312 */ 5313 function createPadding(length, chars) { 5314 chars = chars === undefined ? ' ' : baseToString(chars); 5315 5316 var charsLength = chars.length; 5317 if (charsLength < 2) { 5318 return charsLength ? baseRepeat(chars, length) : chars; 5319 } 5320 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 5321 return hasUnicode(chars) 5322 ? castSlice(stringToArray(result), 0, length).join('') 5323 : result.slice(0, length); 5324 } 5325 5326 /** 5327 * Creates a function that wraps `func` to invoke it with the `this` binding 5328 * of `thisArg` and `partials` prepended to the arguments it receives. 5329 * 5330 * @private 5331 * @param {Function} func The function to wrap. 5332 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 5333 * @param {*} thisArg The `this` binding of `func`. 5334 * @param {Array} partials The arguments to prepend to those provided to 5335 * the new function. 5336 * @returns {Function} Returns the new wrapped function. 5337 */ 5338 function createPartial(func, bitmask, thisArg, partials) { 5339 var isBind = bitmask & WRAP_BIND_FLAG, 5340 Ctor = createCtor(func); 5341 5342 function wrapper() { 5343 var argsIndex = -1, 5344 argsLength = arguments.length, 5345 leftIndex = -1, 5346 leftLength = partials.length, 5347 args = Array(leftLength + argsLength), 5348 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 5349 5350 while (++leftIndex < leftLength) { 5351 args[leftIndex] = partials[leftIndex]; 5352 } 5353 while (argsLength--) { 5354 args[leftIndex++] = arguments[++argsIndex]; 5355 } 5356 return apply(fn, isBind ? thisArg : this, args); 5357 } 5358 return wrapper; 5359 } 5360 5361 /** 5362 * Creates a `_.range` or `_.rangeRight` function. 5363 * 5364 * @private 5365 * @param {boolean} [fromRight] Specify iterating from right to left. 5366 * @returns {Function} Returns the new range function. 5367 */ 5368 function createRange(fromRight) { 5369 return function(start, end, step) { 5370 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 5371 end = step = undefined; 5372 } 5373 // Ensure the sign of `-0` is preserved. 5374 start = toFinite(start); 5375 if (end === undefined) { 5376 end = start; 5377 start = 0; 5378 } else { 5379 end = toFinite(end); 5380 } 5381 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 5382 return baseRange(start, end, step, fromRight); 5383 }; 5384 } 5385 5386 /** 5387 * Creates a function that performs a relational operation on two values. 5388 * 5389 * @private 5390 * @param {Function} operator The function to perform the operation. 5391 * @returns {Function} Returns the new relational operation function. 5392 */ 5393 function createRelationalOperation(operator) { 5394 return function(value, other) { 5395 if (!(typeof value == 'string' && typeof other == 'string')) { 5396 value = toNumber(value); 5397 other = toNumber(other); 5398 } 5399 return operator(value, other); 5400 }; 5401 } 5402 5403 /** 5404 * Creates a function that wraps `func` to continue currying. 5405 * 5406 * @private 5407 * @param {Function} func The function to wrap. 5408 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 5409 * @param {Function} wrapFunc The function to create the `func` wrapper. 5410 * @param {*} placeholder The placeholder value. 5411 * @param {*} [thisArg] The `this` binding of `func`. 5412 * @param {Array} [partials] The arguments to prepend to those provided to 5413 * the new function. 5414 * @param {Array} [holders] The `partials` placeholder indexes. 5415 * @param {Array} [argPos] The argument positions of the new function. 5416 * @param {number} [ary] The arity cap of `func`. 5417 * @param {number} [arity] The arity of `func`. 5418 * @returns {Function} Returns the new wrapped function. 5419 */ 5420 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 5421 var isCurry = bitmask & WRAP_CURRY_FLAG, 5422 newHolders = isCurry ? holders : undefined, 5423 newHoldersRight = isCurry ? undefined : holders, 5424 newPartials = isCurry ? partials : undefined, 5425 newPartialsRight = isCurry ? undefined : partials; 5426 5427 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 5428 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 5429 5430 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 5431 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 5432 } 5433 var newData = [ 5434 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 5435 newHoldersRight, argPos, ary, arity 5436 ]; 5437 5438 var result = wrapFunc.apply(undefined, newData); 5439 if (isLaziable(func)) { 5440 setData(result, newData); 5441 } 5442 result.placeholder = placeholder; 5443 return setWrapToString(result, func, bitmask); 5444 } 5445 5446 /** 5447 * Creates a function like `_.round`. 5448 * 5449 * @private 5450 * @param {string} methodName The name of the `Math` method to use when rounding. 5451 * @returns {Function} Returns the new round function. 5452 */ 5453 function createRound(methodName) { 5454 var func = Math[methodName]; 5455 return function(number, precision) { 5456 number = toNumber(number); 5457 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 5458 if (precision) { 5459 // Shift with exponential notation to avoid floating-point issues. 5460 // See [MDN](https://mdn.io/round#Examples) for more details. 5461 var pair = (toString(number) + 'e').split('e'), 5462 value = func(pair[0] + 'e' + (+pair[1] + precision)); 5463 5464 pair = (toString(value) + 'e').split('e'); 5465 return +(pair[0] + 'e' + (+pair[1] - precision)); 5466 } 5467 return func(number); 5468 }; 5469 } 5470 5471 /** 5472 * Creates a set object of `values`. 5473 * 5474 * @private 5475 * @param {Array} values The values to add to the set. 5476 * @returns {Object} Returns the new set. 5477 */ 5478 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 5479 return new Set(values); 5480 }; 5481 5482 /** 5483 * Creates a `_.toPairs` or `_.toPairsIn` function. 5484 * 5485 * @private 5486 * @param {Function} keysFunc The function to get the keys of a given object. 5487 * @returns {Function} Returns the new pairs function. 5488 */ 5489 function createToPairs(keysFunc) { 5490 return function(object) { 5491 var tag = getTag(object); 5492 if (tag == mapTag) { 5493 return mapToArray(object); 5494 } 5495 if (tag == setTag) { 5496 return setToPairs(object); 5497 } 5498 return baseToPairs(object, keysFunc(object)); 5499 }; 5500 } 5501 5502 /** 5503 * Creates a function that either curries or invokes `func` with optional 5504 * `this` binding and partially applied arguments. 5505 * 5506 * @private 5507 * @param {Function|string} func The function or method name to wrap. 5508 * @param {number} bitmask The bitmask flags. 5509 * 1 - `_.bind` 5510 * 2 - `_.bindKey` 5511 * 4 - `_.curry` or `_.curryRight` of a bound function 5512 * 8 - `_.curry` 5513 * 16 - `_.curryRight` 5514 * 32 - `_.partial` 5515 * 64 - `_.partialRight` 5516 * 128 - `_.rearg` 5517 * 256 - `_.ary` 5518 * 512 - `_.flip` 5519 * @param {*} [thisArg] The `this` binding of `func`. 5520 * @param {Array} [partials] The arguments to be partially applied. 5521 * @param {Array} [holders] The `partials` placeholder indexes. 5522 * @param {Array} [argPos] The argument positions of the new function. 5523 * @param {number} [ary] The arity cap of `func`. 5524 * @param {number} [arity] The arity of `func`. 5525 * @returns {Function} Returns the new wrapped function. 5526 */ 5527 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 5528 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 5529 if (!isBindKey && typeof func != 'function') { 5530 throw new TypeError(FUNC_ERROR_TEXT); 5531 } 5532 var length = partials ? partials.length : 0; 5533 if (!length) { 5534 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 5535 partials = holders = undefined; 5536 } 5537 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 5538 arity = arity === undefined ? arity : toInteger(arity); 5539 length -= holders ? holders.length : 0; 5540 5541 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 5542 var partialsRight = partials, 5543 holdersRight = holders; 5544 5545 partials = holders = undefined; 5546 } 5547 var data = isBindKey ? undefined : getData(func); 5548 5549 var newData = [ 5550 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 5551 argPos, ary, arity 5552 ]; 5553 5554 if (data) { 5555 mergeData(newData, data); 5556 } 5557 func = newData[0]; 5558 bitmask = newData[1]; 5559 thisArg = newData[2]; 5560 partials = newData[3]; 5561 holders = newData[4]; 5562 arity = newData[9] = newData[9] === undefined 5563 ? (isBindKey ? 0 : func.length) 5564 : nativeMax(newData[9] - length, 0); 5565 5566 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 5567 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 5568 } 5569 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 5570 var result = createBind(func, bitmask, thisArg); 5571 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 5572 result = createCurry(func, bitmask, arity); 5573 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 5574 result = createPartial(func, bitmask, thisArg, partials); 5575 } else { 5576 result = createHybrid.apply(undefined, newData); 5577 } 5578 var setter = data ? baseSetData : setData; 5579 return setWrapToString(setter(result, newData), func, bitmask); 5580 } 5581 5582 /** 5583 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 5584 * of source objects to the destination object for all destination properties 5585 * that resolve to `undefined`. 5586 * 5587 * @private 5588 * @param {*} objValue The destination value. 5589 * @param {*} srcValue The source value. 5590 * @param {string} key The key of the property to assign. 5591 * @param {Object} object The parent object of `objValue`. 5592 * @returns {*} Returns the value to assign. 5593 */ 5594 function customDefaultsAssignIn(objValue, srcValue, key, object) { 5595 if (objValue === undefined || 5596 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 5597 return srcValue; 5598 } 5599 return objValue; 5600 } 5601 5602 /** 5603 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 5604 * objects into destination objects that are passed thru. 5605 * 5606 * @private 5607 * @param {*} objValue The destination value. 5608 * @param {*} srcValue The source value. 5609 * @param {string} key The key of the property to merge. 5610 * @param {Object} object The parent object of `objValue`. 5611 * @param {Object} source The parent object of `srcValue`. 5612 * @param {Object} [stack] Tracks traversed source values and their merged 5613 * counterparts. 5614 * @returns {*} Returns the value to assign. 5615 */ 5616 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 5617 if (isObject(objValue) && isObject(srcValue)) { 5618 // Recursively merge objects and arrays (susceptible to call stack limits). 5619 stack.set(srcValue, objValue); 5620 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 5621 stack['delete'](srcValue); 5622 } 5623 return objValue; 5624 } 5625 5626 /** 5627 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 5628 * objects. 5629 * 5630 * @private 5631 * @param {*} value The value to inspect. 5632 * @param {string} key The key of the property to inspect. 5633 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 5634 */ 5635 function customOmitClone(value) { 5636 return isPlainObject(value) ? undefined : value; 5637 } 5638 5639 /** 5640 * A specialized version of `baseIsEqualDeep` for arrays with support for 5641 * partial deep comparisons. 5642 * 5643 * @private 5644 * @param {Array} array The array to compare. 5645 * @param {Array} other The other array to compare. 5646 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 5647 * @param {Function} customizer The function to customize comparisons. 5648 * @param {Function} equalFunc The function to determine equivalents of values. 5649 * @param {Object} stack Tracks traversed `array` and `other` objects. 5650 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 5651 */ 5652 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 5653 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 5654 arrLength = array.length, 5655 othLength = other.length; 5656 5657 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 5658 return false;
vendor: 1,304 bytes, lines 5659-5697
5659 } 5660 // Assume cyclic values are equal. 5661 var stacked = stack.get(array); 5662 if (stacked && stack.get(other)) { 5663 return stacked == other; 5664 } 5665 var index = -1, 5666 result = true, 5667 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 5668 5669 stack.set(array, other); 5670 stack.set(other, array); 5671 5672 // Ignore non-index properties. 5673 while (++index < arrLength) { 5674 var arrValue = array[index], 5675 othValue = other[index]; 5676 5677 if (customizer) { 5678 var compared = isPartial 5679 ? customizer(othValue, arrValue, index, other, array, stack) 5680 : customizer(arrValue, othValue, index, array, other, stack); 5681 } 5682 if (compared !== undefined) { 5683 if (compared) { 5684 continue; 5685 } 5686 result = false; 5687 break; 5688 } 5689 // Recursively compare arrays (susceptible to call stack limits). 5690 if (seen) { 5691 if (!arraySome(other, function(othValue, othIndex) { 5692 if (!cacheHas(seen, othIndex) && 5693 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 5694 return seen.push(othIndex); 5695 } 5696 })) { 5697 result = false;
vendor: 4,179 bytes, lines 5698-5809
5698 break; 5699 } 5700 } else if (!( 5701 arrValue === othValue || 5702 equalFunc(arrValue, othValue, bitmask, customizer, stack) 5703 )) { 5704 result = false; 5705 break; 5706 } 5707 } 5708 stack['delete'](array); 5709 stack['delete'](other); 5710 return result; 5711 } 5712 5713 /** 5714 * A specialized version of `baseIsEqualDeep` for comparing objects of 5715 * the same `toStringTag`. 5716 * 5717 * **Note:** This function only supports comparing values with tags of 5718 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 5719 * 5720 * @private 5721 * @param {Object} object The object to compare. 5722 * @param {Object} other The other object to compare. 5723 * @param {string} tag The `toStringTag` of the objects to compare. 5724 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 5725 * @param {Function} customizer The function to customize comparisons. 5726 * @param {Function} equalFunc The function to determine equivalents of values. 5727 * @param {Object} stack Tracks traversed `object` and `other` objects. 5728 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 5729 */ 5730 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 5731 switch (tag) { 5732 case dataViewTag: 5733 if ((object.byteLength != other.byteLength) || 5734 (object.byteOffset != other.byteOffset)) { 5735 return false; 5736 } 5737 object = object.buffer; 5738 other = other.buffer; 5739 5740 case arrayBufferTag: 5741 if ((object.byteLength != other.byteLength) || 5742 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 5743 return false; 5744 } 5745 return true; 5746 5747 case boolTag: 5748 case dateTag: 5749 case numberTag: 5750 // Coerce booleans to `1` or `0` and dates to milliseconds. 5751 // Invalid dates are coerced to `NaN`. 5752 return eq(+object, +other); 5753 5754 case errorTag: 5755 return object.name == other.name && object.message == other.message; 5756 5757 case regexpTag: 5758 case stringTag: 5759 // Coerce regexes to strings and treat strings, primitives and objects, 5760 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 5761 // for more details. 5762 return object == (other + ''); 5763 5764 case mapTag: 5765 var convert = mapToArray; 5766 5767 case setTag: 5768 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 5769 convert || (convert = setToArray); 5770 5771 if (object.size != other.size && !isPartial) { 5772 return false; 5773 } 5774 // Assume cyclic values are equal. 5775 var stacked = stack.get(object); 5776 if (stacked) { 5777 return stacked == other; 5778 } 5779 bitmask |= COMPARE_UNORDERED_FLAG; 5780 5781 // Recursively compare objects (susceptible to call stack limits). 5782 stack.set(object, other); 5783 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 5784 stack['delete'](object); 5785 return result; 5786 5787 case symbolTag: 5788 if (symbolValueOf) { 5789 return symbolValueOf.call(object) == symbolValueOf.call(other); 5790 } 5791 } 5792 return false; 5793 } 5794 5795 /** 5796 * A specialized version of `baseIsEqualDeep` for objects with support for 5797 * partial deep comparisons. 5798 * 5799 * @private 5800 * @param {Object} object The object to compare. 5801 * @param {Object} other The other object to compare. 5802 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 5803 * @param {Function} customizer The function to customize comparisons. 5804 * @param {Function} equalFunc The function to determine equivalents of values. 5805 * @param {Object} stack Tracks traversed `object` and `other` objects. 5806 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 5807 */ 5808 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 5809 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
vendor: 1,367 bytes, lines 5810-5850
5810 objProps = getAllKeys(object), 5811 objLength = objProps.length, 5812 othProps = getAllKeys(other), 5813 othLength = othProps.length; 5814 5815 if (objLength != othLength && !isPartial) { 5816 return false; 5817 } 5818 var index = objLength; 5819 while (index--) { 5820 var key = objProps[index]; 5821 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 5822 return false; 5823 } 5824 } 5825 // Assume cyclic values are equal. 5826 var stacked = stack.get(object); 5827 if (stacked && stack.get(other)) { 5828 return stacked == other; 5829 } 5830 var result = true; 5831 stack.set(object, other); 5832 stack.set(other, object); 5833 5834 var skipCtor = isPartial; 5835 while (++index < objLength) { 5836 key = objProps[index]; 5837 var objValue = object[key], 5838 othValue = other[key]; 5839 5840 if (customizer) { 5841 var compared = isPartial 5842 ? customizer(othValue, objValue, key, other, object, stack) 5843 : customizer(objValue, othValue, key, object, other, stack); 5844 } 5845 // Recursively compare objects (susceptible to call stack limits). 5846 if (!(compared === undefined 5847 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 5848 : compared 5849 )) { 5850 result = false;
vendor: 8,175 bytes, lines 5851-6116
5851 break; 5852 } 5853 skipCtor || (skipCtor = key == 'constructor'); 5854 } 5855 if (result && !skipCtor) { 5856 var objCtor = object.constructor, 5857 othCtor = other.constructor; 5858 5859 // Non `Object` object instances with different constructors are not equal. 5860 if (objCtor != othCtor && 5861 ('constructor' in object && 'constructor' in other) && 5862 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 5863 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 5864 result = false; 5865 } 5866 } 5867 stack['delete'](object); 5868 stack['delete'](other); 5869 return result; 5870 } 5871 5872 /** 5873 * A specialized version of `baseRest` which flattens the rest array. 5874 * 5875 * @private 5876 * @param {Function} func The function to apply a rest parameter to. 5877 * @returns {Function} Returns the new function. 5878 */ 5879 function flatRest(func) { 5880 return setToString(overRest(func, undefined, flatten), func + ''); 5881 } 5882 5883 /** 5884 * Creates an array of own enumerable property names and symbols of `object`. 5885 * 5886 * @private 5887 * @param {Object} object The object to query. 5888 * @returns {Array} Returns the array of property names and symbols. 5889 */ 5890 function getAllKeys(object) { 5891 return baseGetAllKeys(object, keys, getSymbols); 5892 } 5893 5894 /** 5895 * Creates an array of own and inherited enumerable property names and 5896 * symbols of `object`. 5897 * 5898 * @private 5899 * @param {Object} object The object to query. 5900 * @returns {Array} Returns the array of property names and symbols. 5901 */ 5902 function getAllKeysIn(object) { 5903 return baseGetAllKeys(object, keysIn, getSymbolsIn); 5904 } 5905 5906 /** 5907 * Gets metadata for `func`. 5908 * 5909 * @private 5910 * @param {Function} func The function to query. 5911 * @returns {*} Returns the metadata for `func`. 5912 */ 5913 var getData = !metaMap ? noop : function(func) { 5914 return metaMap.get(func); 5915 }; 5916 5917 /** 5918 * Gets the name of `func`. 5919 * 5920 * @private 5921 * @param {Function} func The function to query. 5922 * @returns {string} Returns the function name. 5923 */ 5924 function getFuncName(func) { 5925 var result = (func.name + ''), 5926 array = realNames[result], 5927 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 5928 5929 while (length--) { 5930 var data = array[length], 5931 otherFunc = data.func; 5932 if (otherFunc == null || otherFunc == func) { 5933 return data.name; 5934 } 5935 } 5936 return result; 5937 } 5938 5939 /** 5940 * Gets the argument placeholder value for `func`. 5941 * 5942 * @private 5943 * @param {Function} func The function to inspect. 5944 * @returns {*} Returns the placeholder value. 5945 */ 5946 function getHolder(func) { 5947 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 5948 return object.placeholder; 5949 } 5950 5951 /** 5952 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 5953 * this function returns the custom method, otherwise it returns `baseIteratee`. 5954 * If arguments are provided, the chosen function is invoked with them and 5955 * its result is returned. 5956 * 5957 * @private 5958 * @param {*} [value] The value to convert to an iteratee. 5959 * @param {number} [arity] The arity of the created iteratee. 5960 * @returns {Function} Returns the chosen function or its result. 5961 */ 5962 function getIteratee() { 5963 var result = lodash.iteratee || iteratee; 5964 result = result === iteratee ? baseIteratee : result; 5965 return arguments.length ? result(arguments[0], arguments[1]) : result; 5966 } 5967 5968 /** 5969 * Gets the data for `map`. 5970 * 5971 * @private 5972 * @param {Object} map The map to query. 5973 * @param {string} key The reference key. 5974 * @returns {*} Returns the map data. 5975 */ 5976 function getMapData(map, key) { 5977 var data = map.__data__; 5978 return isKeyable(key) 5979 ? data[typeof key == 'string' ? 'string' : 'hash'] 5980 : data.map; 5981 } 5982 5983 /** 5984 * Gets the property names, values, and compare flags of `object`. 5985 * 5986 * @private 5987 * @param {Object} object The object to query. 5988 * @returns {Array} Returns the match data of `object`. 5989 */ 5990 function getMatchData(object) { 5991 var result = keys(object), 5992 length = result.length; 5993 5994 while (length--) { 5995 var key = result[length], 5996 value = object[key]; 5997 5998 result[length] = [key, value, isStrictComparable(value)]; 5999 } 6000 return result; 6001 } 6002 6003 /** 6004 * Gets the native function at `key` of `object`. 6005 * 6006 * @private 6007 * @param {Object} object The object to query. 6008 * @param {string} key The key of the method to get. 6009 * @returns {*} Returns the function if it's native, else `undefined`. 6010 */ 6011 function getNative(object, key) { 6012 var value = getValue(object, key); 6013 return baseIsNative(value) ? value : undefined; 6014 } 6015 6016 /** 6017 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 6018 * 6019 * @private 6020 * @param {*} value The value to query. 6021 * @returns {string} Returns the raw `toStringTag`. 6022 */ 6023 function getRawTag(value) { 6024 var isOwn = hasOwnProperty.call(value, symToStringTag), 6025 tag = value[symToStringTag]; 6026 6027 try { 6028 value[symToStringTag] = undefined; 6029 var unmasked = true; 6030 } catch (e) {} 6031 6032 var result = nativeObjectToString.call(value); 6033 if (unmasked) { 6034 if (isOwn) { 6035 value[symToStringTag] = tag; 6036 } else { 6037 delete value[symToStringTag]; 6038 } 6039 } 6040 return result; 6041 } 6042 6043 /** 6044 * Creates an array of the own enumerable symbols of `object`. 6045 * 6046 * @private 6047 * @param {Object} object The object to query. 6048 * @returns {Array} Returns the array of symbols. 6049 */ 6050 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 6051 if (object == null) { 6052 return []; 6053 } 6054 object = Object(object); 6055 return arrayFilter(nativeGetSymbols(object), function(symbol) { 6056 return propertyIsEnumerable.call(object, symbol); 6057 }); 6058 }; 6059 6060 /** 6061 * Creates an array of the own and inherited enumerable symbols of `object`. 6062 * 6063 * @private 6064 * @param {Object} object The object to query. 6065 * @returns {Array} Returns the array of symbols. 6066 */ 6067 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 6068 var result = []; 6069 while (object) { 6070 arrayPush(result, getSymbols(object)); 6071 object = getPrototype(object); 6072 } 6073 return result; 6074 }; 6075 6076 /** 6077 * Gets the `toStringTag` of `value`. 6078 * 6079 * @private 6080 * @param {*} value The value to query. 6081 * @returns {string} Returns the `toStringTag`. 6082 */ 6083 var getTag = baseGetTag; 6084 6085 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 6086 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 6087 (Map && getTag(new Map) != mapTag) || 6088 (Promise && getTag(Promise.resolve()) != promiseTag) || 6089 (Set && getTag(new Set) != setTag) || 6090 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 6091 getTag = function(value) { 6092 var result = baseGetTag(value), 6093 Ctor = result == objectTag ? value.constructor : undefined, 6094 ctorString = Ctor ? toSource(Ctor) : ''; 6095 6096 if (ctorString) { 6097 switch (ctorString) { 6098 case dataViewCtorString: return dataViewTag; 6099 case mapCtorString: return mapTag; 6100 case promiseCtorString: return promiseTag; 6101 case setCtorString: return setTag; 6102 case weakMapCtorString: return weakMapTag; 6103 } 6104 } 6105 return result; 6106 }; 6107 } 6108 6109 /** 6110 * Gets the view, applying any `transforms` to the `start` and `end` positions. 6111 * 6112 * @private 6113 * @param {number} start The start of the view. 6114 * @param {number} end The end of the view. 6115 * @param {Array} transforms The transformations to apply to the view. 6116 * @returns {Object}
vendor: 2,210 bytes, lines 6116-6189
6116 Returns an object containing the `start` and `end` 6117 * positions of the view. 6118 */ 6119 function getView(start, end, transforms) { 6120 var index = -1, 6121 length = transforms.length; 6122 6123 while (++index < length) { 6124 var data = transforms[index], 6125 size = data.size; 6126 6127 switch (data.type) { 6128 case 'drop': start += size; break; 6129 case 'dropRight': end -= size; break; 6130 case 'take': end = nativeMin(end, start + size); break; 6131 case 'takeRight': start = nativeMax(start, end - size); break; 6132 } 6133 } 6134 return { 'start': start, 'end': end }; 6135 } 6136 6137 /** 6138 * Extracts wrapper details from the `source` body comment. 6139 * 6140 * @private 6141 * @param {string} source The source to inspect. 6142 * @returns {Array} Returns the wrapper details. 6143 */ 6144 function getWrapDetails(source) { 6145 var match = source.match(reWrapDetails); 6146 return match ? match[1].split(reSplitDetails) : []; 6147 } 6148 6149 /** 6150 * Checks if `path` exists on `object`. 6151 * 6152 * @private 6153 * @param {Object} object The object to query. 6154 * @param {Array|string} path The path to check. 6155 * @param {Function} hasFunc The function to check properties. 6156 * @returns {boolean} Returns `true` if `path` exists, else `false`. 6157 */ 6158 function hasPath(object, path, hasFunc) { 6159 path = castPath(path, object); 6160 6161 var index = -1, 6162 length = path.length, 6163 result = false; 6164 6165 while (++index < length) { 6166 var key = toKey(path[index]); 6167 if (!(result = object != null && hasFunc(object, key))) { 6168 break; 6169 } 6170 object = object[key]; 6171 } 6172 if (result || ++index != length) { 6173 return result; 6174 } 6175 length = object == null ? 0 : object.length; 6176 return !!length && isLength(length) && isIndex(key, length) && 6177 (isArray(object) || isArguments(object)); 6178 } 6179 6180 /** 6181 * Initializes an array clone. 6182 * 6183 * @private 6184 * @param {Array} array The array to clone. 6185 * @returns {Array} Returns the initialized clone. 6186 */ 6187 function initCloneArray(array) { 6188 var length = array.length, 6189 result =
vendor: 3,696 bytes, lines 6189-6303
6189array.constructor(length); 6190 6191 // Add properties assigned by `RegExp#exec`. 6192 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 6193 result.index = array.index; 6194 result.input = array.input; 6195 } 6196 return result; 6197 } 6198 6199 /** 6200 * Initializes an object clone. 6201 * 6202 * @private 6203 * @param {Object} object The object to clone. 6204 * @returns {Object} Returns the initialized clone. 6205 */ 6206 function initCloneObject(object) { 6207 return (typeof object.constructor == 'function' && !isPrototype(object)) 6208 ? baseCreate(getPrototype(object)) 6209 : {}; 6210 } 6211 6212 /** 6213 * Initializes an object clone based on its `toStringTag`. 6214 * 6215 * **Note:** This function only supports cloning values with tags of 6216 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 6217 * 6218 * @private 6219 * @param {Object} object The object to clone. 6220 * @param {string} tag The `toStringTag` of the object to clone. 6221 * @param {Function} cloneFunc The function to clone values. 6222 * @param {boolean} [isDeep] Specify a deep clone. 6223 * @returns {Object} Returns the initialized clone. 6224 */ 6225 function initCloneByTag(object, tag, cloneFunc, isDeep) { 6226 var Ctor = object.constructor; 6227 switch (tag) { 6228 case arrayBufferTag: 6229 return cloneArrayBuffer(object); 6230 6231 case boolTag: 6232 case dateTag: 6233 return new Ctor(+object); 6234 6235 case dataViewTag: 6236 return cloneDataView(object, isDeep); 6237 6238 case float32Tag: case float64Tag: 6239 case int8Tag: case int16Tag: case int32Tag: 6240 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 6241 return cloneTypedArray(object, isDeep); 6242 6243 case mapTag: 6244 return cloneMap(object, isDeep, cloneFunc); 6245 6246 case numberTag: 6247 case stringTag: 6248 return new Ctor(object); 6249 6250 case regexpTag: 6251 return cloneRegExp(object); 6252 6253 case setTag: 6254 return cloneSet(object, isDeep, cloneFunc); 6255 6256 case symbolTag: 6257 return cloneSymbol(object); 6258 } 6259 } 6260 6261 /** 6262 * Inserts wrapper `details` in a comment at the top of the `source` body. 6263 * 6264 * @private 6265 * @param {string} source The source to modify. 6266 * @returns {Array} details The details to insert. 6267 * @returns {string} Returns the modified source. 6268 */ 6269 function insertWrapDetails(source, details) { 6270 var length = details.length; 6271 if (!length) { 6272 return source; 6273 } 6274 var lastIndex = length - 1; 6275 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 6276 details = details.join(length > 2 ? ', ' : ' '); 6277 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 6278 } 6279 6280 /** 6281 * Checks if `value` is a flattenable `arguments` object or array. 6282 * 6283 * @private 6284 * @param {*} value The value to check. 6285 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 6286 */ 6287 function isFlattenable(value) { 6288 return isArray(value) || isArguments(value) || 6289 !!(spreadableSymbol && value && value[spreadableSymbol]); 6290 } 6291 6292 /** 6293 * Checks if `value` is a valid array-like index. 6294 * 6295 * @private 6296 * @param {*} value The value to check. 6297 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 6298 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 6299 */ 6300 function isIndex(value, length) { 6301 length = length == null ? MAX_SAFE_INTEGER : length; 6302 return !!length && 6303 (typeof value == 'number' || reIsUint.test(value)) &&
vendor: 10,952 bytes, lines 6304-6639
6304 (value > -1 && value % 1 == 0 && value < length); 6305 } 6306 6307 /** 6308 * Checks if the given arguments are from an iteratee call. 6309 * 6310 * @private 6311 * @param {*} value The potential iteratee value argument. 6312 * @param {*} index The potential iteratee index or key argument. 6313 * @param {*} object The potential iteratee object argument. 6314 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 6315 * else `false`. 6316 */ 6317 function isIterateeCall(value, index, object) { 6318 if (!isObject(object)) { 6319 return false; 6320 } 6321 var type = typeof index; 6322 if (type == 'number' 6323 ? (isArrayLike(object) && isIndex(index, object.length)) 6324 : (type == 'string' && index in object) 6325 ) { 6326 return eq(object[index], value); 6327 } 6328 return false; 6329 } 6330 6331 /** 6332 * Checks if `value` is a property name and not a property path. 6333 * 6334 * @private 6335 * @param {*} value The value to check. 6336 * @param {Object} [object] The object to query keys on. 6337 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 6338 */ 6339 function isKey(value, object) { 6340 if (isArray(value)) { 6341 return false; 6342 } 6343 var type = typeof value; 6344 if (type == 'number' || type == 'symbol' || type == 'boolean' || 6345 value == null || isSymbol(value)) { 6346 return true; 6347 } 6348 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 6349 (object != null && value in Object(object)); 6350 } 6351 6352 /** 6353 * Checks if `value` is suitable for use as unique object key. 6354 * 6355 * @private 6356 * @param {*} value The value to check. 6357 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 6358 */ 6359 function isKeyable(value) { 6360 var type = typeof value; 6361 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 6362 ? (value !== '__proto__') 6363 : (value === null); 6364 } 6365 6366 /** 6367 * Checks if `func` has a lazy counterpart. 6368 * 6369 * @private 6370 * @param {Function} func The function to check. 6371 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 6372 * else `false`. 6373 */ 6374 function isLaziable(func) { 6375 var funcName = getFuncName(func), 6376 other = lodash[funcName]; 6377 6378 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 6379 return false; 6380 } 6381 if (func === other) { 6382 return true; 6383 } 6384 var data = getData(other); 6385 return !!data && func === data[0]; 6386 } 6387 6388 /** 6389 * Checks if `func` has its source masked. 6390 * 6391 * @private 6392 * @param {Function} func The function to check. 6393 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 6394 */ 6395 function isMasked(func) { 6396 return !!maskSrcKey && (maskSrcKey in func); 6397 } 6398 6399 /** 6400 * Checks if `func` is capable of being masked. 6401 * 6402 * @private 6403 * @param {*} value The value to check. 6404 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 6405 */ 6406 var isMaskable = coreJsData ? isFunction : stubFalse; 6407 6408 /** 6409 * Checks if `value` is likely a prototype object. 6410 * 6411 * @private 6412 * @param {*} value The value to check. 6413 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 6414 */ 6415 function isPrototype(value) { 6416 var Ctor = value && value.constructor, 6417 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 6418 6419 return value === proto; 6420 } 6421 6422 /** 6423 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 6424 * 6425 * @private 6426 * @param {*} value The value to check. 6427 * @returns {boolean} Returns `true` if `value` if suitable for strict 6428 * equality comparisons, else `false`. 6429 */ 6430 function isStrictComparable(value) { 6431 return value === value && !isObject(value); 6432 } 6433 6434 /** 6435 * A specialized version of `matchesProperty` for source values suitable 6436 * for strict equality comparisons, i.e. `===`. 6437 * 6438 * @private 6439 * @param {string} key The key of the property to get. 6440 * @param {*} srcValue The value to match. 6441 * @returns {Function} Returns the new spec function. 6442 */ 6443 function matchesStrictComparable(key, srcValue) { 6444 return function(object) { 6445 if (object == null) { 6446 return false; 6447 } 6448 return object[key] === srcValue && 6449 (srcValue !== undefined || (key in Object(object))); 6450 }; 6451 } 6452 6453 /** 6454 * A specialized version of `_.memoize` which clears the memoized function's 6455 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 6456 * 6457 * @private 6458 * @param {Function} func The function to have its output memoized. 6459 * @returns {Function} Returns the new memoized function. 6460 */ 6461 function memoizeCapped(func) { 6462 var result = memoize(func, function(key) { 6463 if (cache.size === MAX_MEMOIZE_SIZE) { 6464 cache.clear(); 6465 } 6466 return key; 6467 }); 6468 6469 var cache = result.cache; 6470 return result; 6471 } 6472 6473 /** 6474 * Merges the function metadata of `source` into `data`. 6475 * 6476 * Merging metadata reduces the number of wrappers used to invoke a function. 6477 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 6478 * may be applied regardless of execution order. Methods like `_.ary` and 6479 * `_.rearg` modify function arguments, making the order in which they are 6480 * executed important, preventing the merging of metadata. However, we make 6481 * an exception for a safe combined case where curried functions have `_.ary` 6482 * and or `_.rearg` applied. 6483 * 6484 * @private 6485 * @param {Array} data The destination metadata. 6486 * @param {Array} source The source metadata. 6487 * @returns {Array} Returns `data`. 6488 */ 6489 function mergeData(data, source) { 6490 var bitmask = data[1], 6491 srcBitmask = source[1], 6492 newBitmask = bitmask | srcBitmask, 6493 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 6494 6495 var isCombo = 6496 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 6497 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 6498 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 6499 6500 // Exit early if metadata can't be merged. 6501 if (!(isCommon || isCombo)) { 6502 return data; 6503 } 6504 // Use source `thisArg` if available. 6505 if (srcBitmask & WRAP_BIND_FLAG) { 6506 data[2] = source[2]; 6507 // Set when currying a bound function. 6508 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 6509 } 6510 // Compose partial arguments. 6511 var value = source[3]; 6512 if (value) { 6513 var partials = data[3]; 6514 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 6515 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 6516 } 6517 // Compose partial right arguments. 6518 value = source[5]; 6519 if (value) { 6520 partials = data[5]; 6521 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 6522 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 6523 } 6524 // Use source `argPos` if available. 6525 value = source[7]; 6526 if (value) { 6527 data[7] = value; 6528 } 6529 // Use source `ary` if it's smaller. 6530 if (srcBitmask & WRAP_ARY_FLAG) { 6531 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 6532 } 6533 // Use source `arity` if one is not provided. 6534 if (data[9] == null) { 6535 data[9] = source[9]; 6536 } 6537 // Use source `func` and merge bitmasks. 6538 data[0] = source[0]; 6539 data[1] = newBitmask; 6540 6541 return data; 6542 } 6543 6544 /** 6545 * This function is like 6546 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 6547 * except that it includes inherited enumerable properties. 6548 * 6549 * @private 6550 * @param {Object} object The object to query. 6551 * @returns {Array} Returns the array of property names. 6552 */ 6553 function nativeKeysIn(object) { 6554 var result = []; 6555 if (object != null) { 6556 for (var key in Object(object)) { 6557 result.push(key); 6558 } 6559 } 6560 return result; 6561 } 6562 6563 /** 6564 * Converts `value` to a string using `Object.prototype.toString`. 6565 * 6566 * @private 6567 * @param {*} value The value to convert. 6568 * @returns {string} Returns the converted string. 6569 */ 6570 function objectToString(value) { 6571 return nativeObjectToString.call(value); 6572 } 6573 6574 /** 6575 * A specialized version of `baseRest` which transforms the rest array. 6576 * 6577 * @private 6578 * @param {Function} func The function to apply a rest parameter to. 6579 * @param {number} [start=func.length-1] The start position of the rest parameter. 6580 * @param {Function} transform The rest array transform. 6581 * @returns {Function} Returns the new function. 6582 */ 6583 function overRest(func, start, transform) { 6584 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 6585 return function() { 6586 var args = arguments, 6587 index = -1, 6588 length = nativeMax(args.length - start, 0), 6589 array = Array(length); 6590 6591 while (++index < length) { 6592 array[index] = args[start + index]; 6593 } 6594 index = -1; 6595 var otherArgs = Array(start + 1); 6596 while (++index < start) { 6597 otherArgs[index] = args[index]; 6598 } 6599 otherArgs[start] = transform(array); 6600 return apply(func, this, otherArgs); 6601 }; 6602 } 6603 6604 /** 6605 * Gets the parent value at `path` of `object`. 6606 * 6607 * @private 6608 * @param {Object} object The object to query. 6609 * @param {Array} path The path to get the parent value of. 6610 * @returns {*} Returns the parent value. 6611 */ 6612 function parent(object, path) { 6613 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 6614 } 6615 6616 /** 6617 * Reorder `array` according to the specified indexes where the element at 6618 * the first index is assigned as the first element, the element at 6619 * the second index is assigned as the second element, and so on. 6620 * 6621 * @private 6622 * @param {Array} array The array to reorder. 6623 * @param {Array} indexes The arranged array indexes. 6624 * @returns {Array} Returns `array`. 6625 */ 6626 function reorder(array, indexes) { 6627 var arrLength = array.length, 6628 length = nativeMin(indexes.length, arrLength), 6629 oldArray = copyArray(array); 6630 6631 while (length--) { 6632 var index = indexes[length]; 6633 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 6634 } 6635 return array; 6636 } 6637 6638 /** 6639 *
6639Sets metadata for `func`. 6640 * 6641 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 6642 * period of time, it will trip its breaker and transition to an identity 6643 * function to avoid garbage collection pauses in V8. See 6644 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 6645 * for more details. 6646 * 6647 * @private 6648 * @param {Function} func The function to associate metadata with. 6649 * @param {*} data The metadata. 6650 * @returns {Function} Returns `func`. 6651 */ 6652 var setData = shortOut(baseSetData); 6653 6654 /** 6655 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 6656 * 6657 * @private 6658 * @param {Function} func The function to delay. 6659 * @param {number} wait The number of milliseconds to delay invocation. 6660 * @returns {number|Object} Returns the timer id or timeout object. 6661 */ 6662 var setTimeout = ctxSetTimeout || function(func, wait) { 6663 return root.setTimeout(func, wait); 6664 }; 6665 6666 /** 6667 * Sets the `toString` method of `func` to return `string`. 6668 * 6669 * @private 6670 * @param {Function} func The function to modify. 6671 * @param {Function} string The `toString` result. 6672 * @returns {Function} Returns `func`. 6673 */ 6674 var setToString = shortOut(baseSetToString); 6675 6676 /** 6677 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 6678 * with wrapper details in a comment at the top of the source body. 6679 * 6680 * @private 6681 * @param {Function} wrapper The function to modify. 6682 * @param {Function} reference The reference function. 6683 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6684 * @returns {Function} Returns `wrapper`. 6685 */ 6686 function setWrapToString(wrapper, reference, bitmask) { 6687 var source = (reference + ''); 6688 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 6689 } 6690 6691 /** 6692 * Creates a function that'll short out and invoke `identity` instead 6693 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 6694 * milliseconds. 6695 * 6696 * @private 6697 * @param {Function} func The function to restrict. 6698 * @returns {Function} Returns the new shortable function. 6699 */ 6700 function shortOut(func) { 6701 var count = 0, 6702 lastCalled = 0; 6703 6704 return function() { 6705 var stamp = nativeNow(), 6706 remaining = HOT_SPAN - (stamp - lastCalled); 6707 6708 lastCalled = stamp; 6709 if (remaining > 0) { 6710 if (++count >= HOT_COUNT) { 6711 return arguments[0]; 6712 } 6713 } else { 6714 count = 0; 6715 } 6716 return func.apply(undefined, arguments); 6717 }; 6718 } 6719 6720 /** 6721 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 6722 * 6723 * @private 6724 * @param {Array} array The array to shuffle. 6725 * @param {number} [size=array.length] The size of `array`. 6726 * @returns {Array} Returns `array`. 6727 */ 6728 function shuffleSelf(array, size) { 6729 var index = -1, 6730 length = array.length, 6731 lastIndex = length - 1; 6732 6733 size = size === undefined ? length : size; 6734 while (++index < size) { 6735 var rand = baseRandom(index, lastIndex), 6736 value = array[rand]; 6737 6738 array[rand] = array[index]; 6739 array[index] = value; 6740 } 6741 array.length = size; 6742 return array; 6743 } 6744 6745 /** 6746 * Converts `string` to a property path array. 6747 * 6748 * @private 6749 * @param {string} string The string to convert. 6750 * @returns {Array} Returns the property path array. 6751 */ 6752 var stringToPath = memoizeCapped(function(string) { 6753 var result = []; 6754 if (reLeadingDot.test(string)) { 6755 result.push(''); 6756 }
6757 string.replace(rePropName, function(match, number, quote, string) { 6758 result.push(quote ? s
vendor: 70,687 bytes, lines 6758-9072
6758tring.replace(reEscapeChar, '$1') : (number || match)); 6759 }); 6760 return result; 6761 }); 6762 6763 /** 6764 * Converts `value` to a string key if it's not a string or symbol. 6765 * 6766 * @private 6767 * @param {*} value The value to inspect. 6768 * @returns {string|symbol} Returns the key. 6769 */ 6770 function toKey(value) { 6771 if (typeof value == 'string' || isSymbol(value)) { 6772 return value; 6773 } 6774 var result = (value + ''); 6775 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 6776 } 6777 6778 /** 6779 * Converts `func` to its source code. 6780 * 6781 * @private 6782 * @param {Function} func The function to convert. 6783 * @returns {string} Returns the source code. 6784 */ 6785 function toSource(func) { 6786 if (func != null) { 6787 try { 6788 return funcToString.call(func); 6789 } catch (e) {} 6790 try { 6791 return (func + ''); 6792 } catch (e) {} 6793 } 6794 return ''; 6795 } 6796 6797 /** 6798 * Updates wrapper `details` based on `bitmask` flags. 6799 * 6800 * @private 6801 * @returns {Array} details The details to modify. 6802 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6803 * @returns {Array} Returns `details`. 6804 */ 6805 function updateWrapDetails(details, bitmask) { 6806 arrayEach(wrapFlags, function(pair) { 6807 var value = '_.' + pair[0]; 6808 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 6809 details.push(value); 6810 } 6811 }); 6812 return details.sort(); 6813 } 6814 6815 /** 6816 * Creates a clone of `wrapper`. 6817 * 6818 * @private 6819 * @param {Object} wrapper The wrapper to clone. 6820 * @returns {Object} Returns the cloned wrapper. 6821 */ 6822 function wrapperClone(wrapper) { 6823 if (wrapper instanceof LazyWrapper) { 6824 return wrapper.clone(); 6825 } 6826 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 6827 result.__actions__ = copyArray(wrapper.__actions__); 6828 result.__index__ = wrapper.__index__; 6829 result.__values__ = wrapper.__values__; 6830 return result; 6831 } 6832 6833 /*------------------------------------------------------------------------*/ 6834 6835 /** 6836 * Creates an array of elements split into groups the length of `size`. 6837 * If `array` can't be split evenly, the final chunk will be the remaining 6838 * elements. 6839 * 6840 * @static 6841 * @memberOf _ 6842 * @since 3.0.0 6843 * @category Array 6844 * @param {Array} array The array to process. 6845 * @param {number} [size=1] The length of each chunk 6846 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 6847 * @returns {Array} Returns the new array of chunks. 6848 * @example 6849 * 6850 * _.chunk(['a', 'b', 'c', 'd'], 2); 6851 * // => [['a', 'b'], ['c', 'd']] 6852 * 6853 * _.chunk(['a', 'b', 'c', 'd'], 3); 6854 * // => [['a', 'b', 'c'], ['d']] 6855 */ 6856 function chunk(array, size, guard) { 6857 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 6858 size = 1; 6859 } else { 6860 size = nativeMax(toInteger(size), 0); 6861 } 6862 var length = array == null ? 0 : array.length; 6863 if (!length || size < 1) { 6864 return []; 6865 } 6866 var index = 0, 6867 resIndex = 0, 6868 result = Array(nativeCeil(length / size)); 6869 6870 while (index < length) { 6871 result[resIndex++] = baseSlice(array, index, (index += size)); 6872 } 6873 return result; 6874 } 6875 6876 /** 6877 * Creates an array with all falsey values removed. The values `false`, `null`, 6878 * `0`, `""`, `undefined`, and `NaN` are falsey. 6879 * 6880 * @static 6881 * @memberOf _ 6882 * @since 0.1.0 6883 * @category Array 6884 * @param {Array} array The array to compact. 6885 * @returns {Array} Returns the new array of filtered values. 6886 * @example 6887 * 6888 * _.compact([0, 1, false, 2, '', 3]); 6889 * // => [1, 2, 3] 6890 */ 6891 function compact(array) { 6892 var index = -1, 6893 length = array == null ? 0 : array.length, 6894 resIndex = 0, 6895 result = []; 6896 6897 while (++index < length) { 6898 var value = array[index]; 6899 if (value) { 6900 result[resIndex++] = value; 6901 } 6902 } 6903 return result; 6904 } 6905 6906 /** 6907 * Creates a new array concatenating `array` with any additional arrays 6908 * and/or values. 6909 * 6910 * @static 6911 * @memberOf _ 6912 * @since 4.0.0 6913 * @category Array 6914 * @param {Array} array The array to concatenate. 6915 * @param {...*} [values] The values to concatenate. 6916 * @returns {Array} Returns the new concatenated array. 6917 * @example 6918 * 6919 * var array = [1]; 6920 * var other = _.concat(array, 2, [3], [[4]]); 6921 * 6922 * console.log(other); 6923 * // => [1, 2, 3, [4]] 6924 * 6925 * console.log(array); 6926 * // => [1] 6927 */ 6928 function concat() { 6929 var length = arguments.length; 6930 if (!length) { 6931 return []; 6932 } 6933 var args = Array(length - 1), 6934 array = arguments[0], 6935 index = length; 6936 6937 while (index--) { 6938 args[index - 1] = arguments[index]; 6939 } 6940 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 6941 } 6942 6943 /** 6944 * Creates an array of `array` values not included in the other given arrays 6945 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 6946 * for equality comparisons. The order and references of result values are 6947 * determined by the first array. 6948 * 6949 * **Note:** Unlike `_.pullAll`, this method returns a new array. 6950 * 6951 * @static 6952 * @memberOf _ 6953 * @since 0.1.0 6954 * @category Array 6955 * @param {Array} array The array to inspect. 6956 * @param {...Array} [values] The values to exclude. 6957 * @returns {Array} Returns the new array of filtered values. 6958 * @see _.without, _.xor 6959 * @example 6960 * 6961 * _.difference([2, 1], [2, 3]); 6962 * // => [1] 6963 */ 6964 var difference = baseRest(function(array, values) { 6965 return isArrayLikeObject(array) 6966 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 6967 : []; 6968 }); 6969 6970 /** 6971 * This method is like `_.difference` except that it accepts `iteratee` which 6972 * is invoked for each element of `array` and `values` to generate the criterion 6973 * by which they're compared. The order and references of result values are 6974 * determined by the first array. The iteratee is invoked with one argument: 6975 * (value). 6976 * 6977 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 6978 * 6979 * @static 6980 * @memberOf _ 6981 * @since 4.0.0 6982 * @category Array 6983 * @param {Array} array The array to inspect. 6984 * @param {...Array} [values] The values to exclude. 6985 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 6986 * @returns {Array} Returns the new array of filtered values. 6987 * @example 6988 * 6989 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 6990 * // => [1.2] 6991 * 6992 * // The `_.property` iteratee shorthand. 6993 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 6994 * // => [{ 'x': 2 }] 6995 */ 6996 var differenceBy = baseRest(function(array, values) { 6997 var iteratee = last(values); 6998 if (isArrayLikeObject(iteratee)) { 6999 iteratee = undefined; 7000 } 7001 return isArrayLikeObject(array) 7002 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 7003 : []; 7004 }); 7005 7006 /** 7007 * This method is like `_.difference` except that it accepts `comparator` 7008 * which is invoked to compare elements of `array` to `values`. The order and 7009 * references of result values are determined by the first array. The comparator 7010 * is invoked with two arguments: (arrVal, othVal). 7011 * 7012 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 7013 * 7014 * @static 7015 * @memberOf _ 7016 * @since 4.0.0 7017 * @category Array 7018 * @param {Array} array The array to inspect. 7019 * @param {...Array} [values] The values to exclude. 7020 * @param {Function} [comparator] The comparator invoked per element. 7021 * @returns {Array} Returns the new array of filtered values. 7022 * @example 7023 * 7024 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 7025 * 7026 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 7027 * // => [{ 'x': 2, 'y': 1 }] 7028 */ 7029 var differenceWith = baseRest(function(array, values) { 7030 var comparator = last(values); 7031 if (isArrayLikeObject(comparator)) { 7032 comparator = undefined; 7033 } 7034 return isArrayLikeObject(array) 7035 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 7036 : []; 7037 }); 7038 7039 /** 7040 * Creates a slice of `array` with `n` elements dropped from the beginning. 7041 * 7042 * @static 7043 * @memberOf _ 7044 * @since 0.5.0 7045 * @category Array 7046 * @param {Array} array The array to query. 7047 * @param {number} [n=1] The number of elements to drop. 7048 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 7049 * @returns {Array} Returns the slice of `array`. 7050 * @example 7051 * 7052 * _.drop([1, 2, 3]); 7053 * // => [2, 3] 7054 * 7055 * _.drop([1, 2, 3], 2); 7056 * // => [3] 7057 * 7058 * _.drop([1, 2, 3], 5); 7059 * // => [] 7060 * 7061 * _.drop([1, 2, 3], 0); 7062 * // => [1, 2, 3] 7063 */ 7064 function drop(array, n, guard) { 7065 var length = array == null ? 0 : array.length; 7066 if (!length) { 7067 return []; 7068 } 7069 n = (guard || n === undefined) ? 1 : toInteger(n); 7070 return baseSlice(array, n < 0 ? 0 : n, length); 7071 } 7072 7073 /** 7074 * Creates a slice of `array` with `n` elements dropped from the end. 7075 * 7076 * @static 7077 * @memberOf _ 7078 * @since 3.0.0 7079 * @category Array 7080 * @param {Array} array The array to query. 7081 * @param {number} [n=1] The number of elements to drop. 7082 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 7083 * @returns {Array} Returns the slice of `array`. 7084 * @example 7085 * 7086 * _.dropRight([1, 2, 3]); 7087 * // => [1, 2] 7088 * 7089 * _.dropRight([1, 2, 3], 2); 7090 * // => [1] 7091 * 7092 * _.dropRight([1, 2, 3], 5); 7093 * // => [] 7094 * 7095 * _.dropRight([1, 2, 3], 0); 7096 * // => [1, 2, 3] 7097 */ 7098 function dropRight(array, n, guard) { 7099 var length = array == null ? 0 : array.length; 7100 if (!length) { 7101 return []; 7102 } 7103 n = (guard || n === undefined) ? 1 : toInteger(n); 7104 n = length - n; 7105 return baseSlice(array, 0, n < 0 ? 0 : n); 7106 } 7107 7108 /** 7109 * Creates a slice of `array` excluding elements dropped from the end. 7110 * Elements are dropped until `predicate` returns falsey. The predicate is 7111 * invoked with three arguments: (value, index, array). 7112 * 7113 * @static 7114 * @memberOf _ 7115 * @since 3.0.0 7116 * @category Array 7117 * @param {Array} array The array to query. 7118 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7119 * @returns {Array} Returns the slice of `array`. 7120 * @example 7121 * 7122 * var users = [ 7123 * { 'user': 'barney', 'active': true }, 7124 * { 'user': 'fred', 'active': false }, 7125 * { 'user': 'pebbles', 'active': false } 7126 * ]; 7127 * 7128 * _.dropRightWhile(users, function(o) { return !o.active; }); 7129 * // => objects for ['barney'] 7130 * 7131 * // The `_.matches` iteratee shorthand. 7132 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 7133 * // => objects for ['barney', 'fred'] 7134 * 7135 * // The `_.matchesProperty` iteratee shorthand. 7136 * _.dropRightWhile(users, ['active', false]); 7137 * // => objects for ['barney'] 7138 * 7139 * // The `_.property` iteratee shorthand. 7140 * _.dropRightWhile(users, 'active'); 7141 * // => objects for ['barney', 'fred', 'pebbles'] 7142 */ 7143 function dropRightWhile(array, predicate) { 7144 return (array && array.length) 7145 ? baseWhile(array, getIteratee(predicate, 3), true, true) 7146 : []; 7147 } 7148 7149 /** 7150 * Creates a slice of `array` excluding elements dropped from the beginning. 7151 * Elements are dropped until `predicate` returns falsey. The predicate is 7152 * invoked with three arguments: (value, index, array). 7153 * 7154 * @static 7155 * @memberOf _ 7156 * @since 3.0.0 7157 * @category Array 7158 * @param {Array} array The array to query. 7159 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7160 * @returns {Array} Returns the slice of `array`. 7161 * @example 7162 * 7163 * var users = [ 7164 * { 'user': 'barney', 'active': false }, 7165 * { 'user': 'fred', 'active': false }, 7166 * { 'user': 'pebbles', 'active': true } 7167 * ]; 7168 * 7169 * _.dropWhile(users, function(o) { return !o.active; }); 7170 * // => objects for ['pebbles'] 7171 * 7172 * // The `_.matches` iteratee shorthand. 7173 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 7174 * // => objects for ['fred', 'pebbles'] 7175 * 7176 * // The `_.matchesProperty` iteratee shorthand. 7177 * _.dropWhile(users, ['active', false]); 7178 * // => objects for ['pebbles'] 7179 * 7180 * // The `_.property` iteratee shorthand. 7181 * _.dropWhile(users, 'active'); 7182 * // => objects for ['barney', 'fred', 'pebbles'] 7183 */ 7184 function dropWhile(array, predicate) { 7185 return (array && array.length) 7186 ? baseWhile(array, getIteratee(predicate, 3), true) 7187 : []; 7188 } 7189 7190 /** 7191 * Fills elements of `array` with `value` from `start` up to, but not 7192 * including, `end`. 7193 * 7194 * **Note:** This method mutates `array`. 7195 * 7196 * @static 7197 * @memberOf _ 7198 * @since 3.2.0 7199 * @category Array 7200 * @param {Array} array The array to fill. 7201 * @param {*} value The value to fill `array` with. 7202 * @param {number} [start=0] The start position. 7203 * @param {number} [end=array.length] The end position. 7204 * @returns {Array} Returns `array`. 7205 * @example 7206 * 7207 * var array = [1, 2, 3]; 7208 * 7209 * _.fill(array, 'a'); 7210 * console.log(array); 7211 * // => ['a', 'a', 'a'] 7212 * 7213 * _.fill(Array(3), 2); 7214 * // => [2, 2, 2] 7215 * 7216 * _.fill([4, 6, 8, 10], '*', 1, 3); 7217 * // => [4, '*', '*', 10] 7218 */ 7219 function fill(array, value, start, end) { 7220 var length = array == null ? 0 : array.length; 7221 if (!length) { 7222 return []; 7223 } 7224 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 7225 start = 0; 7226 end = length; 7227 } 7228 return baseFill(array, value, start, end); 7229 } 7230 7231 /** 7232 * This method is like `_.find` except that it returns the index of the first 7233 * element `predicate` returns truthy for instead of the element itself. 7234 * 7235 * @static 7236 * @memberOf _ 7237 * @since 1.1.0 7238 * @category Array 7239 * @param {Array} array The array to inspect. 7240 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7241 * @param {number} [fromIndex=0] The index to search from. 7242 * @returns {number} Returns the index of the found element, else `-1`. 7243 * @example 7244 * 7245 * var users = [ 7246 * { 'user': 'barney', 'active': false }, 7247 * { 'user': 'fred', 'active': false }, 7248 * { 'user': 'pebbles', 'active': true } 7249 * ]; 7250 * 7251 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 7252 * // => 0 7253 * 7254 * // The `_.matches` iteratee shorthand. 7255 * _.findIndex(users, { 'user': 'fred', 'active': false }); 7256 * // => 1 7257 * 7258 * // The `_.matchesProperty` iteratee shorthand. 7259 * _.findIndex(users, ['active', false]); 7260 * // => 0 7261 * 7262 * // The `_.property` iteratee shorthand. 7263 * _.findIndex(users, 'active'); 7264 * // => 2 7265 */ 7266 function findIndex(array, predicate, fromIndex) { 7267 var length = array == null ? 0 : array.length; 7268 if (!length) { 7269 return -1; 7270 } 7271 var index = fromIndex == null ? 0 : toInteger(fromIndex); 7272 if (index < 0) { 7273 index = nativeMax(length + index, 0); 7274 } 7275 return baseFindIndex(array, getIteratee(predicate, 3), index); 7276 } 7277 7278 /** 7279 * This method is like `_.findIndex` except that it iterates over elements 7280 * of `collection` from right to left. 7281 * 7282 * @static 7283 * @memberOf _ 7284 * @since 2.0.0 7285 * @category Array 7286 * @param {Array} array The array to inspect. 7287 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7288 * @param {number} [fromIndex=array.length-1] The index to search from. 7289 * @returns {number} Returns the index of the found element, else `-1`. 7290 * @example 7291 * 7292 * var users = [ 7293 * { 'user': 'barney', 'active': true }, 7294 * { 'user': 'fred', 'active': false }, 7295 * { 'user': 'pebbles', 'active': false } 7296 * ]; 7297 * 7298 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 7299 * // => 2 7300 * 7301 * // The `_.matches` iteratee shorthand. 7302 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 7303 * // => 0 7304 * 7305 * // The `_.matchesProperty` iteratee shorthand. 7306 * _.findLastIndex(users, ['active', false]); 7307 * // => 2 7308 * 7309 * // The `_.property` iteratee shorthand. 7310 * _.findLastIndex(users, 'active'); 7311 * // => 0 7312 */ 7313 function findLastIndex(array, predicate, fromIndex) { 7314 var length = array == null ? 0 : array.length; 7315 if (!length) { 7316 return -1; 7317 } 7318 var index = length - 1; 7319 if (fromIndex !== undefined) { 7320 index = toInteger(fromIndex); 7321 index = fromIndex < 0 7322 ? nativeMax(length + index, 0) 7323 : nativeMin(index, length - 1); 7324 } 7325 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 7326 } 7327 7328 /** 7329 * Flattens `array` a single level deep. 7330 * 7331 * @static 7332 * @memberOf _ 7333 * @since 0.1.0 7334 * @category Array 7335 * @param {Array} array The array to flatten. 7336 * @returns {Array} Returns the new flattened array. 7337 * @example 7338 * 7339 * _.flatten([1, [2, [3, [4]], 5]]); 7340 * // => [1, 2, [3, [4]], 5] 7341 */ 7342 function flatten(array) { 7343 var length = array == null ? 0 : array.length; 7344 return length ? baseFlatten(array, 1) : []; 7345 } 7346 7347 /** 7348 * Recursively flattens `array`. 7349 * 7350 * @static 7351 * @memberOf _ 7352 * @since 3.0.0 7353 * @category Array 7354 * @param {Array} array The array to flatten. 7355 * @returns {Array} Returns the new flattened array. 7356 * @example 7357 * 7358 * _.flattenDeep([1, [2, [3, [4]], 5]]); 7359 * // => [1, 2, 3, 4, 5] 7360 */ 7361 function flattenDeep(array) { 7362 var length = array == null ? 0 : array.length; 7363 return length ? baseFlatten(array, INFINITY) : []; 7364 } 7365 7366 /** 7367 * Recursively flatten `array` up to `depth` times. 7368 * 7369 * @static 7370 * @memberOf _ 7371 * @since 4.4.0 7372 * @category Array 7373 * @param {Array} array The array to flatten. 7374 * @param {number} [depth=1] The maximum recursion depth. 7375 * @returns {Array} Returns the new flattened array. 7376 * @example 7377 * 7378 * var array = [1, [2, [3, [4]], 5]]; 7379 * 7380 * _.flattenDepth(array, 1); 7381 * // => [1, 2, [3, [4]], 5] 7382 * 7383 * _.flattenDepth(array, 2); 7384 * // => [1, 2, 3, [4], 5] 7385 */ 7386 function flattenDepth(array, depth) { 7387 var length = array == null ? 0 : array.length; 7388 if (!length) { 7389 return []; 7390 } 7391 depth = depth === undefined ? 1 : toInteger(depth); 7392 return baseFlatten(array, depth); 7393 } 7394 7395 /** 7396 * The inverse of `_.toPairs`; this method returns an object composed 7397 * from key-value `pairs`. 7398 * 7399 * @static 7400 * @memberOf _ 7401 * @since 4.0.0 7402 * @category Array 7403 * @param {Array} pairs The key-value pairs. 7404 * @returns {Object} Returns the new object. 7405 * @example 7406 * 7407 * _.fromPairs([['a', 1], ['b', 2]]); 7408 * // => { 'a': 1, 'b': 2 } 7409 */ 7410 function fromPairs(pairs) { 7411 var index = -1, 7412 length = pairs == null ? 0 : pairs.length, 7413 result = {}; 7414 7415 while (++index < length) { 7416 var pair = pairs[index]; 7417 result[pair[0]] = pair[1]; 7418 } 7419 return result; 7420 } 7421 7422 /** 7423 * Gets the first element of `array`. 7424 * 7425 * @static 7426 * @memberOf _ 7427 * @since 0.1.0 7428 * @alias first 7429 * @category Array 7430 * @param {Array} array The array to query. 7431 * @returns {*} Returns the first element of `array`. 7432 * @example 7433 * 7434 * _.head([1, 2, 3]); 7435 * // => 1 7436 * 7437 * _.head([]); 7438 * // => undefined 7439 */ 7440 function head(array) { 7441 return (array && array.length) ? array[0] : undefined; 7442 } 7443 7444 /** 7445 * Gets the index at which the first occurrence of `value` is found in `array` 7446 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 7447 * for equality comparisons. If `fromIndex` is negative, it's used as the 7448 * offset from the end of `array`. 7449 * 7450 * @static 7451 * @memberOf _ 7452 * @since 0.1.0 7453 * @category Array 7454 * @param {Array} array The array to inspect. 7455 * @param {*} value The value to search for. 7456 * @param {number} [fromIndex=0] The index to search from. 7457 * @returns {number} Returns the index of the matched value, else `-1`. 7458 * @example 7459 * 7460 * _.indexOf([1, 2, 1, 2], 2); 7461 * // => 1 7462 * 7463 * // Search from the `fromIndex`. 7464 * _.indexOf([1, 2, 1, 2], 2, 2); 7465 * // => 3 7466 */ 7467 function indexOf(array, value, fromIndex) { 7468 var length = array == null ? 0 : array.length; 7469 if (!length) { 7470 return -1; 7471 } 7472 var index = fromIndex == null ? 0 : toInteger(fromIndex); 7473 if (index < 0) { 7474 index = nativeMax(length + index, 0); 7475 } 7476 return baseIndexOf(array, value, index); 7477 } 7478 7479 /** 7480 * Gets all but the last element of `array`. 7481 * 7482 * @static 7483 * @memberOf _ 7484 * @since 0.1.0 7485 * @category Array 7486 * @param {Array} array The array to query. 7487 * @returns {Array} Returns the slice of `array`. 7488 * @example 7489 * 7490 * _.initial([1, 2, 3]); 7491 * // => [1, 2] 7492 */ 7493 function initial(array) { 7494 var length = array == null ? 0 : array.length; 7495 return length ? baseSlice(array, 0, -1) : []; 7496 } 7497 7498 /** 7499 * Creates an array of unique values that are included in all given arrays 7500 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 7501 * for equality comparisons. The order and references of result values are 7502 * determined by the first array. 7503 * 7504 * @static 7505 * @memberOf _ 7506 * @since 0.1.0 7507 * @category Array 7508 * @param {...Array} [arrays] The arrays to inspect. 7509 * @returns {Array} Returns the new array of intersecting values. 7510 * @example 7511 * 7512 * _.intersection([2, 1], [2, 3]); 7513 * // => [2] 7514 */ 7515 var intersection = baseRest(function(arrays) { 7516 var mapped = arrayMap(arrays, castArrayLikeObject); 7517 return (mapped.length && mapped[0] === arrays[0]) 7518 ? baseIntersection(mapped) 7519 : []; 7520 }); 7521 7522 /** 7523 * This method is like `_.intersection` except that it accepts `iteratee` 7524 * which is invoked for each element of each `arrays` to generate the criterion 7525 * by which they're compared. The order and references of result values are 7526 * determined by the first array. The iteratee is invoked with one argument: 7527 * (value). 7528 * 7529 * @static 7530 * @memberOf _ 7531 * @since 4.0.0 7532 * @category Array 7533 * @param {...Array} [arrays] The arrays to inspect. 7534 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 7535 * @returns {Array} Returns the new array of intersecting values. 7536 * @example 7537 * 7538 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 7539 * // => [2.1] 7540 * 7541 * // The `_.property` iteratee shorthand. 7542 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 7543 * // => [{ 'x': 1 }] 7544 */ 7545 var intersectionBy = baseRest(function(arrays) { 7546 var iteratee = last(arrays), 7547 mapped = arrayMap(arrays, castArrayLikeObject); 7548 7549 if (iteratee === last(mapped)) { 7550 iteratee = undefined; 7551 } else { 7552 mapped.pop(); 7553 } 7554 return (mapped.length && mapped[0] === arrays[0]) 7555 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 7556 : []; 7557 }); 7558 7559 /** 7560 * This method is like `_.intersection` except that it accepts `comparator` 7561 * which is invoked to compare elements of `arrays`. The order and references 7562 * of result values are determined by the first array. The comparator is 7563 * invoked with two arguments: (arrVal, othVal). 7564 * 7565 * @static 7566 * @memberOf _ 7567 * @since 4.0.0 7568 * @category Array 7569 * @param {...Array} [arrays] The arrays to inspect. 7570 * @param {Function} [comparator] The comparator invoked per element. 7571 * @returns {Array} Returns the new array of intersecting values. 7572 * @example 7573 * 7574 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 7575 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 7576 * 7577 * _.intersectionWith(objects, others, _.isEqual); 7578 * // => [{ 'x': 1, 'y': 2 }] 7579 */ 7580 var intersectionWith = baseRest(function(arrays) { 7581 var comparator = last(arrays), 7582 mapped = arrayMap(arrays, castArrayLikeObject); 7583 7584 comparator = typeof comparator == 'function' ? comparator : undefined; 7585 if (comparator) { 7586 mapped.pop(); 7587 } 7588 return (mapped.length && mapped[0] === arrays[0]) 7589 ? baseIntersection(mapped, undefined, comparator) 7590 : []; 7591 }); 7592 7593 /** 7594 * Converts all elements in `array` into a string separated by `separator`. 7595 * 7596 * @static 7597 * @memberOf _ 7598 * @since 4.0.0 7599 * @category Array 7600 * @param {Array} array The array to convert. 7601 * @param {string} [separator=','] The element separator. 7602 * @returns {string} Returns the joined string. 7603 * @example 7604 * 7605 * _.join(['a', 'b', 'c'], '~'); 7606 * // => 'a~b~c' 7607 */ 7608 function join(array, separator) { 7609 return array == null ? '' : nativeJoin.call(array, separator); 7610 } 7611 7612 /** 7613 * Gets the last element of `array`. 7614 * 7615 * @static 7616 * @memberOf _ 7617 * @since 0.1.0 7618 * @category Array 7619 * @param {Array} array The array to query. 7620 * @returns {*} Returns the last element of `array`. 7621 * @example 7622 * 7623 * _.last([1, 2, 3]); 7624 * // => 3 7625 */ 7626 function last(array) { 7627 var length = array == null ? 0 : array.length; 7628 return length ? array[length - 1] : undefined; 7629 } 7630 7631 /** 7632 * This method is like `_.indexOf` except that it iterates over elements of 7633 * `array` from right to left. 7634 * 7635 * @static 7636 * @memberOf _ 7637 * @since 0.1.0 7638 * @category Array 7639 * @param {Array} array The array to inspect. 7640 * @param {*} value The value to search for. 7641 * @param {number} [fromIndex=array.length-1] The index to search from. 7642 * @returns {number} Returns the index of the matched value, else `-1`. 7643 * @example 7644 * 7645 * _.lastIndexOf([1, 2, 1, 2], 2); 7646 * // => 3 7647 * 7648 * // Search from the `fromIndex`. 7649 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 7650 * // => 1 7651 */ 7652 function lastIndexOf(array, value, fromIndex) { 7653 var length = array == null ? 0 : array.length; 7654 if (!length) { 7655 return -1; 7656 } 7657 var index = length; 7658 if (fromIndex !== undefined) { 7659 index = toInteger(fromIndex); 7660 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 7661 } 7662 return value === value 7663 ? strictLastIndexOf(array, value, index) 7664 : baseFindIndex(array, baseIsNaN, index, true); 7665 } 7666 7667 /** 7668 * Gets the element at index `n` of `array`. If `n` is negative, the nth 7669 * element from the end is returned. 7670 * 7671 * @static 7672 * @memberOf _ 7673 * @since 4.11.0 7674 * @category Array 7675 * @param {Array} array The array to query. 7676 * @param {number} [n=0] The index of the element to return. 7677 * @returns {*} Returns the nth element of `array`. 7678 * @example 7679 * 7680 * var array = ['a', 'b', 'c', 'd']; 7681 * 7682 * _.nth(array, 1); 7683 * // => 'b' 7684 * 7685 * _.nth(array, -2); 7686 * // => 'c'; 7687 */ 7688 function nth(array, n) { 7689 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 7690 } 7691 7692 /** 7693 * Removes all given values from `array` using 7694 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 7695 * for equality comparisons. 7696 * 7697 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 7698 * to remove elements from an array by predicate. 7699 * 7700 * @static 7701 * @memberOf _ 7702 * @since 2.0.0 7703 * @category Array 7704 * @param {Array} array The array to modify. 7705 * @param {...*} [values] The values to remove. 7706 * @returns {Array} Returns `array`. 7707 * @example 7708 * 7709 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 7710 * 7711 * _.pull(array, 'a', 'c'); 7712 * console.log(array); 7713 * // => ['b', 'b'] 7714 */ 7715 var pull = baseRest(pullAll); 7716 7717 /** 7718 * This method is like `_.pull` except that it accepts an array of values to remove. 7719 * 7720 * **Note:** Unlike `_.difference`, this method mutates `array`. 7721 * 7722 * @static 7723 * @memberOf _ 7724 * @since 4.0.0 7725 * @category Array 7726 * @param {Array} array The array to modify. 7727 * @param {Array} values The values to remove. 7728 * @returns {Array} Returns `array`. 7729 * @example 7730 * 7731 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 7732 * 7733 * _.pullAll(array, ['a', 'c']); 7734 * console.log(array); 7735 * // => ['b', 'b'] 7736 */ 7737 function pullAll(array, values) { 7738 return (array && array.length && values && values.length) 7739 ? basePullAll(array, values) 7740 : array; 7741 } 7742 7743 /** 7744 * This method is like `_.pullAll` except that it accepts `iteratee` which is 7745 * invoked for each element of `array` and `values` to generate the criterion 7746 * by which they're compared. The iteratee is invoked with one argument: (value). 7747 * 7748 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 7749 * 7750 * @static 7751 * @memberOf _ 7752 * @since 4.0.0 7753 * @category Array 7754 * @param {Array} array The array to modify. 7755 * @param {Array} values The values to remove. 7756 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 7757 * @returns {Array} Returns `array`. 7758 * @example 7759 * 7760 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 7761 * 7762 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 7763 * console.log(array); 7764 * // => [{ 'x': 2 }] 7765 */ 7766 function pullAllBy(array, values, iteratee) { 7767 return (array && array.length && values && values.length) 7768 ? basePullAll(array, values, getIteratee(iteratee, 2)) 7769 : array; 7770 } 7771 7772 /** 7773 * This method is like `_.pullAll` except that it accepts `comparator` which 7774 * is invoked to compare elements of `array` to `values`. The comparator is 7775 * invoked with two arguments: (arrVal, othVal). 7776 * 7777 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 7778 * 7779 * @static 7780 * @memberOf _ 7781 * @since 4.6.0 7782 * @category Array 7783 * @param {Array} array The array to modify. 7784 * @param {Array} values The values to remove. 7785 * @param {Function} [comparator] The comparator invoked per element. 7786 * @returns {Array} Returns `array`. 7787 * @example 7788 * 7789 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 7790 * 7791 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 7792 * console.log(array); 7793 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 7794 */ 7795 function pullAllWith(array, values, comparator) { 7796 return (array && array.length && values && values.length) 7797 ? basePullAll(array, values, undefined, comparator) 7798 : array; 7799 } 7800 7801 /** 7802 * Removes elements from `array` corresponding to `indexes` and returns an 7803 * array of removed elements. 7804 * 7805 * **Note:** Unlike `_.at`, this method mutates `array`. 7806 * 7807 * @static 7808 * @memberOf _ 7809 * @since 3.0.0 7810 * @category Array 7811 * @param {Array} array The array to modify. 7812 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 7813 * @returns {Array} Returns the new array of removed elements. 7814 * @example 7815 * 7816 * var array = ['a', 'b', 'c', 'd']; 7817 * var pulled = _.pullAt(array, [1, 3]); 7818 * 7819 * console.log(array); 7820 * // => ['a', 'c'] 7821 * 7822 * console.log(pulled); 7823 * // => ['b', 'd'] 7824 */ 7825 var pullAt = flatRest(function(array, indexes) { 7826 var length = array == null ? 0 : array.length, 7827 result = baseAt(array, indexes); 7828 7829 basePullAt(array, arrayMap(indexes, function(index) { 7830 return isIndex(index, length) ? +index : index; 7831 }).sort(compareAscending)); 7832 7833 return result; 7834 }); 7835 7836 /** 7837 * Removes all elements from `array` that `predicate` returns truthy for 7838 * and returns an array of the removed elements. The predicate is invoked 7839 * with three arguments: (value, index, array). 7840 * 7841 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 7842 * to pull elements from an array by value. 7843 * 7844 * @static 7845 * @memberOf _ 7846 * @since 2.0.0 7847 * @category Array 7848 * @param {Array} array The array to modify. 7849 * @param {Function} [predicate=_.identity] The function invoked per iteration. 7850 * @returns {Array} Returns the new array of removed elements. 7851 * @example 7852 * 7853 * var array = [1, 2, 3, 4]; 7854 * var evens = _.remove(array, function(n) { 7855 * return n % 2 == 0; 7856 * }); 7857 * 7858 * console.log(array); 7859 * // => [1, 3] 7860 * 7861 * console.log(evens); 7862 * // => [2, 4] 7863 */ 7864 function remove(array, predicate) { 7865 var result = []; 7866 if (!(array && array.length)) { 7867 return result; 7868 } 7869 var index = -1, 7870 indexes = [], 7871 length = array.length; 7872 7873 predicate = getIteratee(predicate, 3); 7874 while (++index < length) { 7875 var value = array[index]; 7876 if (predicate(value, index, array)) { 7877 result.push(value); 7878 indexes.push(index); 7879 } 7880 } 7881 basePullAt(array, indexes); 7882 return result; 7883 } 7884 7885 /** 7886 * Reverses `array` so that the first element becomes the last, the second 7887 * element becomes the second to last, and so on. 7888 * 7889 * **Note:** This method mutates `array` and is based on 7890 * [`Array#reverse`](https://mdn.io/Array/reverse). 7891 * 7892 * @static 7893 * @memberOf _ 7894 * @since 4.0.0 7895 * @category Array 7896 * @param {Array} array The array to modify. 7897 * @returns {Array} Returns `array`. 7898 * @example 7899 * 7900 * var array = [1, 2, 3]; 7901 * 7902 * _.reverse(array); 7903 * // => [3, 2, 1] 7904 * 7905 * console.log(array); 7906 * // => [3, 2, 1] 7907 */ 7908 function reverse(array) { 7909 return array == null ? array : nativeReverse.call(array); 7910 } 7911 7912 /** 7913 * Creates a slice of `array` from `start` up to, but not including, `end`. 7914 * 7915 * **Note:** This method is used instead of 7916 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 7917 * returned. 7918 * 7919 * @static 7920 * @memberOf _ 7921 * @since 3.0.0 7922 * @category Array 7923 * @param {Array} array The array to slice. 7924 * @param {number} [start=0] The start position. 7925 * @param {number} [end=array.length] The end position. 7926 * @returns {Array} Returns the slice of `array`. 7927 */ 7928 function slice(array, start, end) { 7929 var length = array == null ? 0 : array.length; 7930 if (!length) { 7931 return []; 7932 } 7933 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 7934 start = 0; 7935 end = length; 7936 } 7937 else { 7938 start = start == null ? 0 : toInteger(start); 7939 end = end === undefined ? length : toInteger(end); 7940 } 7941 return baseSlice(array, start, end); 7942 } 7943 7944 /** 7945 * Uses a binary search to determine the lowest index at which `value` 7946 * should be inserted into `array` in order to maintain its sort order. 7947 * 7948 * @static 7949 * @memberOf _ 7950 * @since 0.1.0 7951 * @category Array 7952 * @param {Array} array The sorted array to inspect. 7953 * @param {*} value The value to evaluate. 7954 * @returns {number} Returns the index at which `value` should be inserted 7955 * into `array`. 7956 * @example 7957 * 7958 * _.sortedIndex([30, 50], 40); 7959 * // => 1 7960 */ 7961 function sortedIndex(array, value) { 7962 return baseSortedIndex(array, value); 7963 } 7964 7965 /** 7966 * This method is like `_.sortedIndex` except that it accepts `iteratee` 7967 * which is invoked for `value` and each element of `array` to compute their 7968 * sort ranking. The iteratee is invoked with one argument: (value). 7969 * 7970 * @static 7971 * @memberOf _ 7972 * @since 4.0.0 7973 * @category Array 7974 * @param {Array} array The sorted array to inspect. 7975 * @param {*} value The value to evaluate. 7976 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 7977 * @returns {number} Returns the index at which `value` should be inserted 7978 * into `array`. 7979 * @example 7980 * 7981 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 7982 * 7983 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 7984 * // => 0 7985 * 7986 * // The `_.property` iteratee shorthand. 7987 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 7988 * // => 0 7989 */ 7990 function sortedIndexBy(array, value, iteratee) { 7991 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 7992 } 7993 7994 /** 7995 * This method is like `_.indexOf` except that it performs a binary 7996 * search on a sorted `array`. 7997 * 7998 * @static 7999 * @memberOf _ 8000 * @since 4.0.0 8001 * @category Array 8002 * @param {Array} array The array to inspect. 8003 * @param {*} value The value to search for. 8004 * @returns {number} Returns the index of the matched value, else `-1`. 8005 * @example 8006 * 8007 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 8008 * // => 1 8009 */ 8010 function sortedIndexOf(array, value) { 8011 var length = array == null ? 0 : array.length; 8012 if (length) { 8013 var index = baseSortedIndex(array, value); 8014 if (index < length && eq(array[index], value)) { 8015 return index; 8016 } 8017 } 8018 return -1; 8019 } 8020 8021 /** 8022 * This method is like `_.sortedIndex` except that it returns the highest 8023 * index at which `value` should be inserted into `array` in order to 8024 * maintain its sort order. 8025 * 8026 * @static 8027 * @memberOf _ 8028 * @since 3.0.0 8029 * @category Array 8030 * @param {Array} array The sorted array to inspect. 8031 * @param {*} value The value to evaluate. 8032 * @returns {number} Returns the index at which `value` should be inserted 8033 * into `array`. 8034 * @example 8035 * 8036 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 8037 * // => 4 8038 */ 8039 function sortedLastIndex(array, value) { 8040 return baseSortedIndex(array, value, true); 8041 } 8042 8043 /** 8044 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 8045 * which is invoked for `value` and each element of `array` to compute their 8046 * sort ranking. The iteratee is invoked with one argument: (value). 8047 * 8048 * @static 8049 * @memberOf _ 8050 * @since 4.0.0 8051 * @category Array 8052 * @param {Array} array The sorted array to inspect. 8053 * @param {*} value The value to evaluate. 8054 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8055 * @returns {number} Returns the index at which `value` should be inserted 8056 * into `array`. 8057 * @example 8058 * 8059 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 8060 * 8061 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 8062 * // => 1 8063 * 8064 * // The `_.property` iteratee shorthand. 8065 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 8066 * // => 1 8067 */ 8068 function sortedLastIndexBy(array, value, iteratee) { 8069 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 8070 } 8071 8072 /** 8073 * This method is like `_.lastIndexOf` except that it performs a binary 8074 * search on a sorted `array`. 8075 * 8076 * @static 8077 * @memberOf _ 8078 * @since 4.0.0 8079 * @category Array 8080 * @param {Array} array The array to inspect. 8081 * @param {*} value The value to search for. 8082 * @returns {number} Returns the index of the matched value, else `-1`. 8083 * @example 8084 * 8085 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 8086 * // => 3 8087 */ 8088 function sortedLastIndexOf(array, value) { 8089 var length = array == null ? 0 : array.length; 8090 if (length) { 8091 var index = baseSortedIndex(array, value, true) - 1; 8092 if (eq(array[index], value)) { 8093 return index; 8094 } 8095 } 8096 return -1; 8097 } 8098 8099 /** 8100 * This method is like `_.uniq` except that it's designed and optimized 8101 * for sorted arrays. 8102 * 8103 * @static 8104 * @memberOf _ 8105 * @since 4.0.0 8106 * @category Array 8107 * @param {Array} array The array to inspect. 8108 * @returns {Array} Returns the new duplicate free array. 8109 * @example 8110 * 8111 * _.sortedUniq([1, 1, 2]); 8112 * // => [1, 2] 8113 */ 8114 function sortedUniq(array) { 8115 return (array && array.length) 8116 ? baseSortedUniq(array) 8117 : []; 8118 } 8119 8120 /** 8121 * This method is like `_.uniqBy` except that it's designed and optimized 8122 * for sorted arrays. 8123 * 8124 * @static 8125 * @memberOf _ 8126 * @since 4.0.0 8127 * @category Array 8128 * @param {Array} array The array to inspect. 8129 * @param {Function} [iteratee] The iteratee invoked per element. 8130 * @returns {Array} Returns the new duplicate free array. 8131 * @example 8132 * 8133 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 8134 * // => [1.1, 2.3] 8135 */ 8136 function sortedUniqBy(array, iteratee) { 8137 return (array && array.length) 8138 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 8139 : []; 8140 } 8141 8142 /** 8143 * Gets all but the first element of `array`. 8144 * 8145 * @static 8146 * @memberOf _ 8147 * @since 4.0.0 8148 * @category Array 8149 * @param {Array} array The array to query. 8150 * @returns {Array} Returns the slice of `array`. 8151 * @example 8152 * 8153 * _.tail([1, 2, 3]); 8154 * // => [2, 3] 8155 */ 8156 function tail(array) { 8157 var length = array == null ? 0 : array.length; 8158 return length ? baseSlice(array, 1, length) : []; 8159 } 8160 8161 /** 8162 * Creates a slice of `array` with `n` elements taken from the beginning. 8163 * 8164 * @static 8165 * @memberOf _ 8166 * @since 0.1.0 8167 * @category Array 8168 * @param {Array} array The array to query. 8169 * @param {number} [n=1] The number of elements to take. 8170 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8171 * @returns {Array} Returns the slice of `array`. 8172 * @example 8173 * 8174 * _.take([1, 2, 3]); 8175 * // => [1] 8176 * 8177 * _.take([1, 2, 3], 2); 8178 * // => [1, 2] 8179 * 8180 * _.take([1, 2, 3], 5); 8181 * // => [1, 2, 3] 8182 * 8183 * _.take([1, 2, 3], 0); 8184 * // => [] 8185 */ 8186 function take(array, n, guard) { 8187 if (!(array && array.length)) { 8188 return []; 8189 } 8190 n = (guard || n === undefined) ? 1 : toInteger(n); 8191 return baseSlice(array, 0, n < 0 ? 0 : n); 8192 } 8193 8194 /** 8195 * Creates a slice of `array` with `n` elements taken from the end. 8196 * 8197 * @static 8198 * @memberOf _ 8199 * @since 3.0.0 8200 * @category Array 8201 * @param {Array} array The array to query. 8202 * @param {number} [n=1] The number of elements to take. 8203 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8204 * @returns {Array} Returns the slice of `array`. 8205 * @example 8206 * 8207 * _.takeRight([1, 2, 3]); 8208 * // => [3] 8209 * 8210 * _.takeRight([1, 2, 3], 2); 8211 * // => [2, 3] 8212 * 8213 * _.takeRight([1, 2, 3], 5); 8214 * // => [1, 2, 3] 8215 * 8216 * _.takeRight([1, 2, 3], 0); 8217 * // => [] 8218 */ 8219 function takeRight(array, n, guard) { 8220 var length = array == null ? 0 : array.length; 8221 if (!length) { 8222 return []; 8223 } 8224 n = (guard || n === undefined) ? 1 : toInteger(n); 8225 n = length - n; 8226 return baseSlice(array, n < 0 ? 0 : n, length); 8227 } 8228 8229 /** 8230 * Creates a slice of `array` with elements taken from the end. Elements are 8231 * taken until `predicate` returns falsey. The predicate is invoked with 8232 * three arguments: (value, index, array). 8233 * 8234 * @static 8235 * @memberOf _ 8236 * @since 3.0.0 8237 * @category Array 8238 * @param {Array} array The array to query. 8239 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8240 * @returns {Array} Returns the slice of `array`. 8241 * @example 8242 * 8243 * var users = [ 8244 * { 'user': 'barney', 'active': true }, 8245 * { 'user': 'fred', 'active': false }, 8246 * { 'user': 'pebbles', 'active': false } 8247 * ]; 8248 * 8249 * _.takeRightWhile(users, function(o) { return !o.active; }); 8250 * // => objects for ['fred', 'pebbles'] 8251 * 8252 * // The `_.matches` iteratee shorthand. 8253 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 8254 * // => objects for ['pebbles'] 8255 * 8256 * // The `_.matchesProperty` iteratee shorthand. 8257 * _.takeRightWhile(users, ['active', false]); 8258 * // => objects for ['fred', 'pebbles'] 8259 * 8260 * // The `_.property` iteratee shorthand. 8261 * _.takeRightWhile(users, 'active'); 8262 * // => [] 8263 */ 8264 function takeRightWhile(array, predicate) { 8265 return (array && array.length) 8266 ? baseWhile(array, getIteratee(predicate, 3), false, true) 8267 : []; 8268 } 8269 8270 /** 8271 * Creates a slice of `array` with elements taken from the beginning. Elements 8272 * are taken until `predicate` returns falsey. The predicate is invoked with 8273 * three arguments: (value, index, array). 8274 * 8275 * @static 8276 * @memberOf _ 8277 * @since 3.0.0 8278 * @category Array 8279 * @param {Array} array The array to query. 8280 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8281 * @returns {Array} Returns the slice of `array`. 8282 * @example 8283 * 8284 * var users = [ 8285 * { 'user': 'barney', 'active': false }, 8286 * { 'user': 'fred', 'active': false }, 8287 * { 'user': 'pebbles', 'active': true } 8288 * ]; 8289 * 8290 * _.takeWhile(users, function(o) { return !o.active; }); 8291 * // => objects for ['barney', 'fred'] 8292 * 8293 * // The `_.matches` iteratee shorthand. 8294 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 8295 * // => objects for ['barney'] 8296 * 8297 * // The `_.matchesProperty` iteratee shorthand. 8298 * _.takeWhile(users, ['active', false]); 8299 * // => objects for ['barney', 'fred'] 8300 * 8301 * // The `_.property` iteratee shorthand. 8302 * _.takeWhile(users, 'active'); 8303 * // => [] 8304 */ 8305 function takeWhile(array, predicate) { 8306 return (array && array.length) 8307 ? baseWhile(array, getIteratee(predicate, 3)) 8308 : []; 8309 } 8310 8311 /** 8312 * Creates an array of unique values, in order, from all given arrays using 8313 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 8314 * for equality comparisons. 8315 * 8316 * @static 8317 * @memberOf _ 8318 * @since 0.1.0 8319 * @category Array 8320 * @param {...Array} [arrays] The arrays to inspect. 8321 * @returns {Array} Returns the new array of combined values. 8322 * @example 8323 * 8324 * _.union([2], [1, 2]); 8325 * // => [2, 1] 8326 */ 8327 var union = baseRest(function(arrays) { 8328 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 8329 }); 8330 8331 /** 8332 * This method is like `_.union` except that it accepts `iteratee` which is 8333 * invoked for each element of each `arrays` to generate the criterion by 8334 * which uniqueness is computed. Result values are chosen from the first 8335 * array in which the value occurs. The iteratee is invoked with one argument: 8336 * (value). 8337 * 8338 * @static 8339 * @memberOf _ 8340 * @since 4.0.0 8341 * @category Array 8342 * @param {...Array} [arrays] The arrays to inspect. 8343 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8344 * @returns {Array} Returns the new array of combined values. 8345 * @example 8346 * 8347 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 8348 * // => [2.1, 1.2] 8349 * 8350 * // The `_.property` iteratee shorthand. 8351 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 8352 * // => [{ 'x': 1 }, { 'x': 2 }] 8353 */ 8354 var unionBy = baseRest(function(arrays) { 8355 var iteratee = last(arrays); 8356 if (isArrayLikeObject(iteratee)) { 8357 iteratee = undefined; 8358 } 8359 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 8360 }); 8361 8362 /** 8363 * This method is like `_.union` except that it accepts `comparator` which 8364 * is invoked to compare elements of `arrays`. Result values are chosen from 8365 * the first array in which the value occurs. The comparator is invoked 8366 * with two arguments: (arrVal, othVal). 8367 * 8368 * @static 8369 * @memberOf _ 8370 * @since 4.0.0 8371 * @category Array 8372 * @param {...Array} [arrays] The arrays to inspect. 8373 * @param {Function} [comparator] The comparator invoked per element. 8374 * @returns {Array} Returns the new array of combined values. 8375 * @example 8376 * 8377 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 8378 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 8379 * 8380 * _.unionWith(objects, others, _.isEqual); 8381 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 8382 */ 8383 var unionWith = baseRest(function(arrays) { 8384 var comparator = last(arrays); 8385 comparator = typeof comparator == 'function' ? comparator : undefined; 8386 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 8387 }); 8388 8389 /** 8390 * Creates a duplicate-free version of an array, using 8391 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 8392 * for equality comparisons, in which only the first occurrence of each element 8393 * is kept. The order of result values is determined by the order they occur 8394 * in the array. 8395 * 8396 * @static 8397 * @memberOf _ 8398 * @since 0.1.0 8399 * @category Array 8400 * @param {Array} array The array to inspect. 8401 * @returns {Array} Returns the new duplicate free array. 8402 * @example 8403 * 8404 * _.uniq([2, 1, 2]); 8405 * // => [2, 1] 8406 */ 8407 function uniq(array) { 8408 return (array && array.length) ? baseUniq(array) : []; 8409 } 8410 8411 /** 8412 * This method is like `_.uniq` except that it accepts `iteratee` which is 8413 * invoked for each element in `array` to generate the criterion by which 8414 * uniqueness is computed. The order of result values is determined by the 8415 * order they occur in the array. The iteratee is invoked with one argument: 8416 * (value). 8417 * 8418 * @static 8419 * @memberOf _ 8420 * @since 4.0.0 8421 * @category Array 8422 * @param {Array} array The array to inspect. 8423 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8424 * @returns {Array} Returns the new duplicate free array. 8425 * @example 8426 * 8427 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 8428 * // => [2.1, 1.2] 8429 * 8430 * // The `_.property` iteratee shorthand. 8431 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 8432 * // => [{ 'x': 1 }, { 'x': 2 }] 8433 */ 8434 function uniqBy(array, iteratee) { 8435 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 8436 } 8437 8438 /** 8439 * This method is like `_.uniq` except that it accepts `comparator` which 8440 * is invoked to compare elements of `array`. The order of result values is 8441 * determined by the order they occur in the array.The comparator is invoked 8442 * with two arguments: (arrVal, othVal). 8443 * 8444 * @static 8445 * @memberOf _ 8446 * @since 4.0.0 8447 * @category Array 8448 * @param {Array} array The array to inspect. 8449 * @param {Function} [comparator] The comparator invoked per element. 8450 * @returns {Array} Returns the new duplicate free array. 8451 * @example 8452 * 8453 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 8454 * 8455 * _.uniqWith(objects, _.isEqual); 8456 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 8457 */ 8458 function uniqWith(array, comparator) { 8459 comparator = typeof comparator == 'function' ? comparator : undefined; 8460 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 8461 } 8462 8463 /** 8464 * This method is like `_.zip` except that it accepts an array of grouped 8465 * elements and creates an array regrouping the elements to their pre-zip 8466 * configuration. 8467 * 8468 * @static 8469 * @memberOf _ 8470 * @since 1.2.0 8471 * @category Array 8472 * @param {Array} array The array of grouped elements to process. 8473 * @returns {Array} Returns the new array of regrouped elements. 8474 * @example 8475 * 8476 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 8477 * // => [['a', 1, true], ['b', 2, false]] 8478 * 8479 * _.unzip(zipped); 8480 * // => [['a', 'b'], [1, 2], [true, false]] 8481 */ 8482 function unzip(array) { 8483 if (!(array && array.length)) { 8484 return []; 8485 } 8486 var length = 0; 8487 array = arrayFilter(array, function(group) { 8488 if (isArrayLikeObject(group)) { 8489 length = nativeMax(group.length, length); 8490 return true; 8491 } 8492 }); 8493 return baseTimes(length, function(index) { 8494 return arrayMap(array, baseProperty(index)); 8495 }); 8496 } 8497 8498 /** 8499 * This method is like `_.unzip` except that it accepts `iteratee` to specify 8500 * how regrouped values should be combined. The iteratee is invoked with the 8501 * elements of each group: (...group). 8502 * 8503 * @static 8504 * @memberOf _ 8505 * @since 3.8.0 8506 * @category Array 8507 * @param {Array} array The array of grouped elements to process. 8508 * @param {Function} [iteratee=_.identity] The function to combine 8509 * regrouped values. 8510 * @returns {Array} Returns the new array of regrouped elements. 8511 * @example 8512 * 8513 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 8514 * // => [[1, 10, 100], [2, 20, 200]] 8515 * 8516 * _.unzipWith(zipped, _.add); 8517 * // => [3, 30, 300] 8518 */ 8519 function unzipWith(array, iteratee) { 8520 if (!(array && array.length)) { 8521 return []; 8522 } 8523 var result = unzip(array); 8524 if (iteratee == null) { 8525 return result; 8526 } 8527 return arrayMap(result, function(group) { 8528 return apply(iteratee, undefined, group); 8529 }); 8530 } 8531 8532 /** 8533 * Creates an array excluding all given values using 8534 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 8535 * for equality comparisons. 8536 * 8537 * **Note:** Unlike `_.pull`, this method returns a new array. 8538 * 8539 * @static 8540 * @memberOf _ 8541 * @since 0.1.0 8542 * @category Array 8543 * @param {Array} array The array to inspect. 8544 * @param {...*} [values] The values to exclude. 8545 * @returns {Array} Returns the new array of filtered values. 8546 * @see _.difference, _.xor 8547 * @example 8548 * 8549 * _.without([2, 1, 2, 3], 1, 2); 8550 * // => [3] 8551 */ 8552 var without = baseRest(function(array, values) { 8553 return isArrayLikeObject(array) 8554 ? baseDifference(array, values) 8555 : []; 8556 }); 8557 8558 /** 8559 * Creates an array of unique values that is the 8560 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 8561 * of the given arrays. The order of result values is determined by the order 8562 * they occur in the arrays. 8563 * 8564 * @static 8565 * @memberOf _ 8566 * @since 2.4.0 8567 * @category Array 8568 * @param {...Array} [arrays] The arrays to inspect. 8569 * @returns {Array} Returns the new array of filtered values. 8570 * @see _.difference, _.without 8571 * @example 8572 * 8573 * _.xor([2, 1], [2, 3]); 8574 * // => [1, 3] 8575 */ 8576 var xor = baseRest(function(arrays) { 8577 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 8578 }); 8579 8580 /** 8581 * This method is like `_.xor` except that it accepts `iteratee` which is 8582 * invoked for each element of each `arrays` to generate the criterion by 8583 * which by which they're compared. The order of result values is determined 8584 * by the order they occur in the arrays. The iteratee is invoked with one 8585 * argument: (value). 8586 * 8587 * @static 8588 * @memberOf _ 8589 * @since 4.0.0 8590 * @category Array 8591 * @param {...Array} [arrays] The arrays to inspect. 8592 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8593 * @returns {Array} Returns the new array of filtered values. 8594 * @example 8595 * 8596 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 8597 * // => [1.2, 3.4] 8598 * 8599 * // The `_.property` iteratee shorthand. 8600 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 8601 * // => [{ 'x': 2 }] 8602 */ 8603 var xorBy = baseRest(function(arrays) { 8604 var iteratee = last(arrays); 8605 if (isArrayLikeObject(iteratee)) { 8606 iteratee = undefined; 8607 } 8608 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 8609 }); 8610 8611 /** 8612 * This method is like `_.xor` except that it accepts `comparator` which is 8613 * invoked to compare elements of `arrays`. The order of result values is 8614 * determined by the order they occur in the arrays. The comparator is invoked 8615 * with two arguments: (arrVal, othVal). 8616 * 8617 * @static 8618 * @memberOf _ 8619 * @since 4.0.0 8620 * @category Array 8621 * @param {...Array} [arrays] The arrays to inspect. 8622 * @param {Function} [comparator] The comparator invoked per element. 8623 * @returns {Array} Returns the new array of filtered values. 8624 * @example 8625 * 8626 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 8627 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 8628 * 8629 * _.xorWith(objects, others, _.isEqual); 8630 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 8631 */ 8632 var xorWith = baseRest(function(arrays) { 8633 var comparator = last(arrays); 8634 comparator = typeof comparator == 'function' ? comparator : undefined; 8635 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 8636 }); 8637 8638 /** 8639 * Creates an array of grouped elements, the first of which contains the 8640 * first elements of the given arrays, the second of which contains the 8641 * second elements of the given arrays, and so on. 8642 * 8643 * @static 8644 * @memberOf _ 8645 * @since 0.1.0 8646 * @category Array 8647 * @param {...Array} [arrays] The arrays to process. 8648 * @returns {Array} Returns the new array of grouped elements. 8649 * @example 8650 * 8651 * _.zip(['a', 'b'], [1, 2], [true, false]); 8652 * // => [['a', 1, true], ['b', 2, false]] 8653 */ 8654 var zip = baseRest(unzip); 8655 8656 /** 8657 * This method is like `_.fromPairs` except that it accepts two arrays, 8658 * one of property identifiers and one of corresponding values. 8659 * 8660 * @static 8661 * @memberOf _ 8662 * @since 0.4.0 8663 * @category Array 8664 * @param {Array} [props=[]] The property identifiers. 8665 * @param {Array} [values=[]] The property values. 8666 * @returns {Object} Returns the new object. 8667 * @example 8668 * 8669 * _.zipObject(['a', 'b'], [1, 2]); 8670 * // => { 'a': 1, 'b': 2 } 8671 */ 8672 function zipObject(props, values) { 8673 return baseZipObject(props || [], values || [], assignValue); 8674 } 8675 8676 /** 8677 * This method is like `_.zipObject` except that it supports property paths. 8678 * 8679 * @static 8680 * @memberOf _ 8681 * @since 4.1.0 8682 * @category Array 8683 * @param {Array} [props=[]] The property identifiers. 8684 * @param {Array} [values=[]] The property values. 8685 * @returns {Object} Returns the new object. 8686 * @example 8687 * 8688 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 8689 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 8690 */ 8691 function zipObjectDeep(props, values) { 8692 return baseZipObject(props || [], values || [], baseSet); 8693 } 8694 8695 /** 8696 * This method is like `_.zip` except that it accepts `iteratee` to specify 8697 * how grouped values should be combined. The iteratee is invoked with the 8698 * elements of each group: (...group). 8699 * 8700 * @static 8701 * @memberOf _ 8702 * @since 3.8.0 8703 * @category Array 8704 * @param {...Array} [arrays] The arrays to process. 8705 * @param {Function} [iteratee=_.identity] The function to combine 8706 * grouped values. 8707 * @returns {Array} Returns the new array of grouped elements. 8708 * @example 8709 * 8710 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 8711 * return a + b + c; 8712 * }); 8713 * // => [111, 222] 8714 */ 8715 var zipWith = baseRest(function(arrays) { 8716 var length = arrays.length, 8717 iteratee = length > 1 ? arrays[length - 1] : undefined; 8718 8719 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 8720 return unzipWith(arrays, iteratee); 8721 }); 8722 8723 /*------------------------------------------------------------------------*/ 8724 8725 /** 8726 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 8727 * chain sequences enabled. The result of such sequences must be unwrapped 8728 * with `_#value`. 8729 * 8730 * @static 8731 * @memberOf _ 8732 * @since 1.3.0 8733 * @category Seq 8734 * @param {*} value The value to wrap. 8735 * @returns {Object} Returns the new `lodash` wrapper instance. 8736 * @example 8737 * 8738 * var users = [ 8739 * { 'user': 'barney', 'age': 36 }, 8740 * { 'user': 'fred', 'age': 40 }, 8741 * { 'user': 'pebbles', 'age': 1 } 8742 * ]; 8743 * 8744 * var youngest = _ 8745 * .chain(users) 8746 * .sortBy('age') 8747 * .map(function(o) { 8748 * return o.user + ' is ' + o.age; 8749 * }) 8750 * .head() 8751 * .value(); 8752 * // => 'pebbles is 1' 8753 */ 8754 function chain(value) { 8755 var result = lodash(value); 8756 result.__chain__ = true; 8757 return result; 8758 } 8759 8760 /** 8761 * This method invokes `interceptor` and returns `value`. The interceptor 8762 * is invoked with one argument; (value). The purpose of this method is to 8763 * "tap into" a method chain sequence in order to modify intermediate results. 8764 * 8765 * @static 8766 * @memberOf _ 8767 * @since 0.1.0 8768 * @category Seq 8769 * @param {*} value The value to provide to `interceptor`. 8770 * @param {Function} interceptor The function to invoke. 8771 * @returns {*} Returns `value`. 8772 * @example 8773 * 8774 * _([1, 2, 3]) 8775 * .tap(function(array) { 8776 * // Mutate input array. 8777 * array.pop(); 8778 * }) 8779 * .reverse() 8780 * .value(); 8781 * // => [2, 1] 8782 */ 8783 function tap(value, interceptor) { 8784 interceptor(value); 8785 return value; 8786 } 8787 8788 /** 8789 * This method is like `_.tap` except that it returns the result of `interceptor`. 8790 * The purpose of this method is to "pass thru" values replacing intermediate 8791 * results in a method chain sequence. 8792 * 8793 * @static 8794 * @memberOf _ 8795 * @since 3.0.0 8796 * @category Seq 8797 * @param {*} value The value to provide to `interceptor`. 8798 * @param {Function} interceptor The function to invoke. 8799 * @returns {*} Returns the result of `interceptor`. 8800 * @example 8801 * 8802 * _(' abc ') 8803 * .chain() 8804 * .trim() 8805 * .thru(function(value) { 8806 * return [value]; 8807 * }) 8808 * .value(); 8809 * // => ['abc'] 8810 */ 8811 function thru(value, interceptor) { 8812 return interceptor(value); 8813 } 8814 8815 /** 8816 * This method is the wrapper version of `_.at`. 8817 * 8818 * @name at 8819 * @memberOf _ 8820 * @since 1.0.0 8821 * @category Seq 8822 * @param {...(string|string[])} [paths] The property paths to pick. 8823 * @returns {Object} Returns the new `lodash` wrapper instance. 8824 * @example 8825 * 8826 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 8827 * 8828 * _(object).at(['a[0].b.c', 'a[1]']).value(); 8829 * // => [3, 4] 8830 */ 8831 var wrapperAt = flatRest(function(paths) { 8832 var length = paths.length, 8833 start = length ? paths[0] : 0, 8834 value = this.__wrapped__, 8835 interceptor = function(object) { return baseAt(object, paths); }; 8836 8837 if (length > 1 || this.__actions__.length || 8838 !(value instanceof LazyWrapper) || !isIndex(start)) { 8839 return this.thru(interceptor); 8840 } 8841 value = value.slice(start, +start + (length ? 1 : 0)); 8842 value.__actions__.push({ 8843 'func': thru, 8844 'args': [interceptor], 8845 'thisArg': undefined 8846 }); 8847 return new LodashWrapper(value, this.__chain__).thru(function(array) { 8848 if (length && !array.length) { 8849 array.push(undefined); 8850 } 8851 return array; 8852 }); 8853 }); 8854 8855 /** 8856 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 8857 * 8858 * @name chain 8859 * @memberOf _ 8860 * @since 0.1.0 8861 * @category Seq 8862 * @returns {Object} Returns the new `lodash` wrapper instance. 8863 * @example 8864 * 8865 * var users = [ 8866 * { 'user': 'barney', 'age': 36 }, 8867 * { 'user': 'fred', 'age': 40 } 8868 * ]; 8869 * 8870 * // A sequence without explicit chaining. 8871 * _(users).head(); 8872 * // => { 'user': 'barney', 'age': 36 } 8873 * 8874 * // A sequence with explicit chaining. 8875 * _(users) 8876 * .chain() 8877 * .head() 8878 * .pick('user') 8879 * .value(); 8880 * // => { 'user': 'barney' } 8881 */ 8882 function wrapperChain() { 8883 return chain(this); 8884 } 8885 8886 /** 8887 * Executes the chain sequence and returns the wrapped result. 8888 * 8889 * @name commit 8890 * @memberOf _ 8891 * @since 3.2.0 8892 * @category Seq 8893 * @returns {Object} Returns the new `lodash` wrapper instance. 8894 * @example 8895 * 8896 * var array = [1, 2]; 8897 * var wrapped = _(array).push(3); 8898 * 8899 * console.log(array); 8900 * // => [1, 2] 8901 * 8902 * wrapped = wrapped.commit(); 8903 * console.log(array); 8904 * // => [1, 2, 3] 8905 * 8906 * wrapped.last(); 8907 * // => 3 8908 * 8909 * console.log(array); 8910 * // => [1, 2, 3] 8911 */ 8912 function wrapperCommit() { 8913 return new LodashWrapper(this.value(), this.__chain__); 8914 } 8915 8916 /** 8917 * Gets the next value on a wrapped object following the 8918 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 8919 * 8920 * @name next 8921 * @memberOf _ 8922 * @since 4.0.0 8923 * @category Seq 8924 * @returns {Object} Returns the next iterator value. 8925 * @example 8926 * 8927 * var wrapped = _([1, 2]); 8928 * 8929 * wrapped.next(); 8930 * // => { 'done': false, 'value': 1 } 8931 * 8932 * wrapped.next(); 8933 * // => { 'done': false, 'value': 2 } 8934 * 8935 * wrapped.next(); 8936 * // => { 'done': true, 'value': undefined } 8937 */ 8938 function wrapperNext() { 8939 if (this.__values__ === undefined) { 8940 this.__values__ = toArray(this.value()); 8941 } 8942 var done = this.__index__ >= this.__values__.length, 8943 value = done ? undefined : this.__values__[this.__index__++]; 8944 8945 return { 'done': done, 'value': value }; 8946 } 8947 8948 /** 8949 * Enables the wrapper to be iterable. 8950 * 8951 * @name Symbol.iterator 8952 * @memberOf _ 8953 * @since 4.0.0 8954 * @category Seq 8955 * @returns {Object} Returns the wrapper object. 8956 * @example 8957 * 8958 * var wrapped = _([1, 2]); 8959 * 8960 * wrapped[Symbol.iterator]() === wrapped; 8961 * // => true 8962 * 8963 * Array.from(wrapped); 8964 * // => [1, 2] 8965 */ 8966 function wrapperToIterator() { 8967 return this; 8968 } 8969 8970 /** 8971 * Creates a clone of the chain sequence planting `value` as the wrapped value. 8972 * 8973 * @name plant 8974 * @memberOf _ 8975 * @since 3.2.0 8976 * @category Seq 8977 * @param {*} value The value to plant. 8978 * @returns {Object} Returns the new `lodash` wrapper instance. 8979 * @example 8980 * 8981 * function square(n) { 8982 * return n * n; 8983 * } 8984 * 8985 * var wrapped = _([1, 2]).map(square); 8986 * var other = wrapped.plant([3, 4]); 8987 * 8988 * other.value(); 8989 * // => [9, 16] 8990 * 8991 * wrapped.value(); 8992 * // => [1, 4] 8993 */ 8994 function wrapperPlant(value) { 8995 var result, 8996 parent = this; 8997 8998 while (parent instanceof baseLodash) { 8999 var clone = wrapperClone(parent); 9000 clone.__index__ = 0; 9001 clone.__values__ = undefined; 9002 if (result) { 9003 previous.__wrapped__ = clone; 9004 } else { 9005 result = clone; 9006 } 9007 var previous = clone; 9008 parent = parent.__wrapped__; 9009 } 9010 previous.__wrapped__ = value; 9011 return result; 9012 } 9013 9014 /** 9015 * This method is the wrapper version of `_.reverse`. 9016 * 9017 * **Note:** This method mutates the wrapped array. 9018 * 9019 * @name reverse 9020 * @memberOf _ 9021 * @since 0.1.0 9022 * @category Seq 9023 * @returns {Object} Returns the new `lodash` wrapper instance. 9024 * @example 9025 * 9026 * var array = [1, 2, 3]; 9027 * 9028 * _(array).reverse().value() 9029 * // => [3, 2, 1] 9030 * 9031 * console.log(array); 9032 * // => [3, 2, 1] 9033 */ 9034 function wrapperReverse() { 9035 var value = this.__wrapped__; 9036 if (value instanceof LazyWrapper) { 9037 var wrapped = value; 9038 if (this.__actions__.length) { 9039 wrapped = new LazyWrapper(this); 9040 } 9041 wrapped = wrapped.reverse(); 9042 wrapped.__actions__.push({ 9043 'func': thru, 9044 'args': [reverse], 9045 'thisArg': undefined 9046 }); 9047 return new LodashWrapper(wrapped, this.__chain__); 9048 } 9049 return this.thru(reverse); 9050 } 9051 9052 /** 9053 * Executes the chain sequence to resolve the unwrapped value. 9054 * 9055 * @name value 9056 * @memberOf _ 9057 * @since 0.1.0 9058 * @alias toJSON, valueOf 9059 * @category Seq 9060 * @returns {*} Returns the resolved unwrapped value. 9061 * @example 9062 * 9063 * _([1, 2, 3]).value(); 9064 * // => [1, 2, 3] 9065 */ 9066 function wrapperValue() { 9067 return baseWrapperValue(this.__wrapped__, this.__actions__); 9068 } 9069 9070 /*------------------------------------------------------------------------*/ 9071 9072 /**
vendor: 6,915 bytes, lines 9073-9263
9073 * Creates an object composed of keys generated from the results of running 9074 * each element of `collection` thru `iteratee`. The corresponding value of 9075 * each key is the number of times the key was returned by `iteratee`. The 9076 * iteratee is invoked with one argument: (value). 9077 * 9078 * @static 9079 * @memberOf _ 9080 * @since 0.5.0 9081 * @category Collection 9082 * @param {Array|Object} collection The collection to iterate over. 9083 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 9084 * @returns {Object} Returns the composed aggregate object. 9085 * @example 9086 * 9087 * _.countBy([6.1, 4.2, 6.3], Math.floor); 9088 * // => { '4': 1, '6': 2 } 9089 * 9090 * // The `_.property` iteratee shorthand. 9091 * _.countBy(['one', 'two', 'three'], 'length'); 9092 * // => { '3': 2, '5': 1 } 9093 */ 9094 var countBy = createAggregator(function(result, value, key) { 9095 if (hasOwnProperty.call(result, key)) { 9096 ++result[key]; 9097 } else { 9098 baseAssignValue(result, key, 1); 9099 } 9100 }); 9101 9102 /** 9103 * Checks if `predicate` returns truthy for **all** elements of `collection`. 9104 * Iteration is stopped once `predicate` returns falsey. The predicate is 9105 * invoked with three arguments: (value, index|key, collection). 9106 * 9107 * **Note:** This method returns `true` for 9108 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 9109 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 9110 * elements of empty collections. 9111 * 9112 * @static 9113 * @memberOf _ 9114 * @since 0.1.0 9115 * @category Collection 9116 * @param {Array|Object} collection The collection to iterate over. 9117 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9118 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9119 * @returns {boolean} Returns `true` if all elements pass the predicate check, 9120 * else `false`. 9121 * @example 9122 * 9123 * _.every([true, 1, null, 'yes'], Boolean); 9124 * // => false 9125 * 9126 * var users = [ 9127 * { 'user': 'barney', 'age': 36, 'active': false }, 9128 * { 'user': 'fred', 'age': 40, 'active': false } 9129 * ]; 9130 * 9131 * // The `_.matches` iteratee shorthand. 9132 * _.every(users, { 'user': 'barney', 'active': false }); 9133 * // => false 9134 * 9135 * // The `_.matchesProperty` iteratee shorthand. 9136 * _.every(users, ['active', false]); 9137 * // => true 9138 * 9139 * // The `_.property` iteratee shorthand. 9140 * _.every(users, 'active'); 9141 * // => false 9142 */ 9143 function every(collection, predicate, guard) { 9144 var func = isArray(collection) ? arrayEvery : baseEvery; 9145 if (guard && isIterateeCall(collection, predicate, guard)) { 9146 predicate = undefined; 9147 } 9148 return func(collection, getIteratee(predicate, 3)); 9149 } 9150 9151 /** 9152 * Iterates over elements of `collection`, returning an array of all elements 9153 * `predicate` returns truthy for. The predicate is invoked with three 9154 * arguments: (value, index|key, collection). 9155 * 9156 * **Note:** Unlike `_.remove`, this method returns a new array. 9157 * 9158 * @static 9159 * @memberOf _ 9160 * @since 0.1.0 9161 * @category Collection 9162 * @param {Array|Object} collection The collection to iterate over. 9163 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9164 * @returns {Array} Returns the new filtered array. 9165 * @see _.reject 9166 * @example 9167 * 9168 * var users = [ 9169 * { 'user': 'barney', 'age': 36, 'active': true }, 9170 * { 'user': 'fred', 'age': 40, 'active': false } 9171 * ]; 9172 * 9173 * _.filter(users, function(o) { return !o.active; }); 9174 * // => objects for ['fred'] 9175 * 9176 * // The `_.matches` iteratee shorthand. 9177 * _.filter(users, { 'age': 36, 'active': true }); 9178 * // => objects for ['barney'] 9179 * 9180 * // The `_.matchesProperty` iteratee shorthand. 9181 * _.filter(users, ['active', false]); 9182 * // => objects for ['fred'] 9183 * 9184 * // The `_.property` iteratee shorthand. 9185 * _.filter(users, 'active'); 9186 * // => objects for ['barney'] 9187 */ 9188 function filter(collection, predicate) { 9189 var func = isArray(collection) ? arrayFilter : baseFilter; 9190 return func(collection, getIteratee(predicate, 3)); 9191 } 9192 9193 /** 9194 * Iterates over elements of `collection`, returning the first element 9195 * `predicate` returns truthy for. The predicate is invoked with three 9196 * arguments: (value, index|key, collection). 9197 * 9198 * @static 9199 * @memberOf _ 9200 * @since 0.1.0 9201 * @category Collection 9202 * @param {Array|Object} collection The collection to inspect. 9203 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9204 * @param {number} [fromIndex=0] The index to search from. 9205 * @returns {*} Returns the matched element, else `undefined`. 9206 * @example 9207 * 9208 * var users = [ 9209 * { 'user': 'barney', 'age': 36, 'active': true }, 9210 * { 'user': 'fred', 'age': 40, 'active': false }, 9211 * { 'user': 'pebbles', 'age': 1, 'active': true } 9212 * ]; 9213 * 9214 * _.find(users, function(o) { return o.age < 40; }); 9215 * // => object for 'barney' 9216 * 9217 * // The `_.matches` iteratee shorthand. 9218 * _.find(users, { 'age': 1, 'active': true }); 9219 * // => object for 'pebbles' 9220 * 9221 * // The `_.matchesProperty` iteratee shorthand. 9222 * _.find(users, ['active', false]); 9223 * // => object for 'fred' 9224 * 9225 * // The `_.property` iteratee shorthand. 9226 * _.find(users, 'active'); 9227 * // => object for 'barney' 9228 */ 9229 var find = createFind(findIndex); 9230 9231 /** 9232 * This method is like `_.find` except that it iterates over elements of 9233 * `collection` from right to left. 9234 * 9235 * @static 9236 * @memberOf _ 9237 * @since 2.0.0 9238 * @category Collection 9239 * @param {Array|Object} collection The collection to inspect. 9240 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9241 * @param {number} [fromIndex=collection.length-1] The index to search from. 9242 * @returns {*} Returns the matched element, else `undefined`. 9243 * @example 9244 * 9245 * _.findLast([1, 2, 3, 4], function(n) { 9246 * return n % 2 == 1; 9247 * }); 9248 * // => 3 9249 */ 9250 var findLast = createFind(findLastIndex); 9251 9252 /** 9253 * Creates a flattened array of values by running each element in `collection` 9254 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 9255 * with three arguments: (value, index|key, collection). 9256 * 9257 * @static 9258 * @memberOf _ 9259 * @since 4.0.0 9260 * @category Collection 9261 * @param {Array|Object} collection The collection to iterate over. 9262 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9263 * @returns {Array} Returns the new flattened array.
vendor: 3,950 bytes, lines 9264-9387
9264 * @example 9265 * 9266 * function duplicate(n) { 9267 * return [n, n]; 9268 * } 9269 * 9270 * _.flatMap([1, 2], duplicate); 9271 * // => [1, 1, 2, 2] 9272 */ 9273 function flatMap(collection, iteratee) { 9274 return baseFlatten(map(collection, iteratee), 1); 9275 } 9276 9277 /** 9278 * This method is like `_.flatMap` except that it recursively flattens the 9279 * mapped results. 9280 * 9281 * @static 9282 * @memberOf _ 9283 * @since 4.7.0 9284 * @category Collection 9285 * @param {Array|Object} collection The collection to iterate over. 9286 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9287 * @returns {Array} Returns the new flattened array. 9288 * @example 9289 * 9290 * function duplicate(n) { 9291 * return [[[n, n]]]; 9292 * } 9293 * 9294 * _.flatMapDeep([1, 2], duplicate); 9295 * // => [1, 1, 2, 2] 9296 */ 9297 function flatMapDeep(collection, iteratee) { 9298 return baseFlatten(map(collection, iteratee), INFINITY); 9299 } 9300 9301 /** 9302 * This method is like `_.flatMap` except that it recursively flattens the 9303 * mapped results up to `depth` times. 9304 * 9305 * @static 9306 * @memberOf _ 9307 * @since 4.7.0 9308 * @category Collection 9309 * @param {Array|Object} collection The collection to iterate over. 9310 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9311 * @param {number} [depth=1] The maximum recursion depth. 9312 * @returns {Array} Returns the new flattened array. 9313 * @example 9314 * 9315 * function duplicate(n) { 9316 * return [[[n, n]]]; 9317 * } 9318 * 9319 * _.flatMapDepth([1, 2], duplicate, 2); 9320 * // => [[1, 1], [2, 2]] 9321 */ 9322 function flatMapDepth(collection, iteratee, depth) { 9323 depth = depth === undefined ? 1 : toInteger(depth); 9324 return baseFlatten(map(collection, iteratee), depth); 9325 } 9326 9327 /** 9328 * Iterates over elements of `collection` and invokes `iteratee` for each element. 9329 * The iteratee is invoked with three arguments: (value, index|key, collection). 9330 * Iteratee functions may exit iteration early by explicitly returning `false`. 9331 * 9332 * **Note:** As with other "Collections" methods, objects with a "length" 9333 * property are iterated like arrays. To avoid this behavior use `_.forIn` 9334 * or `_.forOwn` for object iteration. 9335 * 9336 * @static 9337 * @memberOf _ 9338 * @since 0.1.0 9339 * @alias each 9340 * @category Collection 9341 * @param {Array|Object} collection The collection to iterate over. 9342 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9343 * @returns {Array|Object} Returns `collection`. 9344 * @see _.forEachRight 9345 * @example 9346 * 9347 * _.forEach([1, 2], function(value) { 9348 * console.log(value); 9349 * }); 9350 * // => Logs `1` then `2`. 9351 * 9352 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 9353 * console.log(key); 9354 * }); 9355 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 9356 */ 9357 function forEach(collection, iteratee) { 9358 var func = isArray(collection) ? arrayEach : baseEach; 9359 return func(collection, getIteratee(iteratee, 3)); 9360 } 9361 9362 /** 9363 * This method is like `_.forEach` except that it iterates over elements of 9364 * `collection` from right to left. 9365 * 9366 * @static 9367 * @memberOf _ 9368 * @since 2.0.0 9369 * @alias eachRight 9370 * @category Collection 9371 * @param {Array|Object} collection The collection to iterate over. 9372 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9373 * @returns {Array|Object} Returns `collection`. 9374 * @see _.forEach 9375 * @example 9376 * 9377 * _.forEachRight([1, 2], function(value) { 9378 * console.log(value); 9379 * }); 9380 * // => Logs `2` then `1`. 9381 */ 9382 function forEachRight(collection, iteratee) { 9383 var func = isArray(collection) ? arrayEachRight : baseEachRight; 9384 return func(collection, getIteratee(iteratee, 3)); 9385 } 9386 9387 /**
vendor: 4,136 bytes, lines 9388-9495
9388 * Creates an object composed of keys generated from the results of running 9389 * each element of `collection` thru `iteratee`. The order of grouped values 9390 * is determined by the order they occur in `collection`. The corresponding 9391 * value of each key is an array of elements responsible for generating the 9392 * key. The iteratee is invoked with one argument: (value). 9393 * 9394 * @static 9395 * @memberOf _ 9396 * @since 0.1.0 9397 * @category Collection 9398 * @param {Array|Object} collection The collection to iterate over. 9399 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 9400 * @returns {Object} Returns the composed aggregate object. 9401 * @example 9402 * 9403 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 9404 * // => { '4': [4.2], '6': [6.1, 6.3] } 9405 * 9406 * // The `_.property` iteratee shorthand. 9407 * _.groupBy(['one', 'two', 'three'], 'length'); 9408 * // => { '3': ['one', 'two'], '5': ['three'] } 9409 */ 9410 var groupBy = createAggregator(function(result, value, key) { 9411 if (hasOwnProperty.call(result, key)) { 9412 result[key].push(value); 9413 } else { 9414 baseAssignValue(result, key, [value]); 9415 } 9416 }); 9417 9418 /** 9419 * Checks if `value` is in `collection`. If `collection` is a string, it's 9420 * checked for a substring of `value`, otherwise 9421 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9422 * is used for equality comparisons. If `fromIndex` is negative, it's used as 9423 * the offset from the end of `collection`. 9424 * 9425 * @static 9426 * @memberOf _ 9427 * @since 0.1.0 9428 * @category Collection 9429 * @param {Array|Object|string} collection The collection to inspect. 9430 * @param {*} value The value to search for. 9431 * @param {number} [fromIndex=0] The index to search from. 9432 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 9433 * @returns {boolean} Returns `true` if `value` is found, else `false`. 9434 * @example 9435 * 9436 * _.includes([1, 2, 3], 1); 9437 * // => true 9438 * 9439 * _.includes([1, 2, 3], 1, 2); 9440 * // => false 9441 * 9442 * _.includes({ 'a': 1, 'b': 2 }, 1); 9443 * // => true 9444 * 9445 * _.includes('abcd', 'bc'); 9446 * // => true 9447 */ 9448 function includes(collection, value, fromIndex, guard) { 9449 collection = isArrayLike(collection) ? collection : values(collection); 9450 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 9451 9452 var length = collection.length; 9453 if (fromIndex < 0) { 9454 fromIndex = nativeMax(length + fromIndex, 0); 9455 } 9456 return isString(collection) 9457 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 9458 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 9459 } 9460 9461 /** 9462 * Invokes the method at `path` of each element in `collection`, returning 9463 * an array of the results of each invoked method. Any additional arguments 9464 * are provided to each invoked method. If `path` is a function, it's invoked 9465 * for, and `this` bound to, each element in `collection`. 9466 * 9467 * @static 9468 * @memberOf _ 9469 * @since 4.0.0 9470 * @category Collection 9471 * @param {Array|Object} collection The collection to iterate over. 9472 * @param {Array|Function|string} path The path of the method to invoke or 9473 * the function invoked per iteration. 9474 * @param {...*} [args] The arguments to invoke each method with. 9475 * @returns {Array} Returns the array of results. 9476 * @example 9477 * 9478 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 9479 * // => [[1, 5, 7], [1, 2, 3]] 9480 * 9481 * _.invokeMap([123, 456], String.prototype.split, ''); 9482 * // => [['1', '2', '3'], ['4', '5', '6']] 9483 */ 9484 var invokeMap = baseRest(function(collection, path, args) { 9485 var index = -1, 9486 isFunc = typeof path == 'function', 9487 result = isArrayLike(collection) ? Array(collection.length) : []; 9488 9489 baseEach(collection, function(value) { 9490 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 9491 }); 9492 return result; 9493 }); 9494 9495 /**
vendor: 15,265 bytes, lines 9496-9930
9496 * Creates an object composed of keys generated from the results of running 9497 * each element of `collection` thru `iteratee`. The corresponding value of 9498 * each key is the last element responsible for generating the key. The 9499 * iteratee is invoked with one argument: (value). 9500 * 9501 * @static 9502 * @memberOf _ 9503 * @since 4.0.0 9504 * @category Collection 9505 * @param {Array|Object} collection The collection to iterate over. 9506 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 9507 * @returns {Object} Returns the composed aggregate object. 9508 * @example 9509 * 9510 * var array = [ 9511 * { 'dir': 'left', 'code': 97 }, 9512 * { 'dir': 'right', 'code': 100 } 9513 * ]; 9514 * 9515 * _.keyBy(array, function(o) { 9516 * return String.fromCharCode(o.code); 9517 * }); 9518 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 9519 * 9520 * _.keyBy(array, 'dir'); 9521 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 9522 */ 9523 var keyBy = createAggregator(function(result, value, key) { 9524 baseAssignValue(result, key, value); 9525 }); 9526 9527 /** 9528 * Creates an array of values by running each element in `collection` thru 9529 * `iteratee`. The iteratee is invoked with three arguments: 9530 * (value, index|key, collection). 9531 * 9532 * Many lodash methods are guarded to work as iteratees for methods like 9533 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 9534 * 9535 * The guarded methods are: 9536 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 9537 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 9538 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 9539 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 9540 * 9541 * @static 9542 * @memberOf _ 9543 * @since 0.1.0 9544 * @category Collection 9545 * @param {Array|Object} collection The collection to iterate over. 9546 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9547 * @returns {Array} Returns the new mapped array. 9548 * @example 9549 * 9550 * function square(n) { 9551 * return n * n; 9552 * } 9553 * 9554 * _.map([4, 8], square); 9555 * // => [16, 64] 9556 * 9557 * _.map({ 'a': 4, 'b': 8 }, square); 9558 * // => [16, 64] (iteration order is not guaranteed) 9559 * 9560 * var users = [ 9561 * { 'user': 'barney' }, 9562 * { 'user': 'fred' } 9563 * ]; 9564 * 9565 * // The `_.property` iteratee shorthand. 9566 * _.map(users, 'user'); 9567 * // => ['barney', 'fred'] 9568 */ 9569 function map(collection, iteratee) { 9570 var func = isArray(collection) ? arrayMap : baseMap; 9571 return func(collection, getIteratee(iteratee, 3)); 9572 } 9573 9574 /** 9575 * This method is like `_.sortBy` except that it allows specifying the sort 9576 * orders of the iteratees to sort by. If `orders` is unspecified, all values 9577 * are sorted in ascending order. Otherwise, specify an order of "desc" for 9578 * descending or "asc" for ascending sort order of corresponding values. 9579 * 9580 * @static 9581 * @memberOf _ 9582 * @since 4.0.0 9583 * @category Collection 9584 * @param {Array|Object} collection The collection to iterate over. 9585 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 9586 * The iteratees to sort by. 9587 * @param {string[]} [orders] The sort orders of `iteratees`. 9588 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 9589 * @returns {Array} Returns the new sorted array. 9590 * @example 9591 * 9592 * var users = [ 9593 * { 'user': 'fred', 'age': 48 }, 9594 * { 'user': 'barney', 'age': 34 }, 9595 * { 'user': 'fred', 'age': 40 }, 9596 * { 'user': 'barney', 'age': 36 } 9597 * ]; 9598 * 9599 * // Sort by `user` in ascending order and by `age` in descending order. 9600 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 9601 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 9602 */ 9603 function orderBy(collection, iteratees, orders, guard) { 9604 if (collection == null) { 9605 return []; 9606 } 9607 if (!isArray(iteratees)) { 9608 iteratees = iteratees == null ? [] : [iteratees]; 9609 } 9610 orders = guard ? undefined : orders; 9611 if (!isArray(orders)) { 9612 orders = orders == null ? [] : [orders]; 9613 } 9614 return baseOrderBy(collection, iteratees, orders); 9615 } 9616 9617 /** 9618 * Creates an array of elements split into two groups, the first of which 9619 * contains elements `predicate` returns truthy for, the second of which 9620 * contains elements `predicate` returns falsey for. The predicate is 9621 * invoked with one argument: (value). 9622 * 9623 * @static 9624 * @memberOf _ 9625 * @since 3.0.0 9626 * @category Collection 9627 * @param {Array|Object} collection The collection to iterate over. 9628 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9629 * @returns {Array} Returns the array of grouped elements. 9630 * @example 9631 * 9632 * var users = [ 9633 * { 'user': 'barney', 'age': 36, 'active': false }, 9634 * { 'user': 'fred', 'age': 40, 'active': true }, 9635 * { 'user': 'pebbles', 'age': 1, 'active': false } 9636 * ]; 9637 * 9638 * _.partition(users, function(o) { return o.active; }); 9639 * // => objects for [['fred'], ['barney', 'pebbles']] 9640 * 9641 * // The `_.matches` iteratee shorthand. 9642 * _.partition(users, { 'age': 1, 'active': false }); 9643 * // => objects for [['pebbles'], ['barney', 'fred']] 9644 * 9645 * // The `_.matchesProperty` iteratee shorthand. 9646 * _.partition(users, ['active', false]); 9647 * // => objects for [['barney', 'pebbles'], ['fred']] 9648 * 9649 * // The `_.property` iteratee shorthand. 9650 * _.partition(users, 'active'); 9651 * // => objects for [['fred'], ['barney', 'pebbles']] 9652 */ 9653 var partition = createAggregator(function(result, value, key) { 9654 result[key ? 0 : 1].push(value); 9655 }, function() { return [[], []]; }); 9656 9657 /** 9658 * Reduces `collection` to a value which is the accumulated result of running 9659 * each element in `collection` thru `iteratee`, where each successive 9660 * invocation is supplied the return value of the previous. If `accumulator` 9661 * is not given, the first element of `collection` is used as the initial 9662 * value. The iteratee is invoked with four arguments: 9663 * (accumulator, value, index|key, collection). 9664 * 9665 * Many lodash methods are guarded to work as iteratees for methods like 9666 * `_.reduce`, `_.reduceRight`, and `_.transform`. 9667 * 9668 * The guarded methods are: 9669 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 9670 * and `sortBy` 9671 * 9672 * @static 9673 * @memberOf _ 9674 * @since 0.1.0 9675 * @category Collection 9676 * @param {Array|Object} collection The collection to iterate over. 9677 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9678 * @param {*} [accumulator] The initial value. 9679 * @returns {*} Returns the accumulated value. 9680 * @see _.reduceRight 9681 * @example 9682 * 9683 * _.reduce([1, 2], function(sum, n) { 9684 * return sum + n; 9685 * }, 0); 9686 * // => 3 9687 * 9688 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 9689 * (result[value] || (result[value] = [])).push(key); 9690 * return result; 9691 * }, {}); 9692 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 9693 */ 9694 function reduce(collection, iteratee, accumulator) { 9695 var func = isArray(collection) ? arrayReduce : baseReduce, 9696 initAccum = arguments.length < 3; 9697 9698 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 9699 } 9700 9701 /** 9702 * This method is like `_.reduce` except that it iterates over elements of 9703 * `collection` from right to left. 9704 * 9705 * @static 9706 * @memberOf _ 9707 * @since 0.1.0 9708 * @category Collection 9709 * @param {Array|Object} collection The collection to iterate over. 9710 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 9711 * @param {*} [accumulator] The initial value. 9712 * @returns {*} Returns the accumulated value. 9713 * @see _.reduce 9714 * @example 9715 * 9716 * var array = [[0, 1], [2, 3], [4, 5]]; 9717 * 9718 * _.reduceRight(array, function(flattened, other) { 9719 * return flattened.concat(other); 9720 * }, []); 9721 * // => [4, 5, 2, 3, 0, 1] 9722 */ 9723 function reduceRight(collection, iteratee, accumulator) { 9724 var func = isArray(collection) ? arrayReduceRight : baseReduce, 9725 initAccum = arguments.length < 3; 9726 9727 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 9728 } 9729 9730 /** 9731 * The opposite of `_.filter`; this method returns the elements of `collection` 9732 * that `predicate` does **not** return truthy for. 9733 * 9734 * @static 9735 * @memberOf _ 9736 * @since 0.1.0 9737 * @category Collection 9738 * @param {Array|Object} collection The collection to iterate over. 9739 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9740 * @returns {Array} Returns the new filtered array. 9741 * @see _.filter 9742 * @example 9743 * 9744 * var users = [ 9745 * { 'user': 'barney', 'age': 36, 'active': false }, 9746 * { 'user': 'fred', 'age': 40, 'active': true } 9747 * ]; 9748 * 9749 * _.reject(users, function(o) { return !o.active; }); 9750 * // => objects for ['fred'] 9751 * 9752 * // The `_.matches` iteratee shorthand. 9753 * _.reject(users, { 'age': 40, 'active': true }); 9754 * // => objects for ['barney'] 9755 * 9756 * // The `_.matchesProperty` iteratee shorthand. 9757 * _.reject(users, ['active', false]); 9758 * // => objects for ['fred'] 9759 * 9760 * // The `_.property` iteratee shorthand. 9761 * _.reject(users, 'active'); 9762 * // => objects for ['barney'] 9763 */ 9764 function reject(collection, predicate) { 9765 var func = isArray(collection) ? arrayFilter : baseFilter; 9766 return func(collection, negate(getIteratee(predicate, 3))); 9767 } 9768 9769 /** 9770 * Gets a random element from `collection`. 9771 * 9772 * @static 9773 * @memberOf _ 9774 * @since 2.0.0 9775 * @category Collection 9776 * @param {Array|Object} collection The collection to sample. 9777 * @returns {*} Returns the random element. 9778 * @example 9779 * 9780 * _.sample([1, 2, 3, 4]); 9781 * // => 2 9782 */ 9783 function sample(collection) { 9784 var func = isArray(collection) ? arraySample : baseSample; 9785 return func(collection); 9786 } 9787 9788 /** 9789 * Gets `n` random elements at unique keys from `collection` up to the 9790 * size of `collection`. 9791 * 9792 * @static 9793 * @memberOf _ 9794 * @since 4.0.0 9795 * @category Collection 9796 * @param {Array|Object} collection The collection to sample. 9797 * @param {number} [n=1] The number of elements to sample. 9798 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9799 * @returns {Array} Returns the random elements. 9800 * @example 9801 * 9802 * _.sampleSize([1, 2, 3], 2); 9803 * // => [3, 1] 9804 * 9805 * _.sampleSize([1, 2, 3], 4); 9806 * // => [2, 3, 1] 9807 */ 9808 function sampleSize(collection, n, guard) { 9809 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 9810 n = 1; 9811 } else { 9812 n = toInteger(n); 9813 } 9814 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 9815 return func(collection, n); 9816 } 9817 9818 /** 9819 * Creates an array of shuffled values, using a version of the 9820 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 9821 * 9822 * @static 9823 * @memberOf _ 9824 * @since 0.1.0 9825 * @category Collection 9826 * @param {Array|Object} collection The collection to shuffle. 9827 * @returns {Array} Returns the new shuffled array. 9828 * @example 9829 * 9830 * _.shuffle([1, 2, 3, 4]); 9831 * // => [4, 1, 3, 2] 9832 */ 9833 function shuffle(collection) { 9834 var func = isArray(collection) ? arrayShuffle : baseShuffle; 9835 return func(collection); 9836 } 9837 9838 /** 9839 * Gets the size of `collection` by returning its length for array-like 9840 * values or the number of own enumerable string keyed properties for objects. 9841 * 9842 * @static 9843 * @memberOf _ 9844 * @since 0.1.0 9845 * @category Collection 9846 * @param {Array|Object|string} collection The collection to inspect. 9847 * @returns {number} Returns the collection size. 9848 * @example 9849 * 9850 * _.size([1, 2, 3]); 9851 * // => 3 9852 * 9853 * _.size({ 'a': 1, 'b': 2 }); 9854 * // => 2 9855 * 9856 * _.size('pebbles'); 9857 * // => 7 9858 */ 9859 function size(collection) { 9860 if (collection == null) { 9861 return 0; 9862 } 9863 if (isArrayLike(collection)) { 9864 return isString(collection) ? stringSize(collection) : collection.length; 9865 } 9866 var tag = getTag(collection); 9867 if (tag == mapTag || tag == setTag) { 9868 return collection.size; 9869 } 9870 return baseKeys(collection).length; 9871 } 9872 9873 /** 9874 * Checks if `predicate` returns truthy for **any** element of `collection`. 9875 * Iteration is stopped once `predicate` returns truthy. The predicate is 9876 * invoked with three arguments: (value, index|key, collection). 9877 * 9878 * @static 9879 * @memberOf _ 9880 * @since 0.1.0 9881 * @category Collection 9882 * @param {Array|Object} collection The collection to iterate over. 9883 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9884 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9885 * @returns {boolean} Returns `true` if any element passes the predicate check, 9886 * else `false`. 9887 * @example 9888 * 9889 * _.some([null, 0, 'yes', false], Boolean); 9890 * // => true 9891 * 9892 * var users = [ 9893 * { 'user': 'barney', 'active': true }, 9894 * { 'user': 'fred', 'active': false } 9895 * ]; 9896 * 9897 * // The `_.matches` iteratee shorthand. 9898 * _.some(users, { 'user': 'barney', 'active': false }); 9899 * // => false 9900 * 9901 * // The `_.matchesProperty` iteratee shorthand. 9902 * _.some(users, ['active', false]); 9903 * // => true 9904 * 9905 * // The `_.property` iteratee shorthand. 9906 * _.some(users, 'active'); 9907 * // => true 9908 */ 9909 function some(collection, predicate, guard) { 9910 var func = isArray(collection) ? arraySome : baseSome; 9911 if (guard && isIterateeCall(collection, predicate, guard)) { 9912 predicate = undefined; 9913 } 9914 return func(collection, getIteratee(predicate, 3)); 9915 } 9916 9917 /** 9918 * Creates an array of elements, sorted in ascending order by the results of 9919 * running each element in a collection thru each iteratee. This method 9920 * performs a stable sort, that is, it preserves the original sort order of 9921 * equal elements. The iteratees are invoked with one argument: (value). 9922 * 9923 * @static 9924 * @memberOf _ 9925 * @since 0.1.0 9926 * @category Collection 9927 * @param {Array|Object} collection The collection to iterate over. 9928 * @param {...(Function|Function[])} [iteratees=[_.identity]] 9929 * The iteratees to sort by. 9930 * @returns {Array} Returns the new sorted array.
vendor: 6,758 bytes, lines 9931-10133
9931 * @example 9932 * 9933 * var users = [ 9934 * { 'user': 'fred', 'age': 48 }, 9935 * { 'user': 'barney', 'age': 36 }, 9936 * { 'user': 'fred', 'age': 40 }, 9937 * { 'user': 'barney', 'age': 34 } 9938 * ]; 9939 * 9940 * _.sortBy(users, [function(o) { return o.user; }]); 9941 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 9942 * 9943 * _.sortBy(users, ['user', 'age']); 9944 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] 9945 */ 9946 var sortBy = baseRest(function(collection, iteratees) { 9947 if (collection == null) { 9948 return []; 9949 } 9950 var length = iteratees.length; 9951 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 9952 iteratees = []; 9953 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 9954 iteratees = [iteratees[0]]; 9955 } 9956 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 9957 }); 9958 9959 /*------------------------------------------------------------------------*/ 9960 9961 /** 9962 * Gets the timestamp of the number of milliseconds that have elapsed since 9963 * the Unix epoch (1 January 1970 00:00:00 UTC). 9964 * 9965 * @static 9966 * @memberOf _ 9967 * @since 2.4.0 9968 * @category Date 9969 * @returns {number} Returns the timestamp. 9970 * @example 9971 * 9972 * _.defer(function(stamp) { 9973 * console.log(_.now() - stamp); 9974 * }, _.now()); 9975 * // => Logs the number of milliseconds it took for the deferred invocation. 9976 */ 9977 var now = ctxNow || function() { 9978 return root.Date.now(); 9979 }; 9980 9981 /*------------------------------------------------------------------------*/ 9982 9983 /** 9984 * The opposite of `_.before`; this method creates a function that invokes 9985 * `func` once it's called `n` or more times. 9986 * 9987 * @static 9988 * @memberOf _ 9989 * @since 0.1.0 9990 * @category Function 9991 * @param {number} n The number of calls before `func` is invoked. 9992 * @param {Function} func The function to restrict. 9993 * @returns {Function} Returns the new restricted function. 9994 * @example 9995 * 9996 * var saves = ['profile', 'settings']; 9997 * 9998 * var done = _.after(saves.length, function() { 9999 * console.log('done saving!'); 10000 * }); 10001 * 10002 * _.forEach(saves, function(type) { 10003 * asyncSave({ 'type': type, 'complete': done }); 10004 * }); 10005 * // => Logs 'done saving!' after the two async saves have completed. 10006 */ 10007 function after(n, func) { 10008 if (typeof func != 'function') { 10009 throw new TypeError(FUNC_ERROR_TEXT); 10010 } 10011 n = toInteger(n); 10012 return function() { 10013 if (--n < 1) { 10014 return func.apply(this, arguments); 10015 } 10016 }; 10017 } 10018 10019 /** 10020 * Creates a function that invokes `func`, with up to `n` arguments, 10021 * ignoring any additional arguments. 10022 * 10023 * @static 10024 * @memberOf _ 10025 * @since 3.0.0 10026 * @category Function 10027 * @param {Function} func The function to cap arguments for. 10028 * @param {number} [n=func.length] The arity cap. 10029 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10030 * @returns {Function} Returns the new capped function. 10031 * @example 10032 * 10033 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 10034 * // => [6, 8, 10] 10035 */ 10036 function ary(func, n, guard) { 10037 n = guard ? undefined : n; 10038 n = (func && n == null) ? func.length : n; 10039 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 10040 } 10041 10042 /** 10043 * Creates a function that invokes `func`, with the `this` binding and arguments 10044 * of the created function, while it's called less than `n` times. Subsequent 10045 * calls to the created function return the result of the last `func` invocation. 10046 * 10047 * @static 10048 * @memberOf _ 10049 * @since 3.0.0 10050 * @category Function 10051 * @param {number} n The number of calls at which `func` is no longer invoked. 10052 * @param {Function} func The function to restrict. 10053 * @returns {Function} Returns the new restricted function. 10054 * @example 10055 * 10056 * jQuery(element).on('click', _.before(5, addContactToList)); 10057 * // => Allows adding up to 4 contacts to the list. 10058 */ 10059 function before(n, func) { 10060 var result; 10061 if (typeof func != 'function') { 10062 throw new TypeError(FUNC_ERROR_TEXT); 10063 } 10064 n = toInteger(n); 10065 return function() { 10066 if (--n > 0) { 10067 result = func.apply(this, arguments); 10068 } 10069 if (n <= 1) { 10070 func = undefined; 10071 } 10072 return result; 10073 }; 10074 } 10075 10076 /** 10077 * Creates a function that invokes `func` with the `this` binding of `thisArg` 10078 * and `partials` prepended to the arguments it receives. 10079 * 10080 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 10081 * may be used as a placeholder for partially applied arguments. 10082 * 10083 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 10084 * property of bound functions. 10085 * 10086 * @static 10087 * @memberOf _ 10088 * @since 0.1.0 10089 * @category Function 10090 * @param {Function} func The function to bind. 10091 * @param {*} thisArg The `this` binding of `func`. 10092 * @param {...*} [partials] The arguments to be partially applied. 10093 * @returns {Function} Returns the new bound function. 10094 * @example 10095 * 10096 * function greet(greeting, punctuation) { 10097 * return greeting + ' ' + this.user + punctuation; 10098 * } 10099 * 10100 * var object = { 'user': 'fred' }; 10101 * 10102 * var bound = _.bind(greet, object, 'hi'); 10103 * bound('!'); 10104 * // => 'hi fred!' 10105 * 10106 * // Bound with placeholders. 10107 * var bound = _.bind(greet, object, _, '!'); 10108 * bound('hi'); 10109 * // => 'hi fred!' 10110 */ 10111 var bind = baseRest(function(func, thisArg, partials) { 10112 var bitmask = WRAP_BIND_FLAG; 10113 if (partials.length) { 10114 var holders = replaceHolders(partials, getHolder(bind)); 10115 bitmask |= WRAP_PARTIAL_FLAG; 10116 } 10117 return createWrap(func, bitmask, thisArg, partials, holders); 10118 }); 10119 10120 /** 10121 * Creates a function that invokes the method at `object[key]` with `partials` 10122 * prepended to the arguments it receives. 10123 * 10124 * This method differs from `_.bind` by allowing bound functions to reference 10125 * methods that may be redefined or don't yet exist. See 10126 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 10127 * for more details. 10128 * 10129 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 10130 * builds, may be used as a placeholder for partially applied arguments. 10131 * 10132 * @static 10133 * @memberOf _
vendor: 8,388 bytes, lines 10134-10366
10134 * @since 0.10.0 10135 * @category Function 10136 * @param {Object} object The object to invoke the method on. 10137 * @param {string} key The key of the method. 10138 * @param {...*} [partials] The arguments to be partially applied. 10139 * @returns {Function} Returns the new bound function. 10140 * @example 10141 * 10142 * var object = { 10143 * 'user': 'fred', 10144 * 'greet': function(greeting, punctuation) { 10145 * return greeting + ' ' + this.user + punctuation; 10146 * } 10147 * }; 10148 * 10149 * var bound = _.bindKey(object, 'greet', 'hi'); 10150 * bound('!'); 10151 * // => 'hi fred!' 10152 * 10153 * object.greet = function(greeting, punctuation) { 10154 * return greeting + 'ya ' + this.user + punctuation; 10155 * }; 10156 * 10157 * bound('!'); 10158 * // => 'hiya fred!' 10159 * 10160 * // Bound with placeholders. 10161 * var bound = _.bindKey(object, 'greet', _, '!'); 10162 * bound('hi'); 10163 * // => 'hiya fred!' 10164 */ 10165 var bindKey = baseRest(function(object, key, partials) { 10166 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 10167 if (partials.length) { 10168 var holders = replaceHolders(partials, getHolder(bindKey)); 10169 bitmask |= WRAP_PARTIAL_FLAG; 10170 } 10171 return createWrap(key, bitmask, object, partials, holders); 10172 }); 10173 10174 /** 10175 * Creates a function that accepts arguments of `func` and either invokes 10176 * `func` returning its result, if at least `arity` number of arguments have 10177 * been provided, or returns a function that accepts the remaining `func` 10178 * arguments, and so on. The arity of `func` may be specified if `func.length` 10179 * is not sufficient. 10180 * 10181 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 10182 * may be used as a placeholder for provided arguments. 10183 * 10184 * **Note:** This method doesn't set the "length" property of curried functions. 10185 * 10186 * @static 10187 * @memberOf _ 10188 * @since 2.0.0 10189 * @category Function 10190 * @param {Function} func The function to curry. 10191 * @param {number} [arity=func.length] The arity of `func`. 10192 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10193 * @returns {Function} Returns the new curried function. 10194 * @example 10195 * 10196 * var abc = function(a, b, c) { 10197 * return [a, b, c]; 10198 * }; 10199 * 10200 * var curried = _.curry(abc); 10201 * 10202 * curried(1)(2)(3); 10203 * // => [1, 2, 3] 10204 * 10205 * curried(1, 2)(3); 10206 * // => [1, 2, 3] 10207 * 10208 * curried(1, 2, 3); 10209 * // => [1, 2, 3] 10210 * 10211 * // Curried with placeholders. 10212 * curried(1)(_, 3)(2); 10213 * // => [1, 2, 3] 10214 */ 10215 function curry(func, arity, guard) { 10216 arity = guard ? undefined : arity; 10217 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 10218 result.placeholder = curry.placeholder; 10219 return result; 10220 } 10221 10222 /** 10223 * This method is like `_.curry` except that arguments are applied to `func` 10224 * in the manner of `_.partialRight` instead of `_.partial`. 10225 * 10226 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 10227 * builds, may be used as a placeholder for provided arguments. 10228 * 10229 * **Note:** This method doesn't set the "length" property of curried functions. 10230 * 10231 * @static 10232 * @memberOf _ 10233 * @since 3.0.0 10234 * @category Function 10235 * @param {Function} func The function to curry. 10236 * @param {number} [arity=func.length] The arity of `func`. 10237 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10238 * @returns {Function} Returns the new curried function. 10239 * @example 10240 * 10241 * var abc = function(a, b, c) { 10242 * return [a, b, c]; 10243 * }; 10244 * 10245 * var curried = _.curryRight(abc); 10246 * 10247 * curried(3)(2)(1); 10248 * // => [1, 2, 3] 10249 * 10250 * curried(2, 3)(1); 10251 * // => [1, 2, 3] 10252 * 10253 * curried(1, 2, 3); 10254 * // => [1, 2, 3] 10255 * 10256 * // Curried with placeholders. 10257 * curried(3)(1, _)(2); 10258 * // => [1, 2, 3] 10259 */ 10260 function curryRight(func, arity, guard) { 10261 arity = guard ? undefined : arity; 10262 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 10263 result.placeholder = curryRight.placeholder; 10264 return result; 10265 } 10266 10267 /** 10268 * Creates a debounced function that delays invoking `func` until after `wait` 10269 * milliseconds have elapsed since the last time the debounced function was 10270 * invoked. The debounced function comes with a `cancel` method to cancel 10271 * delayed `func` invocations and a `flush` method to immediately invoke them. 10272 * Provide `options` to indicate whether `func` should be invoked on the 10273 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 10274 * with the last arguments provided to the debounced function. Subsequent 10275 * calls to the debounced function return the result of the last `func` 10276 * invocation. 10277 * 10278 * **Note:** If `leading` and `trailing` options are `true`, `func` is 10279 * invoked on the trailing edge of the timeout only if the debounced function 10280 * is invoked more than once during the `wait` timeout. 10281 * 10282 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 10283 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 10284 * 10285 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 10286 * for details over the differences between `_.debounce` and `_.throttle`. 10287 * 10288 * @static 10289 * @memberOf _ 10290 * @since 0.1.0 10291 * @category Function 10292 * @param {Function} func The function to debounce. 10293 * @param {number} [wait=0] The number of milliseconds to delay. 10294 * @param {Object} [options={}] The options object. 10295 * @param {boolean} [options.leading=false] 10296 * Specify invoking on the leading edge of the timeout. 10297 * @param {number} [options.maxWait] 10298 * The maximum time `func` is allowed to be delayed before it's invoked. 10299 * @param {boolean} [options.trailing=true] 10300 * Specify invoking on the trailing edge of the timeout. 10301 * @returns {Function} Returns the new debounced function. 10302 * @example 10303 * 10304 * // Avoid costly calculations while the window size is in flux. 10305 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 10306 * 10307 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 10308 * jQuery(element).on('click', _.debounce(sendMail, 300, { 10309 * 'leading': true, 10310 * 'trailing': false 10311 * })); 10312 * 10313 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 10314 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 10315 * var source = new EventSource('/stream'); 10316 * jQuery(source).on('message', debounced); 10317 * 10318 * // Cancel the trailing debounced invocation. 10319 * jQuery(window).on('popstate', debounced.cancel); 10320 */ 10321 function debounce(func, wait, options) { 10322 var lastArgs, 10323 lastThis, 10324 maxWait, 10325 result, 10326 timerId, 10327 lastCallTime, 10328 lastInvokeTime = 0, 10329 leading = false, 10330 maxing = false, 10331 trailing = true; 10332 10333 if (typeof func != 'function') { 10334 throw new TypeError(FUNC_ERROR_TEXT); 10335 } 10336 wait = toNumber(wait) || 0; 10337 if (isObject(options)) { 10338 leading = !!options.leading; 10339 maxing = 'maxWait' in options; 10340 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 10341 trailing = 'trailing' in options ? !!options.trailing : trailing; 10342 } 10343 10344 function invokeFunc(time) { 10345 var args = lastArgs, 10346 thisArg = lastThis; 10347 10348 lastArgs = lastThis = undefined; 10349 lastInvokeTime = time; 10350 result = func.apply(thisArg, args); 10351 return result; 10352 } 10353 10354 function leadingEdge(time) { 10355 // Reset any `maxWait` timer. 10356 lastInvokeTime = time; 10357 // Start the timer for the trailing edge. 10358 timerId = setTimeout(timerExpired, wait); 10359 // Invoke the leading edge. 10360 return leading ? invokeFunc(time) : result; 10361 } 10362 10363 function remainingWait(time) { 10364 var timeSinceLastCall = time - lastCallTime, 10365 timeSinceLastInvoke = time - lastInvokeTime, 10366
vendor: 1,940 bytes, lines 10366-10428
10366result = wait - timeSinceLastCall; 10367 10368 return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; 10369 } 10370 10371 function shouldInvoke(time) { 10372 var timeSinceLastCall = time - lastCallTime, 10373 timeSinceLastInvoke = time - lastInvokeTime; 10374 10375 // Either this is the first call, activity has stopped and we're at the 10376 // trailing edge, the system time has gone backwards and we're treating 10377 // it as the trailing edge, or we've hit the `maxWait` limit. 10378 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 10379 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 10380 } 10381 10382 function timerExpired() { 10383 var time = now(); 10384 if (shouldInvoke(time)) { 10385 return trailingEdge(time); 10386 } 10387 // Restart the timer. 10388 timerId = setTimeout(timerExpired, remainingWait(time)); 10389 } 10390 10391 function trailingEdge(time) { 10392 timerId = undefined; 10393 10394 // Only invoke if we have `lastArgs` which means `func` has been 10395 // debounced at least once. 10396 if (trailing && lastArgs) { 10397 return invokeFunc(time); 10398 } 10399 lastArgs = lastThis = undefined; 10400 return result; 10401 } 10402 10403 function cancel() { 10404 if (timerId !== undefined) { 10405 clearTimeout(timerId); 10406 } 10407 lastInvokeTime = 0; 10408 lastArgs = lastCallTime = lastThis = timerId = undefined; 10409 } 10410 10411 function flush() { 10412 return timerId === undefined ? result : trailingEdge(now()); 10413 } 10414 10415 function debounced() { 10416 var time = now(), 10417 isInvoking = shouldInvoke(time); 10418 10419 lastArgs = arguments; 10420 lastThis = this; 10421 lastCallTime = time; 10422 10423 if (isInvoking) { 10424 if (timerId === undefined) { 10425 return leadingEdge(lastCallTime); 10426 } 10427 if (maxing) { 10428 // Handle invocations in a tight loop.
vendor: 36,079 bytes, lines 10428-11607
10428 10429 timerId = setTimeout(timerExpired, wait); 10430 return invokeFunc(lastCallTime); 10431 } 10432 } 10433 if (timerId === undefined) { 10434 timerId = setTimeout(timerExpired, wait); 10435 } 10436 return result; 10437 } 10438 debounced.cancel = cancel; 10439 debounced.flush = flush; 10440 return debounced; 10441 } 10442 10443 /** 10444 * Defers invoking the `func` until the current call stack has cleared. Any 10445 * additional arguments are provided to `func` when it's invoked. 10446 * 10447 * @static 10448 * @memberOf _ 10449 * @since 0.1.0 10450 * @category Function 10451 * @param {Function} func The function to defer. 10452 * @param {...*} [args] The arguments to invoke `func` with. 10453 * @returns {number} Returns the timer id. 10454 * @example 10455 * 10456 * _.defer(function(text) { 10457 * console.log(text); 10458 * }, 'deferred'); 10459 * // => Logs 'deferred' after one millisecond. 10460 */ 10461 var defer = baseRest(function(func, args) { 10462 return baseDelay(func, 1, args); 10463 }); 10464 10465 /** 10466 * Invokes `func` after `wait` milliseconds. Any additional arguments are 10467 * provided to `func` when it's invoked. 10468 * 10469 * @static 10470 * @memberOf _ 10471 * @since 0.1.0 10472 * @category Function 10473 * @param {Function} func The function to delay. 10474 * @param {number} wait The number of milliseconds to delay invocation. 10475 * @param {...*} [args] The arguments to invoke `func` with. 10476 * @returns {number} Returns the timer id. 10477 * @example 10478 * 10479 * _.delay(function(text) { 10480 * console.log(text); 10481 * }, 1000, 'later'); 10482 * // => Logs 'later' after one second. 10483 */ 10484 var delay = baseRest(function(func, wait, args) { 10485 return baseDelay(func, toNumber(wait) || 0, args); 10486 }); 10487 10488 /** 10489 * Creates a function that invokes `func` with arguments reversed. 10490 * 10491 * @static 10492 * @memberOf _ 10493 * @since 4.0.0 10494 * @category Function 10495 * @param {Function} func The function to flip arguments for. 10496 * @returns {Function} Returns the new flipped function. 10497 * @example 10498 * 10499 * var flipped = _.flip(function() { 10500 * return _.toArray(arguments); 10501 * }); 10502 * 10503 * flipped('a', 'b', 'c', 'd'); 10504 * // => ['d', 'c', 'b', 'a'] 10505 */ 10506 function flip(func) { 10507 return createWrap(func, WRAP_FLIP_FLAG); 10508 } 10509 10510 /** 10511 * Creates a function that memoizes the result of `func`. If `resolver` is 10512 * provided, it determines the cache key for storing the result based on the 10513 * arguments provided to the memoized function. By default, the first argument 10514 * provided to the memoized function is used as the map cache key. The `func` 10515 * is invoked with the `this` binding of the memoized function. 10516 * 10517 * **Note:** The cache is exposed as the `cache` property on the memoized 10518 * function. Its creation may be customized by replacing the `_.memoize.Cache` 10519 * constructor with one whose instances implement the 10520 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 10521 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 10522 * 10523 * @static 10524 * @memberOf _ 10525 * @since 0.1.0 10526 * @category Function 10527 * @param {Function} func The function to have its output memoized. 10528 * @param {Function} [resolver] The function to resolve the cache key. 10529 * @returns {Function} Returns the new memoized function. 10530 * @example 10531 * 10532 * var object = { 'a': 1, 'b': 2 }; 10533 * var other = { 'c': 3, 'd': 4 }; 10534 * 10535 * var values = _.memoize(_.values); 10536 * values(object); 10537 * // => [1, 2] 10538 * 10539 * values(other); 10540 * // => [3, 4] 10541 * 10542 * object.a = 2; 10543 * values(object); 10544 * // => [1, 2] 10545 * 10546 * // Modify the result cache. 10547 * values.cache.set(object, ['a', 'b']); 10548 * values(object); 10549 * // => ['a', 'b'] 10550 * 10551 * // Replace `_.memoize.Cache`. 10552 * _.memoize.Cache = WeakMap; 10553 */ 10554 function memoize(func, resolver) { 10555 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 10556 throw new TypeError(FUNC_ERROR_TEXT); 10557 } 10558 var memoized = function() { 10559 var args = arguments, 10560 key = resolver ? resolver.apply(this, args) : args[0], 10561 cache = memoized.cache; 10562 10563 if (cache.has(key)) { 10564 return cache.get(key); 10565 } 10566 var result = func.apply(this, args); 10567 memoized.cache = cache.set(key, result) || cache; 10568 return result; 10569 }; 10570 memoized.cache = new (memoize.Cache || MapCache); 10571 return memoized; 10572 } 10573 10574 // Expose `MapCache`. 10575 memoize.Cache = MapCache; 10576 10577 /** 10578 * Creates a function that negates the result of the predicate `func`. The 10579 * `func` predicate is invoked with the `this` binding and arguments of the 10580 * created function. 10581 * 10582 * @static 10583 * @memberOf _ 10584 * @since 3.0.0 10585 * @category Function 10586 * @param {Function} predicate The predicate to negate. 10587 * @returns {Function} Returns the new negated function. 10588 * @example 10589 * 10590 * function isEven(n) { 10591 * return n % 2 == 0; 10592 * } 10593 * 10594 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 10595 * // => [1, 3, 5] 10596 */ 10597 function negate(predicate) { 10598 if (typeof predicate != 'function') { 10599 throw new TypeError(FUNC_ERROR_TEXT); 10600 } 10601 return function() { 10602 var args = arguments; 10603 switch (args.length) { 10604 case 0: return !predicate.call(this); 10605 case 1: return !predicate.call(this, args[0]); 10606 case 2: return !predicate.call(this, args[0], args[1]); 10607 case 3: return !predicate.call(this, args[0], args[1], args[2]); 10608 } 10609 return !predicate.apply(this, args); 10610 }; 10611 } 10612 10613 /** 10614 * Creates a function that is restricted to invoking `func` once. Repeat calls 10615 * to the function return the value of the first invocation. The `func` is 10616 * invoked with the `this` binding and arguments of the created function. 10617 * 10618 * @static 10619 * @memberOf _ 10620 * @since 0.1.0 10621 * @category Function 10622 * @param {Function} func The function to restrict. 10623 * @returns {Function} Returns the new restricted function. 10624 * @example 10625 * 10626 * var initialize = _.once(createApplication); 10627 * initialize(); 10628 * initialize(); 10629 * // => `createApplication` is invoked once 10630 */ 10631 function once(func) { 10632 return before(2, func); 10633 } 10634 10635 /** 10636 * Creates a function that invokes `func` with its arguments transformed. 10637 * 10638 * @static 10639 * @since 4.0.0 10640 * @memberOf _ 10641 * @category Function 10642 * @param {Function} func The function to wrap. 10643 * @param {...(Function|Function[])} [transforms=[_.identity]] 10644 * The argument transforms. 10645 * @returns {Function} Returns the new function. 10646 * @example 10647 * 10648 * function doubled(n) { 10649 * return n * 2; 10650 * } 10651 * 10652 * function square(n) { 10653 * return n * n; 10654 * } 10655 * 10656 * var func = _.overArgs(function(x, y) { 10657 * return [x, y]; 10658 * }, [square, doubled]); 10659 * 10660 * func(9, 3); 10661 * // => [81, 6] 10662 * 10663 * func(10, 5); 10664 * // => [100, 10] 10665 */ 10666 var overArgs = castRest(function(func, transforms) { 10667 transforms = (transforms.length == 1 && isArray(transforms[0])) 10668 ? arrayMap(transforms[0], baseUnary(getIteratee())) 10669 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 10670 10671 var funcsLength = transforms.length; 10672 return baseRest(function(args) { 10673 var index = -1, 10674 length = nativeMin(args.length, funcsLength); 10675 10676 while (++index < length) { 10677 args[index] = transforms[index].call(this, args[index]); 10678 } 10679 return apply(func, this, args); 10680 }); 10681 }); 10682 10683 /** 10684 * Creates a function that invokes `func` with `partials` prepended to the 10685 * arguments it receives. This method is like `_.bind` except it does **not** 10686 * alter the `this` binding. 10687 * 10688 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 10689 * builds, may be used as a placeholder for partially applied arguments. 10690 * 10691 * **Note:** This method doesn't set the "length" property of partially 10692 * applied functions. 10693 * 10694 * @static 10695 * @memberOf _ 10696 * @since 0.2.0 10697 * @category Function 10698 * @param {Function} func The function to partially apply arguments to. 10699 * @param {...*} [partials] The arguments to be partially applied. 10700 * @returns {Function} Returns the new partially applied function. 10701 * @example 10702 * 10703 * function greet(greeting, name) { 10704 * return greeting + ' ' + name; 10705 * } 10706 * 10707 * var sayHelloTo = _.partial(greet, 'hello'); 10708 * sayHelloTo('fred'); 10709 * // => 'hello fred' 10710 * 10711 * // Partially applied with placeholders. 10712 * var greetFred = _.partial(greet, _, 'fred'); 10713 * greetFred('hi'); 10714 * // => 'hi fred' 10715 */ 10716 var partial = baseRest(function(func, partials) { 10717 var holders = replaceHolders(partials, getHolder(partial)); 10718 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 10719 }); 10720 10721 /** 10722 * This method is like `_.partial` except that partially applied arguments 10723 * are appended to the arguments it receives. 10724 * 10725 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 10726 * builds, may be used as a placeholder for partially applied arguments. 10727 * 10728 * **Note:** This method doesn't set the "length" property of partially 10729 * applied functions. 10730 * 10731 * @static 10732 * @memberOf _ 10733 * @since 1.0.0 10734 * @category Function 10735 * @param {Function} func The function to partially apply arguments to. 10736 * @param {...*} [partials] The arguments to be partially applied. 10737 * @returns {Function} Returns the new partially applied function. 10738 * @example 10739 * 10740 * function greet(greeting, name) { 10741 * return greeting + ' ' + name; 10742 * } 10743 * 10744 * var greetFred = _.partialRight(greet, 'fred'); 10745 * greetFred('hi'); 10746 * // => 'hi fred' 10747 * 10748 * // Partially applied with placeholders. 10749 * var sayHelloTo = _.partialRight(greet, 'hello', _); 10750 * sayHelloTo('fred'); 10751 * // => 'hello fred' 10752 */ 10753 var partialRight = baseRest(function(func, partials) { 10754 var holders = replaceHolders(partials, getHolder(partialRight)); 10755 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 10756 }); 10757 10758 /** 10759 * Creates a function that invokes `func` with arguments arranged according 10760 * to the specified `indexes` where the argument value at the first index is 10761 * provided as the first argument, the argument value at the second index is 10762 * provided as the second argument, and so on. 10763 * 10764 * @static 10765 * @memberOf _ 10766 * @since 3.0.0 10767 * @category Function 10768 * @param {Function} func The function to rearrange arguments for. 10769 * @param {...(number|number[])} indexes The arranged argument indexes. 10770 * @returns {Function} Returns the new function. 10771 * @example 10772 * 10773 * var rearged = _.rearg(function(a, b, c) { 10774 * return [a, b, c]; 10775 * }, [2, 0, 1]); 10776 * 10777 * rearged('b', 'c', 'a') 10778 * // => ['a', 'b', 'c'] 10779 */ 10780 var rearg = flatRest(function(func, indexes) { 10781 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 10782 }); 10783 10784 /** 10785 * Creates a function that invokes `func` with the `this` binding of the 10786 * created function and arguments from `start` and beyond provided as 10787 * an array. 10788 * 10789 * **Note:** This method is based on the 10790 * [rest parameter](https://mdn.io/rest_parameters). 10791 * 10792 * @static 10793 * @memberOf _ 10794 * @since 4.0.0 10795 * @category Function 10796 * @param {Function} func The function to apply a rest parameter to. 10797 * @param {number} [start=func.length-1] The start position of the rest parameter. 10798 * @returns {Function} Returns the new function. 10799 * @example 10800 * 10801 * var say = _.rest(function(what, names) { 10802 * return what + ' ' + _.initial(names).join(', ') + 10803 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 10804 * }); 10805 * 10806 * say('hello', 'fred', 'barney', 'pebbles'); 10807 * // => 'hello fred, barney, & pebbles' 10808 */ 10809 function rest(func, start) { 10810 if (typeof func != 'function') { 10811 throw new TypeError(FUNC_ERROR_TEXT); 10812 } 10813 start = start === undefined ? start : toInteger(start); 10814 return baseRest(func, start); 10815 } 10816 10817 /** 10818 * Creates a function that invokes `func` with the `this` binding of the 10819 * create function and an array of arguments much like 10820 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 10821 * 10822 * **Note:** This method is based on the 10823 * [spread operator](https://mdn.io/spread_operator). 10824 * 10825 * @static 10826 * @memberOf _ 10827 * @since 3.2.0 10828 * @category Function 10829 * @param {Function} func The function to spread arguments over. 10830 * @param {number} [start=0] The start position of the spread. 10831 * @returns {Function} Returns the new function. 10832 * @example 10833 * 10834 * var say = _.spread(function(who, what) { 10835 * return who + ' says ' + what; 10836 * }); 10837 * 10838 * say(['fred', 'hello']); 10839 * // => 'fred says hello' 10840 * 10841 * var numbers = Promise.all([ 10842 * Promise.resolve(40), 10843 * Promise.resolve(36) 10844 * ]); 10845 * 10846 * numbers.then(_.spread(function(x, y) { 10847 * return x + y; 10848 * })); 10849 * // => a Promise of 76 10850 */ 10851 function spread(func, start) { 10852 if (typeof func != 'function') { 10853 throw new TypeError(FUNC_ERROR_TEXT); 10854 } 10855 start = start == null ? 0 : nativeMax(toInteger(start), 0); 10856 return baseRest(function(args) { 10857 var array = args[start], 10858 otherArgs = castSlice(args, 0, start); 10859 10860 if (array) { 10861 arrayPush(otherArgs, array); 10862 } 10863 return apply(func, this, otherArgs); 10864 }); 10865 } 10866 10867 /** 10868 * Creates a throttled function that only invokes `func` at most once per 10869 * every `wait` milliseconds. The throttled function comes with a `cancel` 10870 * method to cancel delayed `func` invocations and a `flush` method to 10871 * immediately invoke them. Provide `options` to indicate whether `func` 10872 * should be invoked on the leading and/or trailing edge of the `wait` 10873 * timeout. The `func` is invoked with the last arguments provided to the 10874 * throttled function. Subsequent calls to the throttled function return the 10875 * result of the last `func` invocation. 10876 * 10877 * **Note:** If `leading` and `trailing` options are `true`, `func` is 10878 * invoked on the trailing edge of the timeout only if the throttled function 10879 * is invoked more than once during the `wait` timeout. 10880 * 10881 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 10882 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 10883 * 10884 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 10885 * for details over the differences between `_.throttle` and `_.debounce`. 10886 * 10887 * @static 10888 * @memberOf _ 10889 * @since 0.1.0 10890 * @category Function 10891 * @param {Function} func The function to throttle. 10892 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 10893 * @param {Object} [options={}] The options object. 10894 * @param {boolean} [options.leading=true] 10895 * Specify invoking on the leading edge of the timeout. 10896 * @param {boolean} [options.trailing=true] 10897 * Specify invoking on the trailing edge of the timeout. 10898 * @returns {Function} Returns the new throttled function. 10899 * @example 10900 * 10901 * // Avoid excessively updating the position while scrolling. 10902 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 10903 * 10904 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 10905 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 10906 * jQuery(element).on('click', throttled); 10907 * 10908 * // Cancel the trailing throttled invocation. 10909 * jQuery(window).on('popstate', throttled.cancel); 10910 */ 10911 function throttle(func, wait, options) { 10912 var leading = true, 10913 trailing = true; 10914 10915 if (typeof func != 'function') { 10916 throw new TypeError(FUNC_ERROR_TEXT); 10917 } 10918 if (isObject(options)) { 10919 leading = 'leading' in options ? !!options.leading : leading; 10920 trailing = 'trailing' in options ? !!options.trailing : trailing; 10921 } 10922 return debounce(func, wait, { 10923 'leading': leading, 10924 'maxWait': wait, 10925 'trailing': trailing 10926 }); 10927 } 10928 10929 /** 10930 * Creates a function that accepts up to one argument, ignoring any 10931 * additional arguments. 10932 * 10933 * @static 10934 * @memberOf _ 10935 * @since 4.0.0 10936 * @category Function 10937 * @param {Function} func The function to cap arguments for. 10938 * @returns {Function} Returns the new capped function. 10939 * @example 10940 * 10941 * _.map(['6', '8', '10'], _.unary(parseInt)); 10942 * // => [6, 8, 10] 10943 */ 10944 function unary(func) { 10945 return ary(func, 1); 10946 } 10947 10948 /** 10949 * Creates a function that provides `value` to `wrapper` as its first 10950 * argument. Any additional arguments provided to the function are appended 10951 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 10952 * binding of the created function. 10953 * 10954 * @static 10955 * @memberOf _ 10956 * @since 0.1.0 10957 * @category Function 10958 * @param {*} value The value to wrap. 10959 * @param {Function} [wrapper=identity] The wrapper function. 10960 * @returns {Function} Returns the new function. 10961 * @example 10962 * 10963 * var p = _.wrap(_.escape, function(func, text) { 10964 * return '<p>' + func(text) + '</p>'; 10965 * }); 10966 * 10967 * p('fred, barney, & pebbles'); 10968 * // => '<p>fred, barney, & pebbles</p>' 10969 */ 10970 function wrap(value, wrapper) { 10971 return partial(castFunction(wrapper), value); 10972 } 10973 10974 /*------------------------------------------------------------------------*/ 10975 10976 /** 10977 * Casts `value` as an array if it's not one. 10978 * 10979 * @static 10980 * @memberOf _ 10981 * @since 4.4.0 10982 * @category Lang 10983 * @param {*} value The value to inspect. 10984 * @returns {Array} Returns the cast array. 10985 * @example 10986 * 10987 * _.castArray(1); 10988 * // => [1] 10989 * 10990 * _.castArray({ 'a': 1 }); 10991 * // => [{ 'a': 1 }] 10992 * 10993 * _.castArray('abc'); 10994 * // => ['abc'] 10995 * 10996 * _.castArray(null); 10997 * // => [null] 10998 * 10999 * _.castArray(undefined); 11000 * // => [undefined] 11001 * 11002 * _.castArray(); 11003 * // => [] 11004 * 11005 * var array = [1, 2, 3]; 11006 * console.log(_.castArray(array) === array); 11007 * // => true 11008 */ 11009 function castArray() { 11010 if (!arguments.length) { 11011 return []; 11012 } 11013 var value = arguments[0]; 11014 return isArray(value) ? value : [value]; 11015 } 11016 11017 /** 11018 * Creates a shallow clone of `value`. 11019 * 11020 * **Note:** This method is loosely based on the 11021 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 11022 * and supports cloning arrays, array buffers, booleans, date objects, maps, 11023 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 11024 * arrays. The own enumerable properties of `arguments` objects are cloned 11025 * as plain objects. An empty object is returned for uncloneable values such 11026 * as error objects, functions, DOM nodes, and WeakMaps. 11027 * 11028 * @static 11029 * @memberOf _ 11030 * @since 0.1.0 11031 * @category Lang 11032 * @param {*} value The value to clone. 11033 * @returns {*} Returns the cloned value. 11034 * @see _.cloneDeep 11035 * @example 11036 * 11037 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 11038 * 11039 * var shallow = _.clone(objects); 11040 * console.log(shallow[0] === objects[0]); 11041 * // => true 11042 */ 11043 function clone(value) { 11044 return baseClone(value, CLONE_SYMBOLS_FLAG); 11045 } 11046 11047 /** 11048 * This method is like `_.clone` except that it accepts `customizer` which 11049 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 11050 * cloning is handled by the method instead. The `customizer` is invoked with 11051 * up to four arguments; (value [, index|key, object, stack]). 11052 * 11053 * @static 11054 * @memberOf _ 11055 * @since 4.0.0 11056 * @category Lang 11057 * @param {*} value The value to clone. 11058 * @param {Function} [customizer] The function to customize cloning. 11059 * @returns {*} Returns the cloned value. 11060 * @see _.cloneDeepWith 11061 * @example 11062 * 11063 * function customizer(value) { 11064 * if (_.isElement(value)) { 11065 * return value.cloneNode(false); 11066 * } 11067 * } 11068 * 11069 * var el = _.cloneWith(document.body, customizer); 11070 * 11071 * console.log(el === document.body); 11072 * // => false 11073 * console.log(el.nodeName); 11074 * // => 'BODY' 11075 * console.log(el.childNodes.length); 11076 * // => 0 11077 */ 11078 function cloneWith(value, customizer) { 11079 customizer = typeof customizer == 'function' ? customizer : undefined; 11080 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 11081 } 11082 11083 /** 11084 * This method is like `_.clone` except that it recursively clones `value`. 11085 * 11086 * @static 11087 * @memberOf _ 11088 * @since 1.0.0 11089 * @category Lang 11090 * @param {*} value The value to recursively clone. 11091 * @returns {*} Returns the deep cloned value. 11092 * @see _.clone 11093 * @example 11094 * 11095 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 11096 * 11097 * var deep = _.cloneDeep(objects); 11098 * console.log(deep[0] === objects[0]); 11099 * // => false 11100 */ 11101 function cloneDeep(value) { 11102 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 11103 } 11104 11105 /** 11106 * This method is like `_.cloneWith` except that it recursively clones `value`. 11107 * 11108 * @static 11109 * @memberOf _ 11110 * @since 4.0.0 11111 * @category Lang 11112 * @param {*} value The value to recursively clone. 11113 * @param {Function} [customizer] The function to customize cloning. 11114 * @returns {*} Returns the deep cloned value. 11115 * @see _.cloneWith 11116 * @example 11117 * 11118 * function customizer(value) { 11119 * if (_.isElement(value)) { 11120 * return value.cloneNode(true); 11121 * } 11122 * } 11123 * 11124 * var el = _.cloneDeepWith(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 * // => 20 11132 */ 11133 function cloneDeepWith(value, customizer) { 11134 customizer = typeof customizer == 'function' ? customizer : undefined; 11135 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 11136 } 11137 11138 /** 11139 * Checks if `object` conforms to `source` by invoking the predicate 11140 * properties of `source` with the corresponding property values of `object`. 11141 * 11142 * **Note:** This method is equivalent to `_.conforms` when `source` is 11143 * partially applied. 11144 * 11145 * @static 11146 * @memberOf _ 11147 * @since 4.14.0 11148 * @category Lang 11149 * @param {Object} object The object to inspect. 11150 * @param {Object} source The object of property predicates to conform to. 11151 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 11152 * @example 11153 * 11154 * var object = { 'a': 1, 'b': 2 }; 11155 * 11156 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 11157 * // => true 11158 * 11159 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 11160 * // => false 11161 */ 11162 function conformsTo(object, source) { 11163 return source == null || baseConformsTo(object, source, keys(source)); 11164 } 11165 11166 /** 11167 * Performs a 11168 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 11169 * comparison between two values to determine if they are equivalent. 11170 * 11171 * @static 11172 * @memberOf _ 11173 * @since 4.0.0 11174 * @category Lang 11175 * @param {*} value The value to compare. 11176 * @param {*} other The other value to compare. 11177 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 11178 * @example 11179 * 11180 * var object = { 'a': 1 }; 11181 * var other = { 'a': 1 }; 11182 * 11183 * _.eq(object, object); 11184 * // => true 11185 * 11186 * _.eq(object, other); 11187 * // => false 11188 * 11189 * _.eq('a', 'a'); 11190 * // => true 11191 * 11192 * _.eq('a', Object('a')); 11193 * // => false 11194 * 11195 * _.eq(NaN, NaN); 11196 * // => true 11197 */ 11198 function eq(value, other) { 11199 return value === other || (value !== value && other !== other); 11200 } 11201 11202 /** 11203 * Checks if `value` is greater than `other`. 11204 * 11205 * @static 11206 * @memberOf _ 11207 * @since 3.9.0 11208 * @category Lang 11209 * @param {*} value The value to compare. 11210 * @param {*} other The other value to compare. 11211 * @returns {boolean} Returns `true` if `value` is greater than `other`, 11212 * else `false`. 11213 * @see _.lt 11214 * @example 11215 * 11216 * _.gt(3, 1); 11217 * // => true 11218 * 11219 * _.gt(3, 3); 11220 * // => false 11221 * 11222 * _.gt(1, 3); 11223 * // => false 11224 */ 11225 var gt = createRelationalOperation(baseGt); 11226 11227 /** 11228 * Checks if `value` is greater than or equal to `other`. 11229 * 11230 * @static 11231 * @memberOf _ 11232 * @since 3.9.0 11233 * @category Lang 11234 * @param {*} value The value to compare. 11235 * @param {*} other The other value to compare. 11236 * @returns {boolean} Returns `true` if `value` is greater than or equal to 11237 * `other`, else `false`. 11238 * @see _.lte 11239 * @example 11240 * 11241 * _.gte(3, 1); 11242 * // => true 11243 * 11244 * _.gte(3, 3); 11245 * // => true 11246 * 11247 * _.gte(1, 3); 11248 * // => false 11249 */ 11250 var gte = createRelationalOperation(function(value, other) { 11251 return value >= other; 11252 }); 11253 11254 /** 11255 * Checks if `value` is likely an `arguments` object. 11256 * 11257 * @static 11258 * @memberOf _ 11259 * @since 0.1.0 11260 * @category Lang 11261 * @param {*} value The value to check. 11262 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 11263 * else `false`. 11264 * @example 11265 * 11266 * _.isArguments(function() { return arguments; }()); 11267 * // => true 11268 * 11269 * _.isArguments([1, 2, 3]); 11270 * // => false 11271 */ 11272 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 11273 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 11274 !propertyIsEnumerable.call(value, 'callee'); 11275 }; 11276 11277 /** 11278 * Checks if `value` is classified as an `Array` object. 11279 * 11280 * @static 11281 * @memberOf _ 11282 * @since 0.1.0 11283 * @category Lang 11284 * @param {*} value The value to check. 11285 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 11286 * @example 11287 * 11288 * _.isArray([1, 2, 3]); 11289 * // => true 11290 * 11291 * _.isArray(document.body.children); 11292 * // => false 11293 * 11294 * _.isArray('abc'); 11295 * // => false 11296 * 11297 * _.isArray(_.noop); 11298 * // => false 11299 */ 11300 var isArray = Array.isArray; 11301 11302 /** 11303 * Checks if `value` is classified as an `ArrayBuffer` object. 11304 * 11305 * @static 11306 * @memberOf _ 11307 * @since 4.3.0 11308 * @category Lang 11309 * @param {*} value The value to check. 11310 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 11311 * @example 11312 * 11313 * _.isArrayBuffer(new ArrayBuffer(2)); 11314 * // => true 11315 * 11316 * _.isArrayBuffer(new Array(2)); 11317 * // => false 11318 */ 11319 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 11320 11321 /** 11322 * Checks if `value` is array-like. A value is considered array-like if it's 11323 * not a function and has a `value.length` that's an integer greater than or 11324 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 11325 * 11326 * @static 11327 * @memberOf _ 11328 * @since 4.0.0 11329 * @category Lang 11330 * @param {*} value The value to check. 11331 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 11332 * @example 11333 * 11334 * _.isArrayLike([1, 2, 3]); 11335 * // => true 11336 * 11337 * _.isArrayLike(document.body.children); 11338 * // => true 11339 * 11340 * _.isArrayLike('abc'); 11341 * // => true 11342 * 11343 * _.isArrayLike(_.noop); 11344 * // => false 11345 */ 11346 function isArrayLike(value) { 11347 return value != null && isLength(value.length) && !isFunction(value); 11348 } 11349 11350 /** 11351 * This method is like `_.isArrayLike` except that it also checks if `value` 11352 * is an object. 11353 * 11354 * @static 11355 * @memberOf _ 11356 * @since 4.0.0 11357 * @category Lang 11358 * @param {*} value The value to check. 11359 * @returns {boolean} Returns `true` if `value` is an array-like object, 11360 * else `false`. 11361 * @example 11362 * 11363 * _.isArrayLikeObject([1, 2, 3]); 11364 * // => true 11365 * 11366 * _.isArrayLikeObject(document.body.children); 11367 * // => true 11368 * 11369 * _.isArrayLikeObject('abc'); 11370 * // => false 11371 * 11372 * _.isArrayLikeObject(_.noop); 11373 * // => false 11374 */ 11375 function isArrayLikeObject(value) { 11376 return isObjectLike(value) && isArrayLike(value); 11377 } 11378 11379 /** 11380 * Checks if `value` is classified as a boolean primitive or object. 11381 * 11382 * @static 11383 * @memberOf _ 11384 * @since 0.1.0 11385 * @category Lang 11386 * @param {*} value The value to check. 11387 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 11388 * @example 11389 * 11390 * _.isBoolean(false); 11391 * // => true 11392 * 11393 * _.isBoolean(null); 11394 * // => false 11395 */ 11396 function isBoolean(value) { 11397 return value === true || value === false || 11398 (isObjectLike(value) && baseGetTag(value) == boolTag); 11399 } 11400 11401 /** 11402 * Checks if `value` is a buffer. 11403 * 11404 * @static 11405 * @memberOf _ 11406 * @since 4.3.0 11407 * @category Lang 11408 * @param {*} value The value to check. 11409 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 11410 * @example 11411 * 11412 * _.isBuffer(new Buffer(2)); 11413 * // => true 11414 * 11415 * _.isBuffer(new Uint8Array(2)); 11416 * // => false 11417 */ 11418 var isBuffer = nativeIsBuffer || stubFalse; 11419 11420 /** 11421 * Checks if `value` is classified as a `Date` object. 11422 * 11423 * @static 11424 * @memberOf _ 11425 * @since 0.1.0 11426 * @category Lang 11427 * @param {*} value The value to check. 11428 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 11429 * @example 11430 * 11431 * _.isDate(new Date); 11432 * // => true 11433 * 11434 * _.isDate('Mon April 23 2012'); 11435 * // => false 11436 */ 11437 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 11438 11439 /** 11440 * Checks if `value` is likely a DOM element. 11441 * 11442 * @static 11443 * @memberOf _ 11444 * @since 0.1.0 11445 * @category Lang 11446 * @param {*} value The value to check. 11447 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 11448 * @example 11449 * 11450 * _.isElement(document.body); 11451 * // => true 11452 * 11453 * _.isElement('<body>'); 11454 * // => false 11455 */ 11456 function isElement(value) { 11457 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 11458 } 11459 11460 /** 11461 * Checks if `value` is an empty object, collection, map, or set. 11462 * 11463 * Objects are considered empty if they have no own enumerable string keyed 11464 * properties. 11465 * 11466 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 11467 * jQuery-like collections are considered empty if they have a `length` of `0`. 11468 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 11469 * 11470 * @static 11471 * @memberOf _ 11472 * @since 0.1.0 11473 * @category Lang 11474 * @param {*} value The value to check. 11475 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 11476 * @example 11477 * 11478 * _.isEmpty(null); 11479 * // => true 11480 * 11481 * _.isEmpty(true); 11482 * // => true 11483 * 11484 * _.isEmpty(1); 11485 * // => true 11486 * 11487 * _.isEmpty([1, 2, 3]); 11488 * // => false 11489 * 11490 * _.isEmpty({ 'a': 1 }); 11491 * // => false 11492 */ 11493 function isEmpty(value) { 11494 if (value == null) { 11495 return true; 11496 } 11497 if (isArrayLike(value) && 11498 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 11499 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 11500 return !value.length; 11501 } 11502 var tag = getTag(value); 11503 if (tag == mapTag || tag == setTag) { 11504 return !value.size; 11505 } 11506 if (isPrototype(value)) { 11507 return !baseKeys(value).length; 11508 } 11509 for (var key in value) { 11510 if (hasOwnProperty.call(value, key)) { 11511 return false; 11512 } 11513 } 11514 return true; 11515 } 11516 11517 /** 11518 * Performs a deep comparison between two values to determine if they are 11519 * equivalent. 11520 * 11521 * **Note:** This method supports comparing arrays, array buffers, booleans, 11522 * date objects, error objects, maps, numbers, `Object` objects, regexes, 11523 * sets, strings, symbols, and typed arrays. `Object` objects are compared 11524 * by their own, not inherited, enumerable properties. Functions and DOM 11525 * nodes are compared by strict equality, i.e. `===`. 11526 * 11527 * @static 11528 * @memberOf _ 11529 * @since 0.1.0 11530 * @category Lang 11531 * @param {*} value The value to compare. 11532 * @param {*} other The other value to compare. 11533 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 11534 * @example 11535 * 11536 * var object = { 'a': 1 }; 11537 * var other = { 'a': 1 }; 11538 * 11539 * _.isEqual(object, other); 11540 * // => true 11541 * 11542 * object === other; 11543 * // => false 11544 */ 11545 function isEqual(value, other) { 11546 return baseIsEqual(value, other); 11547 } 11548 11549 /** 11550 * This method is like `_.isEqual` except that it accepts `customizer` which 11551 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 11552 * are handled by the method instead. The `customizer` is invoked with up to 11553 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 11554 * 11555 * @static 11556 * @memberOf _ 11557 * @since 4.0.0 11558 * @category Lang 11559 * @param {*} value The value to compare. 11560 * @param {*} other The other value to compare. 11561 * @param {Function} [customizer] The function to customize comparisons. 11562 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 11563 * @example 11564 * 11565 * function isGreeting(value) { 11566 * return /^h(?:i|ello)$/.test(value); 11567 * } 11568 * 11569 * function customizer(objValue, othValue) { 11570 * if (isGreeting(objValue) && isGreeting(othValue)) { 11571 * return true; 11572 * } 11573 * } 11574 * 11575 * var array = ['hello', 'goodbye']; 11576 * var other = ['hi', 'goodbye']; 11577 * 11578 * _.isEqualWith(array, other, customizer); 11579 * // => true 11580 */ 11581 function isEqualWith(value, other, customizer) { 11582 customizer = typeof customizer == 'function' ? customizer : undefined; 11583 var result = customizer ? customizer(value, other) : undefined; 11584 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 11585 } 11586 11587 /** 11588 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 11589 * `SyntaxError`, `TypeError`, or `URIError` object. 11590 * 11591 * @static 11592 * @memberOf _ 11593 * @since 3.0.0 11594 * @category Lang 11595 * @param {*} value The value to check. 11596 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 11597 * @example 11598 * 11599 * _.isError(new Error); 11600 * // => true 11601 * 11602 * _.isError(Error); 11603 * // => false 11604 */ 11605 function isError(value) { 11606 if (!isObjectLike(value)) { 11607 return false;
vendor: 6,607 bytes, lines 11608-11845
11608 } 11609 var tag = baseGetTag(value); 11610 return tag == errorTag || tag == domExcTag || 11611 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 11612 } 11613 11614 /** 11615 * Checks if `value` is a finite primitive number. 11616 * 11617 * **Note:** This method is based on 11618 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 11619 * 11620 * @static 11621 * @memberOf _ 11622 * @since 0.1.0 11623 * @category Lang 11624 * @param {*} value The value to check. 11625 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 11626 * @example 11627 * 11628 * _.isFinite(3); 11629 * // => true 11630 * 11631 * _.isFinite(Number.MIN_VALUE); 11632 * // => true 11633 * 11634 * _.isFinite(Infinity); 11635 * // => false 11636 * 11637 * _.isFinite('3'); 11638 * // => false 11639 */ 11640 function isFinite(value) { 11641 return typeof value == 'number' && nativeIsFinite(value); 11642 } 11643 11644 /** 11645 * Checks if `value` is classified as a `Function` object. 11646 * 11647 * @static 11648 * @memberOf _ 11649 * @since 0.1.0 11650 * @category Lang 11651 * @param {*} value The value to check. 11652 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 11653 * @example 11654 * 11655 * _.isFunction(_); 11656 * // => true 11657 * 11658 * _.isFunction(/abc/); 11659 * // => false 11660 */ 11661 function isFunction(value) { 11662 if (!isObject(value)) { 11663 return false; 11664 } 11665 // The use of `Object#toString` avoids issues with the `typeof` operator 11666 // in Safari 9 which returns 'object' for typed arrays and other constructors. 11667 var tag = baseGetTag(value); 11668 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 11669 } 11670 11671 /** 11672 * Checks if `value` is an integer. 11673 * 11674 * **Note:** This method is based on 11675 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 11676 * 11677 * @static 11678 * @memberOf _ 11679 * @since 4.0.0 11680 * @category Lang 11681 * @param {*} value The value to check. 11682 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 11683 * @example 11684 * 11685 * _.isInteger(3); 11686 * // => true 11687 * 11688 * _.isInteger(Number.MIN_VALUE); 11689 * // => false 11690 * 11691 * _.isInteger(Infinity); 11692 * // => false 11693 * 11694 * _.isInteger('3'); 11695 * // => false 11696 */ 11697 function isInteger(value) { 11698 return typeof value == 'number' && value == toInteger(value); 11699 } 11700 11701 /** 11702 * Checks if `value` is a valid array-like length. 11703 * 11704 * **Note:** This method is loosely based on 11705 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 11706 * 11707 * @static 11708 * @memberOf _ 11709 * @since 4.0.0 11710 * @category Lang 11711 * @param {*} value The value to check. 11712 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 11713 * @example 11714 * 11715 * _.isLength(3); 11716 * // => true 11717 * 11718 * _.isLength(Number.MIN_VALUE); 11719 * // => false 11720 * 11721 * _.isLength(Infinity); 11722 * // => false 11723 * 11724 * _.isLength('3'); 11725 * // => false 11726 */ 11727 function isLength(value) { 11728 return typeof value == 'number' && 11729 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 11730 } 11731 11732 /** 11733 * Checks if `value` is the 11734 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 11735 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 11736 * 11737 * @static 11738 * @memberOf _ 11739 * @since 0.1.0 11740 * @category Lang 11741 * @param {*} value The value to check. 11742 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 11743 * @example 11744 * 11745 * _.isObject({}); 11746 * // => true 11747 * 11748 * _.isObject([1, 2, 3]); 11749 * // => true 11750 * 11751 * _.isObject(_.noop); 11752 * // => true 11753 * 11754 * _.isObject(null); 11755 * // => false 11756 */ 11757 function isObject(value) { 11758 var type = typeof value; 11759 return value != null && (type == 'object' || type == 'function'); 11760 } 11761 11762 /** 11763 * Checks if `value` is object-like. A value is object-like if it's not `null` 11764 * and has a `typeof` result of "object". 11765 * 11766 * @static 11767 * @memberOf _ 11768 * @since 4.0.0 11769 * @category Lang 11770 * @param {*} value The value to check. 11771 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 11772 * @example 11773 * 11774 * _.isObjectLike({}); 11775 * // => true 11776 * 11777 * _.isObjectLike([1, 2, 3]); 11778 * // => true 11779 * 11780 * _.isObjectLike(_.noop); 11781 * // => false 11782 * 11783 * _.isObjectLike(null); 11784 * // => false 11785 */ 11786 function isObjectLike(value) { 11787 return value != null && typeof value == 'object'; 11788 } 11789 11790 /** 11791 * Checks if `value` is classified as a `Map` object. 11792 * 11793 * @static 11794 * @memberOf _ 11795 * @since 4.3.0 11796 * @category Lang 11797 * @param {*} value The value to check. 11798 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 11799 * @example 11800 * 11801 * _.isMap(new Map); 11802 * // => true 11803 * 11804 * _.isMap(new WeakMap); 11805 * // => false 11806 */ 11807 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 11808 11809 /** 11810 * Performs a partial deep comparison between `object` and `source` to 11811 * determine if `object` contains equivalent property values. 11812 * 11813 * **Note:** This method is equivalent to `_.matches` when `source` is 11814 * partially applied. 11815 * 11816 * Partial comparisons will match empty array and empty object `source` 11817 * values against any array or object value, respectively. See `_.isEqual` 11818 * for a list of supported value comparisons. 11819 * 11820 * @static 11821 * @memberOf _ 11822 * @since 3.0.0 11823 * @category Lang 11824 * @param {Object} object The object to inspect. 11825 * @param {Object} source The object of property values to match. 11826 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 11827 * @example 11828 * 11829 * var object = { 'a': 1, 'b': 2 }; 11830 * 11831 * _.isMatch(object, { 'b': 2 }); 11832 * // => true 11833 * 11834 * _.isMatch(object, { 'b': 1 }); 11835 * // => false 11836 */ 11837 function isMatch(object, source) { 11838 return object === source || baseIsMatch(object, source, getMatchData(source)); 11839 } 11840 11841 /** 11842 * This method is like `_.isMatch` except that it accepts `customizer` which 11843 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 11844 * are handled by the method instead. The `customizer` is invoked with five 11845 * arguments: (objValue, srcValue, index|key, object, source).
vendor: 12,241 bytes, lines 11846-12311
11846 * 11847 * @static 11848 * @memberOf _ 11849 * @since 4.0.0 11850 * @category Lang 11851 * @param {Object} object The object to inspect. 11852 * @param {Object} source The object of property values to match. 11853 * @param {Function} [customizer] The function to customize comparisons. 11854 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 11855 * @example 11856 * 11857 * function isGreeting(value) { 11858 * return /^h(?:i|ello)$/.test(value); 11859 * } 11860 * 11861 * function customizer(objValue, srcValue) { 11862 * if (isGreeting(objValue) && isGreeting(srcValue)) { 11863 * return true; 11864 * } 11865 * } 11866 * 11867 * var object = { 'greeting': 'hello' }; 11868 * var source = { 'greeting': 'hi' }; 11869 * 11870 * _.isMatchWith(object, source, customizer); 11871 * // => true 11872 */ 11873 function isMatchWith(object, source, customizer) { 11874 customizer = typeof customizer == 'function' ? customizer : undefined; 11875 return baseIsMatch(object, source, getMatchData(source), customizer); 11876 } 11877 11878 /** 11879 * Checks if `value` is `NaN`. 11880 * 11881 * **Note:** This method is based on 11882 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 11883 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 11884 * `undefined` and other non-number values. 11885 * 11886 * @static 11887 * @memberOf _ 11888 * @since 0.1.0 11889 * @category Lang 11890 * @param {*} value The value to check. 11891 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 11892 * @example 11893 * 11894 * _.isNaN(NaN); 11895 * // => true 11896 * 11897 * _.isNaN(new Number(NaN)); 11898 * // => true 11899 * 11900 * isNaN(undefined); 11901 * // => true 11902 * 11903 * _.isNaN(undefined); 11904 * // => false 11905 */ 11906 function isNaN(value) { 11907 // An `NaN` primitive is the only value that is not equal to itself. 11908 // Perform the `toStringTag` check first to avoid errors with some 11909 // ActiveX objects in IE. 11910 return isNumber(value) && value != +value; 11911 } 11912 11913 /** 11914 * Checks if `value` is a pristine native function. 11915 * 11916 * **Note:** This method can't reliably detect native functions in the presence 11917 * of the core-js package because core-js circumvents this kind of detection. 11918 * Despite multiple requests, the core-js maintainer has made it clear: any 11919 * attempt to fix the detection will be obstructed. As a result, we're left 11920 * with little choice but to throw an error. Unfortunately, this also affects 11921 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 11922 * which rely on core-js. 11923 * 11924 * @static 11925 * @memberOf _ 11926 * @since 3.0.0 11927 * @category Lang 11928 * @param {*} value The value to check. 11929 * @returns {boolean} Returns `true` if `value` is a native function, 11930 * else `false`. 11931 * @example 11932 * 11933 * _.isNative(Array.prototype.push); 11934 * // => true 11935 * 11936 * _.isNative(_); 11937 * // => false 11938 */ 11939 function isNative(value) { 11940 if (isMaskable(value)) { 11941 throw new Error(CORE_ERROR_TEXT); 11942 } 11943 return baseIsNative(value); 11944 } 11945 11946 /** 11947 * Checks if `value` is `null`. 11948 * 11949 * @static 11950 * @memberOf _ 11951 * @since 0.1.0 11952 * @category Lang 11953 * @param {*} value The value to check. 11954 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 11955 * @example 11956 * 11957 * _.isNull(null); 11958 * // => true 11959 * 11960 * _.isNull(void 0); 11961 * // => false 11962 */ 11963 function isNull(value) { 11964 return value === null; 11965 } 11966 11967 /** 11968 * Checks if `value` is `null` or `undefined`. 11969 * 11970 * @static 11971 * @memberOf _ 11972 * @since 4.0.0 11973 * @category Lang 11974 * @param {*} value The value to check. 11975 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 11976 * @example 11977 * 11978 * _.isNil(null); 11979 * // => true 11980 * 11981 * _.isNil(void 0); 11982 * // => true 11983 * 11984 * _.isNil(NaN); 11985 * // => false 11986 */ 11987 function isNil(value) { 11988 return value == null; 11989 } 11990 11991 /** 11992 * Checks if `value` is classified as a `Number` primitive or object. 11993 * 11994 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 11995 * classified as numbers, use the `_.isFinite` method. 11996 * 11997 * @static 11998 * @memberOf _ 11999 * @since 0.1.0 12000 * @category Lang 12001 * @param {*} value The value to check. 12002 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 12003 * @example 12004 * 12005 * _.isNumber(3); 12006 * // => true 12007 * 12008 * _.isNumber(Number.MIN_VALUE); 12009 * // => true 12010 * 12011 * _.isNumber(Infinity); 12012 * // => true 12013 * 12014 * _.isNumber('3'); 12015 * // => false 12016 */ 12017 function isNumber(value) { 12018 return typeof value == 'number' || 12019 (isObjectLike(value) && baseGetTag(value) == numberTag); 12020 } 12021 12022 /** 12023 * Checks if `value` is a plain object, that is, an object created by the 12024 * `Object` constructor or one with a `[[Prototype]]` of `null`. 12025 * 12026 * @static 12027 * @memberOf _ 12028 * @since 0.8.0 12029 * @category Lang 12030 * @param {*} value The value to check. 12031 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 12032 * @example 12033 * 12034 * function Foo() { 12035 * this.a = 1; 12036 * } 12037 * 12038 * _.isPlainObject(new Foo); 12039 * // => false 12040 * 12041 * _.isPlainObject([1, 2, 3]); 12042 * // => false 12043 * 12044 * _.isPlainObject({ 'x': 0, 'y': 0 }); 12045 * // => true 12046 * 12047 * _.isPlainObject(Object.create(null)); 12048 * // => true 12049 */ 12050 function isPlainObject(value) { 12051 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 12052 return false; 12053 } 12054 var proto = getPrototype(value); 12055 if (proto === null) { 12056 return true; 12057 } 12058 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 12059 return typeof Ctor == 'function' && Ctor instanceof Ctor && 12060 funcToString.call(Ctor) == objectCtorString; 12061 } 12062 12063 /** 12064 * Checks if `value` is classified as a `RegExp` object. 12065 * 12066 * @static 12067 * @memberOf _ 12068 * @since 0.1.0 12069 * @category Lang 12070 * @param {*} value The value to check. 12071 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 12072 * @example 12073 * 12074 * _.isRegExp(/abc/); 12075 * // => true 12076 * 12077 * _.isRegExp('/abc/'); 12078 * // => false 12079 */ 12080 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 12081 12082 /** 12083 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 12084 * double precision number which isn't the result of a rounded unsafe integer. 12085 * 12086 * **Note:** This method is based on 12087 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 12088 * 12089 * @static 12090 * @memberOf _ 12091 * @since 4.0.0 12092 * @category Lang 12093 * @param {*} value The value to check. 12094 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 12095 * @example 12096 * 12097 * _.isSafeInteger(3); 12098 * // => true 12099 * 12100 * _.isSafeInteger(Number.MIN_VALUE); 12101 * // => false 12102 * 12103 * _.isSafeInteger(Infinity); 12104 * // => false 12105 * 12106 * _.isSafeInteger('3'); 12107 * // => false 12108 */ 12109 function isSafeInteger(value) { 12110 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 12111 } 12112 12113 /** 12114 * Checks if `value` is classified as a `Set` object. 12115 * 12116 * @static 12117 * @memberOf _ 12118 * @since 4.3.0 12119 * @category Lang 12120 * @param {*} value The value to check. 12121 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 12122 * @example 12123 * 12124 * _.isSet(new Set); 12125 * // => true 12126 * 12127 * _.isSet(new WeakSet); 12128 * // => false 12129 */ 12130 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 12131 12132 /** 12133 * Checks if `value` is classified as a `String` primitive or object. 12134 * 12135 * @static 12136 * @since 0.1.0 12137 * @memberOf _ 12138 * @category Lang 12139 * @param {*} value The value to check. 12140 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 12141 * @example 12142 * 12143 * _.isString('abc'); 12144 * // => true 12145 * 12146 * _.isString(1); 12147 * // => false 12148 */ 12149 function isString(value) { 12150 return typeof value == 'string' || 12151 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 12152 } 12153 12154 /** 12155 * Checks if `value` is classified as a `Symbol` primitive or object. 12156 * 12157 * @static 12158 * @memberOf _ 12159 * @since 4.0.0 12160 * @category Lang 12161 * @param {*} value The value to check. 12162 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 12163 * @example 12164 * 12165 * _.isSymbol(Symbol.iterator); 12166 * // => true 12167 * 12168 * _.isSymbol('abc'); 12169 * // => false 12170 */ 12171 function isSymbol(value) { 12172 return typeof value == 'symbol' || 12173 (isObjectLike(value) && baseGetTag(value) == symbolTag); 12174 } 12175 12176 /** 12177 * Checks if `value` is classified as a typed array. 12178 * 12179 * @static 12180 * @memberOf _ 12181 * @since 3.0.0 12182 * @category Lang 12183 * @param {*} value The value to check. 12184 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 12185 * @example 12186 * 12187 * _.isTypedArray(new Uint8Array); 12188 * // => true 12189 * 12190 * _.isTypedArray([]); 12191 * // => false 12192 */ 12193 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 12194 12195 /** 12196 * Checks if `value` is `undefined`. 12197 * 12198 * @static 12199 * @since 0.1.0 12200 * @memberOf _ 12201 * @category Lang 12202 * @param {*} value The value to check. 12203 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 12204 * @example 12205 * 12206 * _.isUndefined(void 0); 12207 * // => true 12208 * 12209 * _.isUndefined(null); 12210 * // => false 12211 */ 12212 function isUndefined(value) { 12213 return value === undefined; 12214 } 12215 12216 /** 12217 * Checks if `value` is classified as a `WeakMap` object. 12218 * 12219 * @static 12220 * @memberOf _ 12221 * @since 4.3.0 12222 * @category Lang 12223 * @param {*} value The value to check. 12224 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 12225 * @example 12226 * 12227 * _.isWeakMap(new WeakMap); 12228 * // => true 12229 * 12230 * _.isWeakMap(new Map); 12231 * // => false 12232 */ 12233 function isWeakMap(value) { 12234 return isObjectLike(value) && getTag(value) == weakMapTag; 12235 } 12236 12237 /** 12238 * Checks if `value` is classified as a `WeakSet` object. 12239 * 12240 * @static 12241 * @memberOf _ 12242 * @since 4.3.0 12243 * @category Lang 12244 * @param {*} value The value to check. 12245 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 12246 * @example 12247 * 12248 * _.isWeakSet(new WeakSet); 12249 * // => true 12250 * 12251 * _.isWeakSet(new Set); 12252 * // => false 12253 */ 12254 function isWeakSet(value) { 12255 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 12256 } 12257 12258 /** 12259 * Checks if `value` is less than `other`. 12260 * 12261 * @static 12262 * @memberOf _ 12263 * @since 3.9.0 12264 * @category Lang 12265 * @param {*} value The value to compare. 12266 * @param {*} other The other value to compare. 12267 * @returns {boolean} Returns `true` if `value` is less than `other`, 12268 * else `false`. 12269 * @see _.gt 12270 * @example 12271 * 12272 * _.lt(1, 3); 12273 * // => true 12274 * 12275 * _.lt(3, 3); 12276 * // => false 12277 * 12278 * _.lt(3, 1); 12279 * // => false 12280 */ 12281 var lt = createRelationalOperation(baseLt); 12282 12283 /** 12284 * Checks if `value` is less than or equal to `other`. 12285 * 12286 * @static 12287 * @memberOf _ 12288 * @since 3.9.0 12289 * @category Lang 12290 * @param {*} value The value to compare. 12291 * @param {*} other The other value to compare. 12292 * @returns {boolean} Returns `true` if `value` is less than or equal to 12293 * `other`, else `false`. 12294 * @see _.gte 12295 * @example 12296 * 12297 * _.lte(1, 3); 12298 * // => true 12299 * 12300 * _.lte(3, 3); 12301 * // => true 12302 * 12303 * _.lte(3, 1); 12304 * // => false 12305 */ 12306 var lte = createRelationalOperation(function(value, other) { 12307 return value <= other; 12308 }); 12309 12310 /** 12311 * Converts `value` to an array.
vendor: 4,495 bytes, lines 12312-12493
12312 * 12313 * @static 12314 * @since 0.1.0 12315 * @memberOf _ 12316 * @category Lang 12317 * @param {*} value The value to convert. 12318 * @returns {Array} Returns the converted array. 12319 * @example 12320 * 12321 * _.toArray({ 'a': 1, 'b': 2 }); 12322 * // => [1, 2] 12323 * 12324 * _.toArray('abc'); 12325 * // => ['a', 'b', 'c'] 12326 * 12327 * _.toArray(1); 12328 * // => [] 12329 * 12330 * _.toArray(null); 12331 * // => [] 12332 */ 12333 function toArray(value) { 12334 if (!value) { 12335 return []; 12336 } 12337 if (isArrayLike(value)) { 12338 return isString(value) ? stringToArray(value) : copyArray(value); 12339 } 12340 if (symIterator && value[symIterator]) { 12341 return iteratorToArray(value[symIterator]()); 12342 } 12343 var tag = getTag(value), 12344 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 12345 12346 return func(value); 12347 } 12348 12349 /** 12350 * Converts `value` to a finite number. 12351 * 12352 * @static 12353 * @memberOf _ 12354 * @since 4.12.0 12355 * @category Lang 12356 * @param {*} value The value to convert. 12357 * @returns {number} Returns the converted number. 12358 * @example 12359 * 12360 * _.toFinite(3.2); 12361 * // => 3.2 12362 * 12363 * _.toFinite(Number.MIN_VALUE); 12364 * // => 5e-324 12365 * 12366 * _.toFinite(Infinity); 12367 * // => 1.7976931348623157e+308 12368 * 12369 * _.toFinite('3.2'); 12370 * // => 3.2 12371 */ 12372 function toFinite(value) { 12373 if (!value) { 12374 return value === 0 ? value : 0; 12375 } 12376 value = toNumber(value); 12377 if (value === INFINITY || value === -INFINITY) { 12378 var sign = (value < 0 ? -1 : 1); 12379 return sign * MAX_INTEGER; 12380 } 12381 return value === value ? value : 0; 12382 } 12383 12384 /** 12385 * Converts `value` to an integer. 12386 * 12387 * **Note:** This method is loosely based on 12388 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 12389 * 12390 * @static 12391 * @memberOf _ 12392 * @since 4.0.0 12393 * @category Lang 12394 * @param {*} value The value to convert. 12395 * @returns {number} Returns the converted integer. 12396 * @example 12397 * 12398 * _.toInteger(3.2); 12399 * // => 3 12400 * 12401 * _.toInteger(Number.MIN_VALUE); 12402 * // => 0 12403 * 12404 * _.toInteger(Infinity); 12405 * // => 1.7976931348623157e+308 12406 * 12407 * _.toInteger('3.2'); 12408 * // => 3 12409 */ 12410 function toInteger(value) { 12411 var result = toFinite(value), 12412 remainder = result % 1; 12413 12414 return result === result ? (remainder ? result - remainder : result) : 0; 12415 } 12416 12417 /** 12418 * Converts `value` to an integer suitable for use as the length of an 12419 * array-like object. 12420 * 12421 * **Note:** This method is based on 12422 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 12423 * 12424 * @static 12425 * @memberOf _ 12426 * @since 4.0.0 12427 * @category Lang 12428 * @param {*} value The value to convert. 12429 * @returns {number} Returns the converted integer. 12430 * @example 12431 * 12432 * _.toLength(3.2); 12433 * // => 3 12434 * 12435 * _.toLength(Number.MIN_VALUE); 12436 * // => 0 12437 * 12438 * _.toLength(Infinity); 12439 * // => 4294967295 12440 * 12441 * _.toLength('3.2'); 12442 * // => 3 12443 */ 12444 function toLength(value) { 12445 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 12446 } 12447 12448 /** 12449 * Converts `value` to a number. 12450 * 12451 * @static 12452 * @memberOf _ 12453 * @since 4.0.0 12454 * @category Lang 12455 * @param {*} value The value to process. 12456 * @returns {number} Returns the number. 12457 * @example 12458 * 12459 * _.toNumber(3.2); 12460 * // => 3.2 12461 * 12462 * _.toNumber(Number.MIN_VALUE); 12463 * // => 5e-324 12464 * 12465 * _.toNumber(Infinity); 12466 * // => Infinity 12467 * 12468 * _.toNumber('3.2'); 12469 * // => 3.2 12470 */ 12471 function toNumber(value) { 12472 if (typeof value == 'number') { 12473 return value; 12474 } 12475 if (isSymbol(value)) { 12476 return NAN; 12477 } 12478 if (isObject(value)) { 12479 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 12480 value = isObject(other) ? (other + '') : other; 12481 } 12482 if (typeof value != 'string') { 12483 return value === 0 ? value : +value; 12484 } 12485 value = value.replace(reTrim, ''); 12486 var isBinary = reIsBinary.test(value); 12487 return (isBinary || reIsOctal.test(value)) 12488 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 12489 : (reIsBadHex.test(value) ? NAN : +value); 12490 } 12491 12492 /** 12493 * Converts `value` to a plain object flattening inherited enumerable str
vendor: 9,060 bytes, lines 12493-12800
12493ing 12494 * keyed properties of `value` to own properties of the plain object. 12495 * 12496 * @static 12497 * @memberOf _ 12498 * @since 3.0.0 12499 * @category Lang 12500 * @param {*} value The value to convert. 12501 * @returns {Object} Returns the converted plain object. 12502 * @example 12503 * 12504 * function Foo() { 12505 * this.b = 2; 12506 * } 12507 * 12508 * Foo.prototype.c = 3; 12509 * 12510 * _.assign({ 'a': 1 }, new Foo); 12511 * // => { 'a': 1, 'b': 2 } 12512 * 12513 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 12514 * // => { 'a': 1, 'b': 2, 'c': 3 } 12515 */ 12516 function toPlainObject(value) { 12517 return copyObject(value, keysIn(value)); 12518 } 12519 12520 /** 12521 * Converts `value` to a safe integer. A safe integer can be compared and 12522 * represented correctly. 12523 * 12524 * @static 12525 * @memberOf _ 12526 * @since 4.0.0 12527 * @category Lang 12528 * @param {*} value The value to convert. 12529 * @returns {number} Returns the converted integer. 12530 * @example 12531 * 12532 * _.toSafeInteger(3.2); 12533 * // => 3 12534 * 12535 * _.toSafeInteger(Number.MIN_VALUE); 12536 * // => 0 12537 * 12538 * _.toSafeInteger(Infinity); 12539 * // => 9007199254740991 12540 * 12541 * _.toSafeInteger('3.2'); 12542 * // => 3 12543 */ 12544 function toSafeInteger(value) { 12545 return value 12546 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 12547 : (value === 0 ? value : 0); 12548 } 12549 12550 /** 12551 * Converts `value` to a string. An empty string is returned for `null` 12552 * and `undefined` values. The sign of `-0` is preserved. 12553 * 12554 * @static 12555 * @memberOf _ 12556 * @since 4.0.0 12557 * @category Lang 12558 * @param {*} value The value to convert. 12559 * @returns {string} Returns the converted string. 12560 * @example 12561 * 12562 * _.toString(null); 12563 * // => '' 12564 * 12565 * _.toString(-0); 12566 * // => '-0' 12567 * 12568 * _.toString([1, 2, 3]); 12569 * // => '1,2,3' 12570 */ 12571 function toString(value) { 12572 return value == null ? '' : baseToString(value); 12573 } 12574 12575 /*------------------------------------------------------------------------*/ 12576 12577 /** 12578 * Assigns own enumerable string keyed properties of source objects to the 12579 * destination object. Source objects are applied from left to right. 12580 * Subsequent sources overwrite property assignments of previous sources. 12581 * 12582 * **Note:** This method mutates `object` and is loosely based on 12583 * [`Object.assign`](https://mdn.io/Object/assign). 12584 * 12585 * @static 12586 * @memberOf _ 12587 * @since 0.10.0 12588 * @category Object 12589 * @param {Object} object The destination object. 12590 * @param {...Object} [sources] The source objects. 12591 * @returns {Object} Returns `object`. 12592 * @see _.assignIn 12593 * @example 12594 * 12595 * function Foo() { 12596 * this.a = 1; 12597 * } 12598 * 12599 * function Bar() { 12600 * this.c = 3; 12601 * } 12602 * 12603 * Foo.prototype.b = 2; 12604 * Bar.prototype.d = 4; 12605 * 12606 * _.assign({ 'a': 0 }, new Foo, new Bar); 12607 * // => { 'a': 1, 'c': 3 } 12608 */ 12609 var assign = createAssigner(function(object, source) { 12610 if (isPrototype(source) || isArrayLike(source)) { 12611 copyObject(source, keys(source), object); 12612 return; 12613 } 12614 for (var key in source) { 12615 if (hasOwnProperty.call(source, key)) { 12616 assignValue(object, key, source[key]); 12617 } 12618 } 12619 }); 12620 12621 /** 12622 * This method is like `_.assign` except that it iterates over own and 12623 * inherited source properties. 12624 * 12625 * **Note:** This method mutates `object`. 12626 * 12627 * @static 12628 * @memberOf _ 12629 * @since 4.0.0 12630 * @alias extend 12631 * @category Object 12632 * @param {Object} object The destination object. 12633 * @param {...Object} [sources] The source objects. 12634 * @returns {Object} Returns `object`. 12635 * @see _.assign 12636 * @example 12637 * 12638 * function Foo() { 12639 * this.a = 1; 12640 * } 12641 * 12642 * function Bar() { 12643 * this.c = 3; 12644 * } 12645 * 12646 * Foo.prototype.b = 2; 12647 * Bar.prototype.d = 4; 12648 * 12649 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 12650 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 12651 */ 12652 var assignIn = createAssigner(function(object, source) { 12653 copyObject(source, keysIn(source), object); 12654 }); 12655 12656 /** 12657 * This method is like `_.assignIn` except that it accepts `customizer` 12658 * which is invoked to produce the assigned values. If `customizer` returns 12659 * `undefined`, assignment is handled by the method instead. The `customizer` 12660 * is invoked with five arguments: (objValue, srcValue, key, object, source). 12661 * 12662 * **Note:** This method mutates `object`. 12663 * 12664 * @static 12665 * @memberOf _ 12666 * @since 4.0.0 12667 * @alias extendWith 12668 * @category Object 12669 * @param {Object} object The destination object. 12670 * @param {...Object} sources The source objects. 12671 * @param {Function} [customizer] The function to customize assigned values. 12672 * @returns {Object} Returns `object`. 12673 * @see _.assignWith 12674 * @example 12675 * 12676 * function customizer(objValue, srcValue) { 12677 * return _.isUndefined(objValue) ? srcValue : objValue; 12678 * } 12679 * 12680 * var defaults = _.partialRight(_.assignInWith, customizer); 12681 * 12682 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 12683 * // => { 'a': 1, 'b': 2 } 12684 */ 12685 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 12686 copyObject(source, keysIn(source), object, customizer); 12687 }); 12688 12689 /** 12690 * This method is like `_.assign` except that it accepts `customizer` 12691 * which is invoked to produce the assigned values. If `customizer` returns 12692 * `undefined`, assignment is handled by the method instead. The `customizer` 12693 * is invoked with five arguments: (objValue, srcValue, key, object, source). 12694 * 12695 * **Note:** This method mutates `object`. 12696 * 12697 * @static 12698 * @memberOf _ 12699 * @since 4.0.0 12700 * @category Object 12701 * @param {Object} object The destination object. 12702 * @param {...Object} sources The source objects. 12703 * @param {Function} [customizer] The function to customize assigned values. 12704 * @returns {Object} Returns `object`. 12705 * @see _.assignInWith 12706 * @example 12707 * 12708 * function customizer(objValue, srcValue) { 12709 * return _.isUndefined(objValue) ? srcValue : objValue; 12710 * } 12711 * 12712 * var defaults = _.partialRight(_.assignWith, customizer); 12713 * 12714 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 12715 * // => { 'a': 1, 'b': 2 } 12716 */ 12717 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 12718 copyObject(source, keys(source), object, customizer); 12719 }); 12720 12721 /** 12722 * Creates an array of values corresponding to `paths` of `object`. 12723 * 12724 * @static 12725 * @memberOf _ 12726 * @since 1.0.0 12727 * @category Object 12728 * @param {Object} object The object to iterate over. 12729 * @param {...(string|string[])} [paths] The property paths to pick. 12730 * @returns {Array} Returns the picked values. 12731 * @example 12732 * 12733 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 12734 * 12735 * _.at(object, ['a[0].b.c', 'a[1]']); 12736 * // => [3, 4] 12737 */ 12738 var at = flatRest(baseAt); 12739 12740 /** 12741 * Creates an object that inherits from the `prototype` object. If a 12742 * `properties` object is given, its own enumerable string keyed properties 12743 * are assigned to the created object. 12744 * 12745 * @static 12746 * @memberOf _ 12747 * @since 2.3.0 12748 * @category Object 12749 * @param {Object} prototype The object to inherit from. 12750 * @param {Object} [properties] The properties to assign to the object. 12751 * @returns {Object} Returns the new object. 12752 * @example 12753 * 12754 * function Shape() { 12755 * this.x = 0; 12756 * this.y = 0; 12757 * } 12758 * 12759 * function Circle() { 12760 * Shape.call(this); 12761 * } 12762 * 12763 * Circle.prototype = _.create(Shape.prototype, { 12764 * 'constructor': Circle 12765 * }); 12766 * 12767 * var circle = new Circle; 12768 * circle instanceof Circle; 12769 * // => true 12770 * 12771 * circle instanceof Shape; 12772 * // => true 12773 */ 12774 function create(prototype, properties) { 12775 var result = baseCreate(prototype); 12776 return properties == null ? result : baseAssign(result, properties); 12777 } 12778 12779 /** 12780 * Assigns own and inherited enumerable string keyed properties of source 12781 * objects to the destination object for all destination properties that 12782 * resolve to `undefined`. Source objects are applied from left to right. 12783 * Once a property is set, additional values of the same property are ignored. 12784 * 12785 * **Note:** This method mutates `object`. 12786 * 12787 * @static 12788 * @since 0.1.0 12789 * @memberOf _ 12790 * @category Object 12791 * @param {Object} object The destination object. 12792 * @param {...Object} [sources] The source objects. 12793 * @returns {Object} Returns `object`. 12794 * @see _.defaultsDeep 12795 * @example 12796 * 12797 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 12798 * // => { 'a': 1, 'b': 2 } 12799 */ 12800 var defaults = baseRest(function(
12800args) { 12801 args.push(undefined, customDefaultsAssignIn); 12802 return apply(assignInWith, undefined, args)
vendor: 11,675 bytes, lines 12802-13199
12802; 12803 }); 12804 12805 /** 12806 * This method is like `_.defaults` except that it recursively assigns 12807 * default properties. 12808 * 12809 * **Note:** This method mutates `object`. 12810 * 12811 * @static 12812 * @memberOf _ 12813 * @since 3.10.0 12814 * @category Object 12815 * @param {Object} object The destination object. 12816 * @param {...Object} [sources] The source objects. 12817 * @returns {Object} Returns `object`. 12818 * @see _.defaults 12819 * @example 12820 * 12821 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 12822 * // => { 'a': { 'b': 2, 'c': 3 } } 12823 */ 12824 var defaultsDeep = baseRest(function(args) { 12825 args.push(undefined, customDefaultsMerge); 12826 return apply(mergeWith, undefined, args); 12827 }); 12828 12829 /** 12830 * This method is like `_.find` except that it returns the key of the first 12831 * element `predicate` returns truthy for instead of the element itself. 12832 * 12833 * @static 12834 * @memberOf _ 12835 * @since 1.1.0 12836 * @category Object 12837 * @param {Object} object The object to inspect. 12838 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12839 * @returns {string|undefined} Returns the key of the matched element, 12840 * else `undefined`. 12841 * @example 12842 * 12843 * var users = { 12844 * 'barney': { 'age': 36, 'active': true }, 12845 * 'fred': { 'age': 40, 'active': false }, 12846 * 'pebbles': { 'age': 1, 'active': true } 12847 * }; 12848 * 12849 * _.findKey(users, function(o) { return o.age < 40; }); 12850 * // => 'barney' (iteration order is not guaranteed) 12851 * 12852 * // The `_.matches` iteratee shorthand. 12853 * _.findKey(users, { 'age': 1, 'active': true }); 12854 * // => 'pebbles' 12855 * 12856 * // The `_.matchesProperty` iteratee shorthand. 12857 * _.findKey(users, ['active', false]); 12858 * // => 'fred' 12859 * 12860 * // The `_.property` iteratee shorthand. 12861 * _.findKey(users, 'active'); 12862 * // => 'barney' 12863 */ 12864 function findKey(object, predicate) { 12865 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 12866 } 12867 12868 /** 12869 * This method is like `_.findKey` except that it iterates over elements of 12870 * a collection in the opposite order. 12871 * 12872 * @static 12873 * @memberOf _ 12874 * @since 2.0.0 12875 * @category Object 12876 * @param {Object} object The object to inspect. 12877 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12878 * @returns {string|undefined} Returns the key of the matched element, 12879 * else `undefined`. 12880 * @example 12881 * 12882 * var users = { 12883 * 'barney': { 'age': 36, 'active': true }, 12884 * 'fred': { 'age': 40, 'active': false }, 12885 * 'pebbles': { 'age': 1, 'active': true } 12886 * }; 12887 * 12888 * _.findLastKey(users, function(o) { return o.age < 40; }); 12889 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 12890 * 12891 * // The `_.matches` iteratee shorthand. 12892 * _.findLastKey(users, { 'age': 36, 'active': true }); 12893 * // => 'barney' 12894 * 12895 * // The `_.matchesProperty` iteratee shorthand. 12896 * _.findLastKey(users, ['active', false]); 12897 * // => 'fred' 12898 * 12899 * // The `_.property` iteratee shorthand. 12900 * _.findLastKey(users, 'active'); 12901 * // => 'pebbles' 12902 */ 12903 function findLastKey(object, predicate) { 12904 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 12905 } 12906 12907 /** 12908 * Iterates over own and inherited enumerable string keyed properties of an 12909 * object and invokes `iteratee` for each property. The iteratee is invoked 12910 * with three arguments: (value, key, object). Iteratee functions may exit 12911 * iteration early by explicitly returning `false`. 12912 * 12913 * @static 12914 * @memberOf _ 12915 * @since 0.3.0 12916 * @category Object 12917 * @param {Object} object The object to iterate over. 12918 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 12919 * @returns {Object} Returns `object`. 12920 * @see _.forInRight 12921 * @example 12922 * 12923 * function Foo() { 12924 * this.a = 1; 12925 * this.b = 2; 12926 * } 12927 * 12928 * Foo.prototype.c = 3; 12929 * 12930 * _.forIn(new Foo, function(value, key) { 12931 * console.log(key); 12932 * }); 12933 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 12934 */ 12935 function forIn(object, iteratee) { 12936 return object == null 12937 ? object 12938 : baseFor(object, getIteratee(iteratee, 3), keysIn); 12939 } 12940 12941 /** 12942 * This method is like `_.forIn` except that it iterates over properties of 12943 * `object` in the opposite order. 12944 * 12945 * @static 12946 * @memberOf _ 12947 * @since 2.0.0 12948 * @category Object 12949 * @param {Object} object The object to iterate over. 12950 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 12951 * @returns {Object} Returns `object`. 12952 * @see _.forIn 12953 * @example 12954 * 12955 * function Foo() { 12956 * this.a = 1; 12957 * this.b = 2; 12958 * } 12959 * 12960 * Foo.prototype.c = 3; 12961 * 12962 * _.forInRight(new Foo, function(value, key) { 12963 * console.log(key); 12964 * }); 12965 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 12966 */ 12967 function forInRight(object, iteratee) { 12968 return object == null 12969 ? object 12970 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 12971 } 12972 12973 /** 12974 * Iterates over own enumerable string keyed properties of an object and 12975 * invokes `iteratee` for each property. The iteratee is invoked with three 12976 * arguments: (value, key, object). Iteratee functions may exit iteration 12977 * early by explicitly returning `false`. 12978 * 12979 * @static 12980 * @memberOf _ 12981 * @since 0.3.0 12982 * @category Object 12983 * @param {Object} object The object to iterate over. 12984 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 12985 * @returns {Object} Returns `object`. 12986 * @see _.forOwnRight 12987 * @example 12988 * 12989 * function Foo() { 12990 * this.a = 1; 12991 * this.b = 2; 12992 * } 12993 * 12994 * Foo.prototype.c = 3; 12995 * 12996 * _.forOwn(new Foo, function(value, key) { 12997 * console.log(key); 12998 * }); 12999 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 13000 */ 13001 function forOwn(object, iteratee) { 13002 return object && baseForOwn(object, getIteratee(iteratee, 3)); 13003 } 13004 13005 /** 13006 * This method is like `_.forOwn` except that it iterates over properties of 13007 * `object` in the opposite order. 13008 * 13009 * @static 13010 * @memberOf _ 13011 * @since 2.0.0 13012 * @category Object 13013 * @param {Object} object The object to iterate over. 13014 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13015 * @returns {Object} Returns `object`. 13016 * @see _.forOwn 13017 * @example 13018 * 13019 * function Foo() { 13020 * this.a = 1; 13021 * this.b = 2; 13022 * } 13023 * 13024 * Foo.prototype.c = 3; 13025 * 13026 * _.forOwnRight(new Foo, function(value, key) { 13027 * console.log(key); 13028 * }); 13029 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 13030 */ 13031 function forOwnRight(object, iteratee) { 13032 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 13033 } 13034 13035 /** 13036 * Creates an array of function property names from own enumerable properties 13037 * of `object`. 13038 * 13039 * @static 13040 * @since 0.1.0 13041 * @memberOf _ 13042 * @category Object 13043 * @param {Object} object The object to inspect. 13044 * @returns {Array} Returns the function names. 13045 * @see _.functionsIn 13046 * @example 13047 * 13048 * function Foo() { 13049 * this.a = _.constant('a'); 13050 * this.b = _.constant('b'); 13051 * } 13052 * 13053 * Foo.prototype.c = _.constant('c'); 13054 * 13055 * _.functions(new Foo); 13056 * // => ['a', 'b'] 13057 */ 13058 function functions(object) { 13059 return object == null ? [] : baseFunctions(object, keys(object)); 13060 } 13061 13062 /** 13063 * Creates an array of function property names from own and inherited 13064 * enumerable properties of `object`. 13065 * 13066 * @static 13067 * @memberOf _ 13068 * @since 4.0.0 13069 * @category Object 13070 * @param {Object} object The object to inspect. 13071 * @returns {Array} Returns the function names. 13072 * @see _.functions 13073 * @example 13074 * 13075 * function Foo() { 13076 * this.a = _.constant('a'); 13077 * this.b = _.constant('b'); 13078 * } 13079 * 13080 * Foo.prototype.c = _.constant('c'); 13081 * 13082 * _.functionsIn(new Foo); 13083 * // => ['a', 'b', 'c'] 13084 */ 13085 function functionsIn(object) { 13086 return object == null ? [] : baseFunctions(object, keysIn(object)); 13087 } 13088 13089 /** 13090 * Gets the value at `path` of `object`. If the resolved value is 13091 * `undefined`, the `defaultValue` is returned in its place. 13092 * 13093 * @static 13094 * @memberOf _ 13095 * @since 3.7.0 13096 * @category Object 13097 * @param {Object} object The object to query. 13098 * @param {Array|string} path The path of the property to get. 13099 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 13100 * @returns {*} Returns the resolved value. 13101 * @example 13102 * 13103 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 13104 * 13105 * _.get(object, 'a[0].b.c'); 13106 * // => 3 13107 * 13108 * _.get(object, ['a', '0', 'b', 'c']); 13109 * // => 3 13110 * 13111 * _.get(object, 'a.b.c', 'default'); 13112 * // => 'default' 13113 */ 13114 function get(object, path, defaultValue) { 13115 var result = object == null ? undefined : baseGet(object, path); 13116 return result === undefined ? defaultValue : result; 13117 } 13118 13119 /** 13120 * Checks if `path` is a direct property of `object`. 13121 * 13122 * @static 13123 * @since 0.1.0 13124 * @memberOf _ 13125 * @category Object 13126 * @param {Object} object The object to query. 13127 * @param {Array|string} path The path to check. 13128 * @returns {boolean} Returns `true` if `path` exists, else `false`. 13129 * @example 13130 * 13131 * var object = { 'a': { 'b': 2 } }; 13132 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 13133 * 13134 * _.has(object, 'a'); 13135 * // => true 13136 * 13137 * _.has(object, 'a.b'); 13138 * // => true 13139 * 13140 * _.has(object, ['a', 'b']); 13141 * // => true 13142 * 13143 * _.has(other, 'a'); 13144 * // => false 13145 */ 13146 function has(object, path) { 13147 return object != null && hasPath(object, path, baseHas); 13148 } 13149 13150 /** 13151 * Checks if `path` is a direct or inherited property of `object`. 13152 * 13153 * @static 13154 * @memberOf _ 13155 * @since 4.0.0 13156 * @category Object 13157 * @param {Object} object The object to query. 13158 * @param {Array|string} path The path to check. 13159 * @returns {boolean} Returns `true` if `path` exists, else `false`. 13160 * @example 13161 * 13162 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 13163 * 13164 * _.hasIn(object, 'a'); 13165 * // => true 13166 * 13167 * _.hasIn(object, 'a.b'); 13168 * // => true 13169 * 13170 * _.hasIn(object, ['a', 'b']); 13171 * // => true 13172 * 13173 * _.hasIn(object, 'b'); 13174 * // => false 13175 */ 13176 function hasIn(object, path) { 13177 return object != null && hasPath(object, path, baseHasIn); 13178 } 13179 13180 /** 13181 * Creates an object composed of the inverted keys and values of `object`. 13182 * If `object` contains duplicate values, subsequent values overwrite 13183 * property assignments of previous values. 13184 * 13185 * @static 13186 * @memberOf _ 13187 * @since 0.7.0 13188 * @category Object 13189 * @param {Object} object The object to invert. 13190 * @returns {Object} Returns the new inverted object. 13191 * @example 13192 * 13193 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 13194 * 13195 * _.invert(object); 13196 * // => { '1': 'c', '2': 'b' } 13197 */ 13198 var invert = createInverter(function(result, value, key) { 13199
13199result[value] = key; 13200 }, constant(identity)); 13201 13202 /** 13203 * This method is like `_.invert` except that the inverted object is generated 13204 * from the results of running each element of `object` thru `iteratee`. The 13205 * corresponding inverted value of each inverted key is an array of keys 13206 * responsible for generating the inverted value. The iteratee is invoked 13207 * with one argument: (value). 13208 * 13209 * @static 13210 * @memberOf _ 13211 * @since 4.1.0 13212 * @category Object 13213 * @param {Object} object The object to invert. 13214 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13215 * @returns {Object} Returns the new inverted object. 13216 * @example 13217 * 13218 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 13219 * 13220 * _.invertBy(object); 13221 * // => { '1': ['a', 'c'], '2': ['b'] } 13222 * 13223 * _.invertBy(object, function(value) { 13224 * return 'group' + value; 13225 * }); 13226 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 13227 */ 13228 var invertBy = createInverter(function(result, value, key) {
vendor: 9,906 bytes, lines 13228-13541
13228 13229 if (hasOwnProperty.call(result, value)) { 13230 result[value].push(key); 13231 } else { 13232 result[value] = [key]; 13233 } 13234 }, getIteratee); 13235 13236 /** 13237 * Invokes the method at `path` of `object`. 13238 * 13239 * @static 13240 * @memberOf _ 13241 * @since 4.0.0 13242 * @category Object 13243 * @param {Object} object The object to query. 13244 * @param {Array|string} path The path of the method to invoke. 13245 * @param {...*} [args] The arguments to invoke the method with. 13246 * @returns {*} Returns the result of the invoked method. 13247 * @example 13248 * 13249 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 13250 * 13251 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 13252 * // => [2, 3] 13253 */ 13254 var invoke = baseRest(baseInvoke); 13255 13256 /** 13257 * Creates an array of the own enumerable property names of `object`. 13258 * 13259 * **Note:** Non-object values are coerced to objects. See the 13260 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 13261 * for more details. 13262 * 13263 * @static 13264 * @since 0.1.0 13265 * @memberOf _ 13266 * @category Object 13267 * @param {Object} object The object to query. 13268 * @returns {Array} Returns the array of property names. 13269 * @example 13270 * 13271 * function Foo() { 13272 * this.a = 1; 13273 * this.b = 2; 13274 * } 13275 * 13276 * Foo.prototype.c = 3; 13277 * 13278 * _.keys(new Foo); 13279 * // => ['a', 'b'] (iteration order is not guaranteed) 13280 * 13281 * _.keys('hi'); 13282 * // => ['0', '1'] 13283 */ 13284 function keys(object) { 13285 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 13286 } 13287 13288 /** 13289 * Creates an array of the own and inherited enumerable property names of `object`. 13290 * 13291 * **Note:** Non-object values are coerced to objects. 13292 * 13293 * @static 13294 * @memberOf _ 13295 * @since 3.0.0 13296 * @category Object 13297 * @param {Object} object The object to query. 13298 * @returns {Array} Returns the array of property names. 13299 * @example 13300 * 13301 * function Foo() { 13302 * this.a = 1; 13303 * this.b = 2; 13304 * } 13305 * 13306 * Foo.prototype.c = 3; 13307 * 13308 * _.keysIn(new Foo); 13309 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 13310 */ 13311 function keysIn(object) { 13312 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 13313 } 13314 13315 /** 13316 * The opposite of `_.mapValues`; this method creates an object with the 13317 * same values as `object` and keys generated by running each own enumerable 13318 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 13319 * with three arguments: (value, key, object). 13320 * 13321 * @static 13322 * @memberOf _ 13323 * @since 3.8.0 13324 * @category Object 13325 * @param {Object} object The object to iterate over. 13326 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13327 * @returns {Object} Returns the new mapped object. 13328 * @see _.mapValues 13329 * @example 13330 * 13331 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 13332 * return key + value; 13333 * }); 13334 * // => { 'a1': 1, 'b2': 2 } 13335 */ 13336 function mapKeys(object, iteratee) { 13337 var result = {}; 13338 iteratee = getIteratee(iteratee, 3); 13339 13340 baseForOwn(object, function(value, key, object) { 13341 baseAssignValue(result, iteratee(value, key, object), value); 13342 }); 13343 return result; 13344 } 13345 13346 /** 13347 * Creates an object with the same keys as `object` and values generated 13348 * by running each own enumerable string keyed property of `object` thru 13349 * `iteratee`. The iteratee is invoked with three arguments: 13350 * (value, key, object). 13351 * 13352 * @static 13353 * @memberOf _ 13354 * @since 2.4.0 13355 * @category Object 13356 * @param {Object} object The object to iterate over. 13357 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13358 * @returns {Object} Returns the new mapped object. 13359 * @see _.mapKeys 13360 * @example 13361 * 13362 * var users = { 13363 * 'fred': { 'user': 'fred', 'age': 40 }, 13364 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 13365 * }; 13366 * 13367 * _.mapValues(users, function(o) { return o.age; }); 13368 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 13369 * 13370 * // The `_.property` iteratee shorthand. 13371 * _.mapValues(users, 'age'); 13372 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 13373 */ 13374 function mapValues(object, iteratee) { 13375 var result = {}; 13376 iteratee = getIteratee(iteratee, 3); 13377 13378 baseForOwn(object, function(value, key, object) { 13379 baseAssignValue(result, key, iteratee(value, key, object)); 13380 }); 13381 return result; 13382 } 13383 13384 /** 13385 * This method is like `_.assign` except that it recursively merges own and 13386 * inherited enumerable string keyed properties of source objects into the 13387 * destination object. Source properties that resolve to `undefined` are 13388 * skipped if a destination value exists. Array and plain object properties 13389 * are merged recursively. Other objects and value types are overridden by 13390 * assignment. Source objects are applied from left to right. Subsequent 13391 * sources overwrite property assignments of previous sources. 13392 * 13393 * **Note:** This method mutates `object`. 13394 * 13395 * @static 13396 * @memberOf _ 13397 * @since 0.5.0 13398 * @category Object 13399 * @param {Object} object The destination object. 13400 * @param {...Object} [sources] The source objects. 13401 * @returns {Object} Returns `object`. 13402 * @example 13403 * 13404 * var object = { 13405 * 'a': [{ 'b': 2 }, { 'd': 4 }] 13406 * }; 13407 * 13408 * var other = { 13409 * 'a': [{ 'c': 3 }, { 'e': 5 }] 13410 * }; 13411 * 13412 * _.merge(object, other); 13413 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 13414 */ 13415 var merge = createAssigner(function(object, source, srcIndex) { 13416 baseMerge(object, source, srcIndex); 13417 }); 13418 13419 /** 13420 * This method is like `_.merge` except that it accepts `customizer` which 13421 * is invoked to produce the merged values of the destination and source 13422 * properties. If `customizer` returns `undefined`, merging is handled by the 13423 * method instead. The `customizer` is invoked with six arguments: 13424 * (objValue, srcValue, key, object, source, stack). 13425 * 13426 * **Note:** This method mutates `object`. 13427 * 13428 * @static 13429 * @memberOf _ 13430 * @since 4.0.0 13431 * @category Object 13432 * @param {Object} object The destination object. 13433 * @param {...Object} sources The source objects. 13434 * @param {Function} customizer The function to customize assigned values. 13435 * @returns {Object} Returns `object`. 13436 * @example 13437 * 13438 * function customizer(objValue, srcValue) { 13439 * if (_.isArray(objValue)) { 13440 * return objValue.concat(srcValue); 13441 * } 13442 * } 13443 * 13444 * var object = { 'a': [1], 'b': [2] }; 13445 * var other = { 'a': [3], 'b': [4] }; 13446 * 13447 * _.mergeWith(object, other, customizer); 13448 * // => { 'a': [1, 3], 'b': [2, 4] } 13449 */ 13450 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 13451 baseMerge(object, source, srcIndex, customizer); 13452 }); 13453 13454 /** 13455 * The opposite of `_.pick`; this method creates an object composed of the 13456 * own and inherited enumerable property paths of `object` that are not omitted. 13457 * 13458 * **Note:** This method is considerably slower than `_.pick`. 13459 * 13460 * @static 13461 * @since 0.1.0 13462 * @memberOf _ 13463 * @category Object 13464 * @param {Object} object The source object. 13465 * @param {...(string|string[])} [paths] The property paths to omit. 13466 * @returns {Object} Returns the new object. 13467 * @example 13468 * 13469 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 13470 * 13471 * _.omit(object, ['a', 'c']); 13472 * // => { 'b': '2' } 13473 */ 13474 var omit = flatRest(function(object, paths) { 13475 var result = {}; 13476 if (object == null) { 13477 return result; 13478 } 13479 var isDeep = false; 13480 paths = arrayMap(paths, function(path) { 13481 path = castPath(path, object); 13482 isDeep || (isDeep = path.length > 1); 13483 return path; 13484 }); 13485 copyObject(object, getAllKeysIn(object), result); 13486 if (isDeep) { 13487 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 13488 } 13489 var length = paths.length; 13490 while (length--) { 13491 baseUnset(result, paths[length]); 13492 } 13493 return result; 13494 }); 13495 13496 /** 13497 * The opposite of `_.pickBy`; this method creates an object composed of 13498 * the own and inherited enumerable string keyed properties of `object` that 13499 * `predicate` doesn't return truthy for. The predicate is invoked with two 13500 * arguments: (value, key). 13501 * 13502 * @static 13503 * @memberOf _ 13504 * @since 4.0.0 13505 * @category Object 13506 * @param {Object} object The source object. 13507 * @param {Function} [predicate=_.identity] The function invoked per property. 13508 * @returns {Object} Returns the new object. 13509 * @example 13510 * 13511 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 13512 * 13513 * _.omitBy(object, _.isNumber); 13514 * // => { 'b': '2' } 13515 */ 13516 function omitBy(object, predicate) { 13517 return pickBy(object, negate(getIteratee(predicate))); 13518 } 13519 13520 /** 13521 * Creates an object composed of the picked `object` properties. 13522 * 13523 * @static 13524 * @since 0.1.0 13525 * @memberOf _ 13526 * @category Object 13527 * @param {Object} object The source object. 13528 * @param {...(string|string[])} [paths] The property paths to pick. 13529 * @returns {Object} Returns the new object. 13530 * @example 13531 * 13532 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 13533 * 13534 * _.pick(object, ['a', 'c']); 13535 * // => { 'a': 1, 'c': 3 } 13536 */ 13537 var pick = flatRest(function(object, paths) { 13538 return object == null ? {} : basePick(object, paths); 13539 }); 13540 13541 /**
vendor: 11,160 bytes, lines 13542-13880
13542 * Creates an object composed of the `object` properties `predicate` returns 13543 * truthy for. The predicate is invoked with two arguments: (value, key). 13544 * 13545 * @static 13546 * @memberOf _ 13547 * @since 4.0.0 13548 * @category Object 13549 * @param {Object} object The source object. 13550 * @param {Function} [predicate=_.identity] The function invoked per property. 13551 * @returns {Object} Returns the new object. 13552 * @example 13553 * 13554 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 13555 * 13556 * _.pickBy(object, _.isNumber); 13557 * // => { 'a': 1, 'c': 3 } 13558 */ 13559 function pickBy(object, predicate) { 13560 if (object == null) { 13561 return {}; 13562 } 13563 var props = arrayMap(getAllKeysIn(object), function(prop) { 13564 return [prop]; 13565 }); 13566 predicate = getIteratee(predicate); 13567 return basePickBy(object, props, function(value, path) { 13568 return predicate(value, path[0]); 13569 }); 13570 } 13571 13572 /** 13573 * This method is like `_.get` except that if the resolved value is a 13574 * function it's invoked with the `this` binding of its parent object and 13575 * its result is returned. 13576 * 13577 * @static 13578 * @since 0.1.0 13579 * @memberOf _ 13580 * @category Object 13581 * @param {Object} object The object to query. 13582 * @param {Array|string} path The path of the property to resolve. 13583 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 13584 * @returns {*} Returns the resolved value. 13585 * @example 13586 * 13587 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 13588 * 13589 * _.result(object, 'a[0].b.c1'); 13590 * // => 3 13591 * 13592 * _.result(object, 'a[0].b.c2'); 13593 * // => 4 13594 * 13595 * _.result(object, 'a[0].b.c3', 'default'); 13596 * // => 'default' 13597 * 13598 * _.result(object, 'a[0].b.c3', _.constant('default')); 13599 * // => 'default' 13600 */ 13601 function result(object, path, defaultValue) { 13602 path = castPath(path, object); 13603 13604 var index = -1, 13605 length = path.length; 13606 13607 // Ensure the loop is entered when path is empty. 13608 if (!length) { 13609 length = 1; 13610 object = undefined; 13611 } 13612 while (++index < length) { 13613 var value = object == null ? undefined : object[toKey(path[index])]; 13614 if (value === undefined) { 13615 index = length; 13616 value = defaultValue; 13617 } 13618 object = isFunction(value) ? value.call(object) : value; 13619 } 13620 return object; 13621 } 13622 13623 /** 13624 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 13625 * it's created. Arrays are created for missing index properties while objects 13626 * are created for all other missing properties. Use `_.setWith` to customize 13627 * `path` creation. 13628 * 13629 * **Note:** This method mutates `object`. 13630 * 13631 * @static 13632 * @memberOf _ 13633 * @since 3.7.0 13634 * @category Object 13635 * @param {Object} object The object to modify. 13636 * @param {Array|string} path The path of the property to set. 13637 * @param {*} value The value to set. 13638 * @returns {Object} Returns `object`. 13639 * @example 13640 * 13641 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 13642 * 13643 * _.set(object, 'a[0].b.c', 4); 13644 * console.log(object.a[0].b.c); 13645 * // => 4 13646 * 13647 * _.set(object, ['x', '0', 'y', 'z'], 5); 13648 * console.log(object.x[0].y.z); 13649 * // => 5 13650 */ 13651 function set(object, path, value) { 13652 return object == null ? object : baseSet(object, path, value); 13653 } 13654 13655 /** 13656 * This method is like `_.set` except that it accepts `customizer` which is 13657 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 13658 * path creation is handled by the method instead. The `customizer` is invoked 13659 * with three arguments: (nsValue, key, nsObject). 13660 * 13661 * **Note:** This method mutates `object`. 13662 * 13663 * @static 13664 * @memberOf _ 13665 * @since 4.0.0 13666 * @category Object 13667 * @param {Object} object The object to modify. 13668 * @param {Array|string} path The path of the property to set. 13669 * @param {*} value The value to set. 13670 * @param {Function} [customizer] The function to customize assigned values. 13671 * @returns {Object} Returns `object`. 13672 * @example 13673 * 13674 * var object = {}; 13675 * 13676 * _.setWith(object, '[0][1]', 'a', Object); 13677 * // => { '0': { '1': 'a' } } 13678 */ 13679 function setWith(object, path, value, customizer) { 13680 customizer = typeof customizer == 'function' ? customizer : undefined; 13681 return object == null ? object : baseSet(object, path, value, customizer); 13682 } 13683 13684 /** 13685 * Creates an array of own enumerable string keyed-value pairs for `object` 13686 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 13687 * entries are returned. 13688 * 13689 * @static 13690 * @memberOf _ 13691 * @since 4.0.0 13692 * @alias entries 13693 * @category Object 13694 * @param {Object} object The object to query. 13695 * @returns {Array} Returns the key-value pairs. 13696 * @example 13697 * 13698 * function Foo() { 13699 * this.a = 1; 13700 * this.b = 2; 13701 * } 13702 * 13703 * Foo.prototype.c = 3; 13704 * 13705 * _.toPairs(new Foo); 13706 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 13707 */ 13708 var toPairs = createToPairs(keys); 13709 13710 /** 13711 * Creates an array of own and inherited enumerable string keyed-value pairs 13712 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 13713 * or set, its entries are returned. 13714 * 13715 * @static 13716 * @memberOf _ 13717 * @since 4.0.0 13718 * @alias entriesIn 13719 * @category Object 13720 * @param {Object} object The object to query. 13721 * @returns {Array} Returns the key-value pairs. 13722 * @example 13723 * 13724 * function Foo() { 13725 * this.a = 1; 13726 * this.b = 2; 13727 * } 13728 * 13729 * Foo.prototype.c = 3; 13730 * 13731 * _.toPairsIn(new Foo); 13732 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 13733 */ 13734 var toPairsIn = createToPairs(keysIn); 13735 13736 /** 13737 * An alternative to `_.reduce`; this method transforms `object` to a new 13738 * `accumulator` object which is the result of running each of its own 13739 * enumerable string keyed properties thru `iteratee`, with each invocation 13740 * potentially mutating the `accumulator` object. If `accumulator` is not 13741 * provided, a new object with the same `[[Prototype]]` will be used. The 13742 * iteratee is invoked with four arguments: (accumulator, value, key, object). 13743 * Iteratee functions may exit iteration early by explicitly returning `false`. 13744 * 13745 * @static 13746 * @memberOf _ 13747 * @since 1.3.0 13748 * @category Object 13749 * @param {Object} object The object to iterate over. 13750 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 13751 * @param {*} [accumulator] The custom accumulator value. 13752 * @returns {*} Returns the accumulated value. 13753 * @example 13754 * 13755 * _.transform([2, 3, 4], function(result, n) { 13756 * result.push(n *= n); 13757 * return n % 2 == 0; 13758 * }, []); 13759 * // => [4, 9] 13760 * 13761 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 13762 * (result[value] || (result[value] = [])).push(key); 13763 * }, {}); 13764 * // => { '1': ['a', 'c'], '2': ['b'] } 13765 */ 13766 function transform(object, iteratee, accumulator) { 13767 var isArr = isArray(object), 13768 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 13769 13770 iteratee = getIteratee(iteratee, 4); 13771 if (accumulator == null) { 13772 var Ctor = object && object.constructor; 13773 if (isArrLike) { 13774 accumulator = isArr ? new Ctor : []; 13775 } 13776 else if (isObject(object)) { 13777 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 13778 } 13779 else { 13780 accumulator = {}; 13781 } 13782 } 13783 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 13784 return iteratee(accumulator, value, index, object); 13785 }); 13786 return accumulator; 13787 } 13788 13789 /** 13790 * Removes the property at `path` of `object`. 13791 * 13792 * **Note:** This method mutates `object`. 13793 * 13794 * @static 13795 * @memberOf _ 13796 * @since 4.0.0 13797 * @category Object 13798 * @param {Object} object The object to modify. 13799 * @param {Array|string} path The path of the property to unset. 13800 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 13801 * @example 13802 * 13803 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 13804 * _.unset(object, 'a[0].b.c'); 13805 * // => true 13806 * 13807 * console.log(object); 13808 * // => { 'a': [{ 'b': {} }] }; 13809 * 13810 * _.unset(object, ['a', '0', 'b', 'c']); 13811 * // => true 13812 * 13813 * console.log(object); 13814 * // => { 'a': [{ 'b': {} }] }; 13815 */ 13816 function unset(object, path) { 13817 return object == null ? true : baseUnset(object, path); 13818 } 13819 13820 /** 13821 * This method is like `_.set` except that accepts `updater` to produce the 13822 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 13823 * is invoked with one argument: (value). 13824 * 13825 * **Note:** This method mutates `object`. 13826 * 13827 * @static 13828 * @memberOf _ 13829 * @since 4.6.0 13830 * @category Object 13831 * @param {Object} object The object to modify. 13832 * @param {Array|string} path The path of the property to set. 13833 * @param {Function} updater The function to produce the updated value. 13834 * @returns {Object} Returns `object`. 13835 * @example 13836 * 13837 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 13838 * 13839 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 13840 * console.log(object.a[0].b.c); 13841 * // => 9 13842 * 13843 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 13844 * console.log(object.x[0].y.z); 13845 * // => 0 13846 */ 13847 function update(object, path, updater) { 13848 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 13849 } 13850 13851 /** 13852 * This method is like `_.update` except that it accepts `customizer` which is 13853 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 13854 * path creation is handled by the method instead. The `customizer` is invoked 13855 * with three arguments: (nsValue, key, nsObject). 13856 * 13857 * **Note:** This method mutates `object`. 13858 * 13859 * @static 13860 * @memberOf _ 13861 * @since 4.6.0 13862 * @category Object 13863 * @param {Object} object The object to modify. 13864 * @param {Array|string} path The path of the property to set. 13865 * @param {Function} updater The function to produce the updated value. 13866 * @param {Function} [customizer] The function to customize assigned values. 13867 * @returns {Object} Returns `object`. 13868 * @example 13869 * 13870 * var object = {}; 13871 * 13872 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 13873 * // => { '0': { '1': 'a' } } 13874 */ 13875 function updateWith(object, path, updater, customizer) { 13876 customizer = typeof customizer == 'function' ? customizer : undefined; 13877 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 13878 } 13879 13880 /**
vendor: 1,263 bytes, lines 13881-13930
13881 * Creates an array of the own enumerable string keyed property values of `object`. 13882 * 13883 * **Note:** Non-object values are coerced to objects. 13884 * 13885 * @static 13886 * @since 0.1.0 13887 * @memberOf _ 13888 * @category Object 13889 * @param {Object} object The object to query. 13890 * @returns {Array} Returns the array of property values. 13891 * @example 13892 * 13893 * function Foo() { 13894 * this.a = 1; 13895 * this.b = 2; 13896 * } 13897 * 13898 * Foo.prototype.c = 3; 13899 * 13900 * _.values(new Foo); 13901 * // => [1, 2] (iteration order is not guaranteed) 13902 * 13903 * _.values('hi'); 13904 * // => ['h', 'i'] 13905 */ 13906 function values(object) { 13907 return object == null ? [] : baseValues(object, keys(object)); 13908 } 13909 13910 /** 13911 * Creates an array of the own and inherited enumerable string keyed property 13912 * values of `object`. 13913 * 13914 * **Note:** Non-object values are coerced to objects. 13915 * 13916 * @static 13917 * @memberOf _ 13918 * @since 3.0.0 13919 * @category Object 13920 * @param {Object} object The object to query. 13921 * @returns {Array} Returns the array of property values. 13922 * @example 13923 * 13924 * function Foo() { 13925 * this.a = 1; 13926 * this.b = 2; 13927 * } 13928 * 13929 * Foo.prototype.c = 3; 13930 *
vendor: 9,679 bytes, lines 13931-14251
13931 * _.valuesIn(new Foo); 13932 * // => [1, 2, 3] (iteration order is not guaranteed) 13933 */ 13934 function valuesIn(object) { 13935 return object == null ? [] : baseValues(object, keysIn(object)); 13936 } 13937 13938 /*------------------------------------------------------------------------*/ 13939 13940 /** 13941 * Clamps `number` within the inclusive `lower` and `upper` bounds. 13942 * 13943 * @static 13944 * @memberOf _ 13945 * @since 4.0.0 13946 * @category Number 13947 * @param {number} number The number to clamp. 13948 * @param {number} [lower] The lower bound. 13949 * @param {number} upper The upper bound. 13950 * @returns {number} Returns the clamped number. 13951 * @example 13952 * 13953 * _.clamp(-10, -5, 5); 13954 * // => -5 13955 * 13956 * _.clamp(10, -5, 5); 13957 * // => 5 13958 */ 13959 function clamp(number, lower, upper) { 13960 if (upper === undefined) { 13961 upper = lower; 13962 lower = undefined; 13963 } 13964 if (upper !== undefined) { 13965 upper = toNumber(upper); 13966 upper = upper === upper ? upper : 0; 13967 } 13968 if (lower !== undefined) { 13969 lower = toNumber(lower); 13970 lower = lower === lower ? lower : 0; 13971 } 13972 return baseClamp(toNumber(number), lower, upper); 13973 } 13974 13975 /** 13976 * Checks if `n` is between `start` and up to, but not including, `end`. If 13977 * `end` is not specified, it's set to `start` with `start` then set to `0`. 13978 * If `start` is greater than `end` the params are swapped to support 13979 * negative ranges. 13980 * 13981 * @static 13982 * @memberOf _ 13983 * @since 3.3.0 13984 * @category Number 13985 * @param {number} number The number to check. 13986 * @param {number} [start=0] The start of the range. 13987 * @param {number} end The end of the range. 13988 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 13989 * @see _.range, _.rangeRight 13990 * @example 13991 * 13992 * _.inRange(3, 2, 4); 13993 * // => true 13994 * 13995 * _.inRange(4, 8); 13996 * // => true 13997 * 13998 * _.inRange(4, 2); 13999 * // => false 14000 * 14001 * _.inRange(2, 2); 14002 * // => false 14003 * 14004 * _.inRange(1.2, 2); 14005 * // => true 14006 * 14007 * _.inRange(5.2, 4); 14008 * // => false 14009 * 14010 * _.inRange(-3, -2, -6); 14011 * // => true 14012 */ 14013 function inRange(number, start, end) { 14014 start = toFinite(start); 14015 if (end === undefined) { 14016 end = start; 14017 start = 0; 14018 } else { 14019 end = toFinite(end); 14020 } 14021 number = toNumber(number); 14022 return baseInRange(number, start, end); 14023 } 14024 14025 /** 14026 * Produces a random number between the inclusive `lower` and `upper` bounds. 14027 * If only one argument is provided a number between `0` and the given number 14028 * is returned. If `floating` is `true`, or either `lower` or `upper` are 14029 * floats, a floating-point number is returned instead of an integer. 14030 * 14031 * **Note:** JavaScript follows the IEEE-754 standard for resolving 14032 * floating-point values which can produce unexpected results. 14033 * 14034 * @static 14035 * @memberOf _ 14036 * @since 0.7.0 14037 * @category Number 14038 * @param {number} [lower=0] The lower bound. 14039 * @param {number} [upper=1] The upper bound. 14040 * @param {boolean} [floating] Specify returning a floating-point number. 14041 * @returns {number} Returns the random number. 14042 * @example 14043 * 14044 * _.random(0, 5); 14045 * // => an integer between 0 and 5 14046 * 14047 * _.random(5); 14048 * // => also an integer between 0 and 5 14049 * 14050 * _.random(5, true); 14051 * // => a floating-point number between 0 and 5 14052 * 14053 * _.random(1.2, 5.2); 14054 * // => a floating-point number between 1.2 and 5.2 14055 */ 14056 function random(lower, upper, floating) { 14057 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 14058 upper = floating = undefined; 14059 } 14060 if (floating === undefined) { 14061 if (typeof upper == 'boolean') { 14062 floating = upper; 14063 upper = undefined; 14064 } 14065 else if (typeof lower == 'boolean') { 14066 floating = lower; 14067 lower = undefined; 14068 } 14069 } 14070 if (lower === undefined && upper === undefined) { 14071 lower = 0; 14072 upper = 1; 14073 } 14074 else { 14075 lower = toFinite(lower); 14076 if (upper === undefined) { 14077 upper = lower; 14078 lower = 0; 14079 } else { 14080 upper = toFinite(upper); 14081 } 14082 } 14083 if (lower > upper) { 14084 var temp = lower; 14085 lower = upper; 14086 upper = temp; 14087 } 14088 if (floating || lower % 1 || upper % 1) { 14089 var rand = nativeRandom(); 14090 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 14091 } 14092 return baseRandom(lower, upper); 14093 } 14094 14095 /*------------------------------------------------------------------------*/ 14096 14097 /** 14098 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 14099 * 14100 * @static 14101 * @memberOf _ 14102 * @since 3.0.0 14103 * @category String 14104 * @param {string} [string=''] The string to convert. 14105 * @returns {string} Returns the camel cased string. 14106 * @example 14107 * 14108 * _.camelCase('Foo Bar'); 14109 * // => 'fooBar' 14110 * 14111 * _.camelCase('--foo-bar--'); 14112 * // => 'fooBar' 14113 * 14114 * _.camelCase('__FOO_BAR__'); 14115 * // => 'fooBar' 14116 */ 14117 var camelCase = createCompounder(function(result, word, index) { 14118 word = word.toLowerCase(); 14119 return result + (index ? capitalize(word) : word); 14120 }); 14121 14122 /** 14123 * Converts the first character of `string` to upper case and the remaining 14124 * to lower case. 14125 * 14126 * @static 14127 * @memberOf _ 14128 * @since 3.0.0 14129 * @category String 14130 * @param {string} [string=''] The string to capitalize. 14131 * @returns {string} Returns the capitalized string. 14132 * @example 14133 * 14134 * _.capitalize('FRED'); 14135 * // => 'Fred' 14136 */ 14137 function capitalize(string) { 14138 return upperFirst(toString(string).toLowerCase()); 14139 } 14140 14141 /** 14142 * Deburrs `string` by converting 14143 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 14144 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 14145 * letters to basic Latin letters and removing 14146 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 14147 * 14148 * @static 14149 * @memberOf _ 14150 * @since 3.0.0 14151 * @category String 14152 * @param {string} [string=''] The string to deburr. 14153 * @returns {string} Returns the deburred string. 14154 * @example 14155 * 14156 * _.deburr('déjàvu'); 14157 * // => 'deja vu' 14158 */ 14159 function deburr(string) { 14160 string = toString(string); 14161 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 14162 } 14163 14164 /** 14165 * Checks if `string` ends with the given target string. 14166 * 14167 * @static 14168 * @memberOf _ 14169 * @since 3.0.0 14170 * @category String 14171 * @param {string} [string=''] The string to inspect. 14172 * @param {string} [target] The string to search for. 14173 * @param {number} [position=string.length] The position to search up to. 14174 * @returns {boolean} Returns `true` if `string` ends with `target`, 14175 * else `false`. 14176 * @example 14177 * 14178 * _.endsWith('abc', 'c'); 14179 * // => true 14180 * 14181 * _.endsWith('abc', 'b'); 14182 * // => false 14183 * 14184 * _.endsWith('abc', 'b', 2); 14185 * // => true 14186 */ 14187 function endsWith(string, target, position) { 14188 string = toString(string); 14189 target = baseToString(target); 14190 14191 var length = string.length; 14192 position = position === undefined 14193 ? length 14194 : baseClamp(toInteger(position), 0, length); 14195 14196 var end = position; 14197 position -= target.length; 14198 return position >= 0 && string.slice(position, end) == target; 14199 } 14200 14201 /** 14202 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 14203 * corresponding HTML entities. 14204 * 14205 * **Note:** No other characters are escaped. To escape additional 14206 * characters use a third-party library like [_he_](https://mths.be/he). 14207 * 14208 * Though the ">" character is escaped for symmetry, characters like 14209 * ">" and "/" don't need escaping in HTML and have no special meaning 14210 * unless they're part of a tag or unquoted attribute value. See 14211 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 14212 * (under "semi-related fun fact") for more details. 14213 * 14214 * When working with HTML you should always 14215 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 14216 * XSS vectors. 14217 * 14218 * @static 14219 * @since 0.1.0 14220 * @memberOf _ 14221 * @category String 14222 * @param {string} [string=''] The string to escape. 14223 * @returns {string} Returns the escaped string. 14224 * @example 14225 * 14226 * _.escape('fred, barney, & pebbles'); 14227 * // => 'fred, barney, & pebbles' 14228 */ 14229 function escape(string) { 14230 string = toString(string); 14231 return (string && reHasUnescapedHtml.test(string)) 14232 ? string.replace(reUnescapedHtml, escapeHtmlChar) 14233 : string; 14234 } 14235 14236 /** 14237 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 14238 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 14239 * 14240 * @static 14241 * @memberOf _ 14242 * @since 3.0.0 14243 * @category String 14244 * @param {string} [string=''] The string to escape. 14245 * @returns {string} Returns the escaped string. 14246 * @example 14247 * 14248 * _.escapeRegExp('[lodash](https://lodash.com/)'); 14249 * // => '\[lodash\]\(https://lodash\.com/\)' 14250 */ 14251 function escapeRegExp(string) {
vendor: 4,658 bytes, lines 14252-14421
14252 string = toString(string); 14253 return (string && reHasRegExpChar.test(string)) 14254 ? string.replace(reRegExpChar, '\\$&') 14255 : string; 14256 } 14257 14258 /** 14259 * Converts `string` to 14260 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 14261 * 14262 * @static 14263 * @memberOf _ 14264 * @since 3.0.0 14265 * @category String 14266 * @param {string} [string=''] The string to convert. 14267 * @returns {string} Returns the kebab cased string. 14268 * @example 14269 * 14270 * _.kebabCase('Foo Bar'); 14271 * // => 'foo-bar' 14272 * 14273 * _.kebabCase('fooBar'); 14274 * // => 'foo-bar' 14275 * 14276 * _.kebabCase('__FOO_BAR__'); 14277 * // => 'foo-bar' 14278 */ 14279 var kebabCase = createCompounder(function(result, word, index) { 14280 return result + (index ? '-' : '') + word.toLowerCase(); 14281 }); 14282 14283 /** 14284 * Converts `string`, as space separated words, to lower case. 14285 * 14286 * @static 14287 * @memberOf _ 14288 * @since 4.0.0 14289 * @category String 14290 * @param {string} [string=''] The string to convert. 14291 * @returns {string} Returns the lower cased string. 14292 * @example 14293 * 14294 * _.lowerCase('--Foo-Bar--'); 14295 * // => 'foo bar' 14296 * 14297 * _.lowerCase('fooBar'); 14298 * // => 'foo bar' 14299 * 14300 * _.lowerCase('__FOO_BAR__'); 14301 * // => 'foo bar' 14302 */ 14303 var lowerCase = createCompounder(function(result, word, index) { 14304 return result + (index ? ' ' : '') + word.toLowerCase(); 14305 }); 14306 14307 /** 14308 * Converts the first character of `string` to lower case. 14309 * 14310 * @static 14311 * @memberOf _ 14312 * @since 4.0.0 14313 * @category String 14314 * @param {string} [string=''] The string to convert. 14315 * @returns {string} Returns the converted string. 14316 * @example 14317 * 14318 * _.lowerFirst('Fred'); 14319 * // => 'fred' 14320 * 14321 * _.lowerFirst('FRED'); 14322 * // => 'fRED' 14323 */ 14324 var lowerFirst = createCaseFirst('toLowerCase'); 14325 14326 /** 14327 * Pads `string` on the left and right sides if it's shorter than `length`. 14328 * Padding characters are truncated if they can't be evenly divided by `length`. 14329 * 14330 * @static 14331 * @memberOf _ 14332 * @since 3.0.0 14333 * @category String 14334 * @param {string} [string=''] The string to pad. 14335 * @param {number} [length=0] The padding length. 14336 * @param {string} [chars=' '] The string used as padding. 14337 * @returns {string} Returns the padded string. 14338 * @example 14339 * 14340 * _.pad('abc', 8); 14341 * // => ' abc ' 14342 * 14343 * _.pad('abc', 8, '_-'); 14344 * // => '_-abc_-_' 14345 * 14346 * _.pad('abc', 3); 14347 * // => 'abc' 14348 */ 14349 function pad(string, length, chars) { 14350 string = toString(string); 14351 length = toInteger(length); 14352 14353 var strLength = length ? stringSize(string) : 0; 14354 if (!length || strLength >= length) { 14355 return string; 14356 } 14357 var mid = (length - strLength) / 2; 14358 return ( 14359 createPadding(nativeFloor(mid), chars) + 14360 string + 14361 createPadding(nativeCeil(mid), chars) 14362 ); 14363 } 14364 14365 /** 14366 * Pads `string` on the right side if it's shorter than `length`. Padding 14367 * characters are truncated if they exceed `length`. 14368 * 14369 * @static 14370 * @memberOf _ 14371 * @since 4.0.0 14372 * @category String 14373 * @param {string} [string=''] The string to pad. 14374 * @param {number} [length=0] The padding length. 14375 * @param {string} [chars=' '] The string used as padding. 14376 * @returns {string} Returns the padded string. 14377 * @example 14378 * 14379 * _.padEnd('abc', 6); 14380 * // => 'abc ' 14381 * 14382 * _.padEnd('abc', 6, '_-'); 14383 * // => 'abc_-_' 14384 * 14385 * _.padEnd('abc', 3); 14386 * // => 'abc' 14387 */ 14388 function padEnd(string, length, chars) { 14389 string = toString(string); 14390 length = toInteger(length); 14391 14392 var strLength = length ? stringSize(string) : 0; 14393 return (length && strLength < length) 14394 ? (string + createPadding(length - strLength, chars)) 14395 : string; 14396 } 14397 14398 /** 14399 * Pads `string` on the left side if it's shorter than `length`. Padding 14400 * characters are truncated if they exceed `length`. 14401 * 14402 * @static 14403 * @memberOf _ 14404 * @since 4.0.0 14405 * @category String 14406 * @param {string} [string=''] The string to pad. 14407 * @param {number} [length=0] The padding length. 14408 * @param {string} [chars=' '] The string used as padding. 14409 * @returns {string} Returns the padded string. 14410 * @example 14411 * 14412 * _.padStart('abc', 6); 14413 * // => ' abc' 14414 * 14415 * _.padStart('abc', 6, '_-'); 14416 * // => '_-_abc' 14417 * 14418 * _.padStart('abc', 3); 14419 * // => 'abc' 14420 */ 14421 function padStart(string, length, chars) {
vendor: 12,646 bytes, lines 14422-14779
14422 string = toString(string); 14423 length = toInteger(length); 14424 14425 var strLength = length ? stringSize(string) : 0; 14426 return (length && strLength < length) 14427 ? (createPadding(length - strLength, chars) + string) 14428 : string; 14429 } 14430 14431 /** 14432 * Converts `string` to an integer of the specified radix. If `radix` is 14433 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 14434 * hexadecimal, in which case a `radix` of `16` is used. 14435 * 14436 * **Note:** This method aligns with the 14437 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 14438 * 14439 * @static 14440 * @memberOf _ 14441 * @since 1.1.0 14442 * @category String 14443 * @param {string} string The string to convert. 14444 * @param {number} [radix=10] The radix to interpret `value` by. 14445 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14446 * @returns {number} Returns the converted integer. 14447 * @example 14448 * 14449 * _.parseInt('08'); 14450 * // => 8 14451 * 14452 * _.map(['6', '08', '10'], _.parseInt); 14453 * // => [6, 8, 10] 14454 */ 14455 function parseInt(string, radix, guard) { 14456 if (guard || radix == null) { 14457 radix = 0; 14458 } else if (radix) { 14459 radix = +radix; 14460 } 14461 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 14462 } 14463 14464 /** 14465 * Repeats the given string `n` times. 14466 * 14467 * @static 14468 * @memberOf _ 14469 * @since 3.0.0 14470 * @category String 14471 * @param {string} [string=''] The string to repeat. 14472 * @param {number} [n=1] The number of times to repeat the string. 14473 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14474 * @returns {string} Returns the repeated string. 14475 * @example 14476 * 14477 * _.repeat('*', 3); 14478 * // => '***' 14479 * 14480 * _.repeat('abc', 2); 14481 * // => 'abcabc' 14482 * 14483 * _.repeat('abc', 0); 14484 * // => '' 14485 */ 14486 function repeat(string, n, guard) { 14487 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 14488 n = 1; 14489 } else { 14490 n = toInteger(n); 14491 } 14492 return baseRepeat(toString(string), n); 14493 } 14494 14495 /** 14496 * Replaces matches for `pattern` in `string` with `replacement`. 14497 * 14498 * **Note:** This method is based on 14499 * [`String#replace`](https://mdn.io/String/replace). 14500 * 14501 * @static 14502 * @memberOf _ 14503 * @since 4.0.0 14504 * @category String 14505 * @param {string} [string=''] The string to modify. 14506 * @param {RegExp|string} pattern The pattern to replace. 14507 * @param {Function|string} replacement The match replacement. 14508 * @returns {string} Returns the modified string. 14509 * @example 14510 * 14511 * _.replace('Hi Fred', 'Fred', 'Barney'); 14512 * // => 'Hi Barney' 14513 */ 14514 function replace() { 14515 var args = arguments, 14516 string = toString(args[0]); 14517 14518 return args.length < 3 ? string : string.replace(args[1], args[2]); 14519 } 14520 14521 /** 14522 * Converts `string` to 14523 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 14524 * 14525 * @static 14526 * @memberOf _ 14527 * @since 3.0.0 14528 * @category String 14529 * @param {string} [string=''] The string to convert. 14530 * @returns {string} Returns the snake cased string. 14531 * @example 14532 * 14533 * _.snakeCase('Foo Bar'); 14534 * // => 'foo_bar' 14535 * 14536 * _.snakeCase('fooBar'); 14537 * // => 'foo_bar' 14538 * 14539 * _.snakeCase('--FOO-BAR--'); 14540 * // => 'foo_bar' 14541 */ 14542 var snakeCase = createCompounder(function(result, word, index) { 14543 return result + (index ? '_' : '') + word.toLowerCase(); 14544 }); 14545 14546 /** 14547 * Splits `string` by `separator`. 14548 * 14549 * **Note:** This method is based on 14550 * [`String#split`](https://mdn.io/String/split). 14551 * 14552 * @static 14553 * @memberOf _ 14554 * @since 4.0.0 14555 * @category String 14556 * @param {string} [string=''] The string to split. 14557 * @param {RegExp|string} separator The separator pattern to split by. 14558 * @param {number} [limit] The length to truncate results to. 14559 * @returns {Array} Returns the string segments. 14560 * @example 14561 * 14562 * _.split('a-b-c', '-', 2); 14563 * // => ['a', 'b'] 14564 */ 14565 function split(string, separator, limit) { 14566 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 14567 separator = limit = undefined; 14568 } 14569 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 14570 if (!limit) { 14571 return []; 14572 } 14573 string = toString(string); 14574 if (string && ( 14575 typeof separator == 'string' || 14576 (separator != null && !isRegExp(separator)) 14577 )) { 14578 separator = baseToString(separator); 14579 if (!separator && hasUnicode(string)) { 14580 return castSlice(stringToArray(string), 0, limit); 14581 } 14582 } 14583 return string.split(separator, limit); 14584 } 14585 14586 /** 14587 * Converts `string` to 14588 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 14589 * 14590 * @static 14591 * @memberOf _ 14592 * @since 3.1.0 14593 * @category String 14594 * @param {string} [string=''] The string to convert. 14595 * @returns {string} Returns the start cased string. 14596 * @example 14597 * 14598 * _.startCase('--foo-bar--'); 14599 * // => 'Foo Bar' 14600 * 14601 * _.startCase('fooBar'); 14602 * // => 'Foo Bar' 14603 * 14604 * _.startCase('__FOO_BAR__'); 14605 * // => 'FOO BAR' 14606 */ 14607 var startCase = createCompounder(function(result, word, index) { 14608 return result + (index ? ' ' : '') + upperFirst(word); 14609 }); 14610 14611 /** 14612 * Checks if `string` starts with the given target string. 14613 * 14614 * @static 14615 * @memberOf _ 14616 * @since 3.0.0 14617 * @category String 14618 * @param {string} [string=''] The string to inspect. 14619 * @param {string} [target] The string to search for. 14620 * @param {number} [position=0] The position to search from. 14621 * @returns {boolean} Returns `true` if `string` starts with `target`, 14622 * else `false`. 14623 * @example 14624 * 14625 * _.startsWith('abc', 'a'); 14626 * // => true 14627 * 14628 * _.startsWith('abc', 'b'); 14629 * // => false 14630 * 14631 * _.startsWith('abc', 'b', 1); 14632 * // => true 14633 */ 14634 function startsWith(string, target, position) { 14635 string = toString(string); 14636 position = position == null 14637 ? 0 14638 : baseClamp(toInteger(position), 0, string.length); 14639 14640 target = baseToString(target); 14641 return string.slice(position, position + target.length) == target; 14642 } 14643 14644 /** 14645 * Creates a compiled template function that can interpolate data properties 14646 * in "interpolate" delimiters, HTML-escape interpolated data properties in 14647 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 14648 * properties may be accessed as free variables in the template. If a setting 14649 * object is given, it takes precedence over `_.templateSettings` values. 14650 * 14651 * **Note:** In the development build `_.template` utilizes 14652 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 14653 * for easier debugging. 14654 * 14655 * For more information on precompiling templates see 14656 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 14657 * 14658 * For more information on Chrome extension sandboxes see 14659 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 14660 * 14661 * @static 14662 * @since 0.1.0 14663 * @memberOf _ 14664 * @category String 14665 * @param {string} [string=''] The template string. 14666 * @param {Object} [options={}] The options object. 14667 * @param {RegExp} [options.escape=_.templateSettings.escape] 14668 * The HTML "escape" delimiter. 14669 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 14670 * The "evaluate" delimiter. 14671 * @param {Object} [options.imports=_.templateSettings.imports] 14672 * An object to import into the template as free variables. 14673 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 14674 * The "interpolate" delimiter. 14675 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 14676 * The sourceURL of the compiled template. 14677 * @param {string} [options.variable='obj'] 14678 * The data object variable name. 14679 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14680 * @returns {Function} Returns the compiled template function. 14681 * @example 14682 * 14683 * // Use the "interpolate" delimiter to create a compiled template. 14684 * var compiled = _.template('hello <%= user %>!'); 14685 * compiled({ 'user': 'fred' }); 14686 * // => 'hello fred!' 14687 * 14688 * // Use the HTML "escape" delimiter to escape data property values. 14689 * var compiled = _.template('<b><%- value %></b>'); 14690 * compiled({ 'value': '<script>' }); 14691 * // => '<b><script></b>' 14692 * 14693 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 14694 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 14695 * compiled({ 'users': ['fred', 'barney'] }); 14696 * // => '<li>fred</li><li>barney</li>' 14697 * 14698 * // Use the internal `print` function in "evaluate" delimiters. 14699 * var compiled = _.template('<% print("hello " + user); %>!'); 14700 * compiled({ 'user': 'barney' }); 14701 * // => 'hello barney!' 14702 * 14703 * // Use the ES template literal delimiter as an "interpolate" delimiter. 14704 * // Disable support by replacing the "interpolate" delimiter. 14705 * var compiled = _.template('hello ${ user }!'); 14706 * compiled({ 'user': 'pebbles' }); 14707 * // => 'hello pebbles!' 14708 * 14709 * // Use backslashes to treat delimiters as plain text. 14710 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 14711 * compiled({ 'value': 'ignored' }); 14712 * // => '<%- value %>' 14713 * 14714 * // Use the `imports` option to import `jQuery` as `jq`. 14715 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 14716 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 14717 * compiled({ 'users': ['fred', 'barney'] }); 14718 * // => '<li>fred</li><li>barney</li>' 14719 * 14720 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 14721 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 14722 * compiled(data); 14723 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 14724 * 14725 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 14726 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 14727 * compiled.source; 14728 * // => function(data) { 14729 * // var __t, __p = ''; 14730 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 14731 * // return __p; 14732 * // } 14733 * 14734 * // Use custom template delimiters. 14735 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 14736 * var compiled = _.template('hello {{ user }}!'); 14737 * compiled({ 'user': 'mustache' }); 14738 * // => 'hello mustache!' 14739 * 14740 * // Use the `source` property to inline compiled templates for meaningful 14741 * // line numbers in error messages and stack traces. 14742 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 14743 * var JST = {\ 14744 * "main": ' + _.template(mainText).source + '\ 14745 * };\ 14746 * '); 14747 */ 14748 function template(string, options, guard) { 14749 // Based on John Resig's `tmpl` implementation 14750 // (http://ejohn.org/blog/javascript-micro-templating/) 14751 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 14752 var settings = lodash.templateSettings; 14753 14754 if (guard && isIterateeCall(string, options, guard)) { 14755 options = undefined; 14756 } 14757 string = toString(string); 14758 options = assignInWith({}, options, settings, customDefaultsAssignIn); 14759 14760 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 14761 importsKeys = keys(imports), 14762 importsValues = baseValues(imports, importsKeys); 14763 14764 var isEscaping, 14765 isEvaluating, 14766 index = 0, 14767 interpolate = options.interpolate || reNoMatch, 14768 source = "__p += '"; 14769 14770 // Compile the regexp to match each delimiter. 14771 var reDelimiters = RegExp( 14772 (options.escape || reNoMatch).source + '|' + 14773 interpolate.source + '|' + 14774 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 14775 (options.evaluate || reNoMatch).source + '|$' 14776 , 'g'); 14777 14778 // Use a sourceURL for easier debugging. 14779
vendor: 1,744 bytes, lines 14779-14823
14779var sourceURL = '//# sourceURL=' + 14780 ('sourceURL' in options 14781 ? options.sourceURL 14782 : ('lodash.templateSources[' + (++templateCounter) + ']') 14783 ) + '\n'; 14784 14785 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 14786 interpolateValue || (interpolateValue = esTemplateValue); 14787 14788 // Escape characters that can't be included in string literals. 14789 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 14790 14791 // Replace delimiters with snippets. 14792 if (escapeValue) { 14793 isEscaping = true; 14794 source += "' +\n__e(" + escapeValue + ") +\n'"; 14795 } 14796 if (evaluateValue) { 14797 isEvaluating = true; 14798 source += "';\n" + evaluateValue + ";\n__p += '"; 14799 } 14800 if (interpolateValue) { 14801 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 14802 } 14803 index = offset + match.length; 14804 14805 // The JS engine embedded in Adobe products needs `match` returned in 14806 // order to produce the correct `offset` value. 14807 return match; 14808 }); 14809 14810 source += "';\n"; 14811 14812 // If `variable` is not specified wrap a with-statement around the generated 14813 // code to add the data object to the top of the scope chain. 14814 var variable = options.variable; 14815 if (!variable) { 14816 source = 'with (obj) {\n' + source + '\n}\n'; 14817 } 14818 // Cleanup code by stripping empty strings. 14819 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 14820 .replace(reEmptyStringMiddle, '$1') 14821 .replace(reEmptyStringTrailing, '$1;'); 14822 14823 // Frame code as the function body.
vendor: 4,089 bytes, lines 14824-14966
14824 source = 'function(' + (variable || 'obj') + ') {\n' + 14825 (variable 14826 ? '' 14827 : 'obj || (obj = {});\n' 14828 ) + 14829 "var __t, __p = ''" + 14830 (isEscaping 14831 ? ', __e = _.escape' 14832 : '' 14833 ) + 14834 (isEvaluating 14835 ? ', __j = Array.prototype.join;\n' + 14836 "function print() { __p += __j.call(arguments, '') }\n" 14837 : ';\n' 14838 ) + 14839 source + 14840 'return __p\n}'; 14841 14842 var result = attempt(function() { 14843 return Function(importsKeys, sourceURL + 'return ' + source) 14844 .apply(undefined, importsValues); 14845 }); 14846 14847 // Provide the compiled function's source by its `toString` method or 14848 // the `source` property as a convenience for inlining compiled templates. 14849 result.source = source; 14850 if (isError(result)) { 14851 throw result; 14852 } 14853 return result; 14854 } 14855 14856 /** 14857 * Converts `string`, as a whole, to lower case just like 14858 * [String#toLowerCase](https://mdn.io/toLowerCase). 14859 * 14860 * @static 14861 * @memberOf _ 14862 * @since 4.0.0 14863 * @category String 14864 * @param {string} [string=''] The string to convert. 14865 * @returns {string} Returns the lower cased string. 14866 * @example 14867 * 14868 * _.toLower('--Foo-Bar--'); 14869 * // => '--foo-bar--' 14870 * 14871 * _.toLower('fooBar'); 14872 * // => 'foobar' 14873 * 14874 * _.toLower('__FOO_BAR__'); 14875 * // => '__foo_bar__' 14876 */ 14877 function toLower(value) { 14878 return toString(value).toLowerCase(); 14879 } 14880 14881 /** 14882 * Converts `string`, as a whole, to upper case just like 14883 * [String#toUpperCase](https://mdn.io/toUpperCase). 14884 * 14885 * @static 14886 * @memberOf _ 14887 * @since 4.0.0 14888 * @category String 14889 * @param {string} [string=''] The string to convert. 14890 * @returns {string} Returns the upper cased string. 14891 * @example 14892 * 14893 * _.toUpper('--foo-bar--'); 14894 * // => '--FOO-BAR--' 14895 * 14896 * _.toUpper('fooBar'); 14897 * // => 'FOOBAR' 14898 * 14899 * _.toUpper('__foo_bar__'); 14900 * // => '__FOO_BAR__' 14901 */ 14902 function toUpper(value) { 14903 return toString(value).toUpperCase(); 14904 } 14905 14906 /** 14907 * Removes leading and trailing whitespace or specified characters from `string`. 14908 * 14909 * @static 14910 * @memberOf _ 14911 * @since 3.0.0 14912 * @category String 14913 * @param {string} [string=''] The string to trim. 14914 * @param {string} [chars=whitespace] The characters to trim. 14915 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14916 * @returns {string} Returns the trimmed string. 14917 * @example 14918 * 14919 * _.trim(' abc '); 14920 * // => 'abc' 14921 * 14922 * _.trim('-_-abc-_-', '_-'); 14923 * // => 'abc' 14924 * 14925 * _.map([' foo ', ' bar '], _.trim); 14926 * // => ['foo', 'bar'] 14927 */ 14928 function trim(string, chars, guard) { 14929 string = toString(string); 14930 if (string && (guard || chars === undefined)) { 14931 return string.replace(reTrim, ''); 14932 } 14933 if (!string || !(chars = baseToString(chars))) { 14934 return string; 14935 } 14936 var strSymbols = stringToArray(string), 14937 chrSymbols = stringToArray(chars), 14938 start = charsStartIndex(strSymbols, chrSymbols), 14939 end = charsEndIndex(strSymbols, chrSymbols) + 1; 14940 14941 return castSlice(strSymbols, start, end).join(''); 14942 } 14943 14944 /** 14945 * Removes trailing whitespace or specified characters from `string`. 14946 * 14947 * @static 14948 * @memberOf _ 14949 * @since 4.0.0 14950 * @category String 14951 * @param {string} [string=''] The string to trim. 14952 * @param {string} [chars=whitespace] The characters to trim. 14953 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14954 * @returns {string} Returns the trimmed string. 14955 * @example 14956 * 14957 * _.trimEnd(' abc '); 14958 * // => ' abc' 14959 * 14960 * _.trimEnd('-_-abc-_-', '_-'); 14961 * // => '-_-abc' 14962 */ 14963 function trimEnd(string, chars, guard) { 14964 string = toString(string); 14965 if (string && (guard || chars === undefined)) { 14966 return string.replace(reTrimEnd, ''
vendor: 10,736 bytes, lines 14966-15310
14966); 14967 } 14968 if (!string || !(chars = baseToString(chars))) { 14969 return string; 14970 } 14971 var strSymbols = stringToArray(string), 14972 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 14973 14974 return castSlice(strSymbols, 0, end).join(''); 14975 } 14976 14977 /** 14978 * Removes leading whitespace or specified characters from `string`. 14979 * 14980 * @static 14981 * @memberOf _ 14982 * @since 4.0.0 14983 * @category String 14984 * @param {string} [string=''] The string to trim. 14985 * @param {string} [chars=whitespace] The characters to trim. 14986 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14987 * @returns {string} Returns the trimmed string. 14988 * @example 14989 * 14990 * _.trimStart(' abc '); 14991 * // => 'abc ' 14992 * 14993 * _.trimStart('-_-abc-_-', '_-'); 14994 * // => 'abc-_-' 14995 */ 14996 function trimStart(string, chars, guard) { 14997 string = toString(string); 14998 if (string && (guard || chars === undefined)) { 14999 return string.replace(reTrimStart, ''); 15000 } 15001 if (!string || !(chars = baseToString(chars))) { 15002 return string; 15003 } 15004 var strSymbols = stringToArray(string), 15005 start = charsStartIndex(strSymbols, stringToArray(chars)); 15006 15007 return castSlice(strSymbols, start).join(''); 15008 } 15009 15010 /** 15011 * Truncates `string` if it's longer than the given maximum string length. 15012 * The last characters of the truncated string are replaced with the omission 15013 * string which defaults to "...". 15014 * 15015 * @static 15016 * @memberOf _ 15017 * @since 4.0.0 15018 * @category String 15019 * @param {string} [string=''] The string to truncate. 15020 * @param {Object} [options={}] The options object. 15021 * @param {number} [options.length=30] The maximum string length. 15022 * @param {string} [options.omission='...'] The string to indicate text is omitted. 15023 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 15024 * @returns {string} Returns the truncated string. 15025 * @example 15026 * 15027 * _.truncate('hi-diddly-ho there, neighborino'); 15028 * // => 'hi-diddly-ho there, neighbo...' 15029 * 15030 * _.truncate('hi-diddly-ho there, neighborino', { 15031 * 'length': 24, 15032 * 'separator': ' ' 15033 * }); 15034 * // => 'hi-diddly-ho there,...' 15035 * 15036 * _.truncate('hi-diddly-ho there, neighborino', { 15037 * 'length': 24, 15038 * 'separator': /,? +/ 15039 * }); 15040 * // => 'hi-diddly-ho there...' 15041 * 15042 * _.truncate('hi-diddly-ho there, neighborino', { 15043 * 'omission': ' [...]' 15044 * }); 15045 * // => 'hi-diddly-ho there, neig [...]' 15046 */ 15047 function truncate(string, options) { 15048 var length = DEFAULT_TRUNC_LENGTH, 15049 omission = DEFAULT_TRUNC_OMISSION; 15050 15051 if (isObject(options)) { 15052 var separator = 'separator' in options ? options.separator : separator; 15053 length = 'length' in options ? toInteger(options.length) : length; 15054 omission = 'omission' in options ? baseToString(options.omission) : omission; 15055 } 15056 string = toString(string); 15057 15058 var strLength = string.length; 15059 if (hasUnicode(string)) { 15060 var strSymbols = stringToArray(string); 15061 strLength = strSymbols.length; 15062 } 15063 if (length >= strLength) { 15064 return string; 15065 } 15066 var end = length - stringSize(omission); 15067 if (end < 1) { 15068 return omission; 15069 } 15070 var result = strSymbols 15071 ? castSlice(strSymbols, 0, end).join('') 15072 : string.slice(0, end); 15073 15074 if (separator === undefined) { 15075 return result + omission; 15076 } 15077 if (strSymbols) { 15078 end += (result.length - end); 15079 } 15080 if (isRegExp(separator)) { 15081 if (string.slice(end).search(separator)) { 15082 var match, 15083 substring = result; 15084 15085 if (!separator.global) { 15086 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 15087 } 15088 separator.lastIndex = 0; 15089 while ((match = separator.exec(substring))) { 15090 var newEnd = match.index; 15091 } 15092 result = result.slice(0, newEnd === undefined ? end : newEnd); 15093 } 15094 } else if (string.indexOf(baseToString(separator), end) != end) { 15095 var index = result.lastIndexOf(separator); 15096 if (index > -1) { 15097 result = result.slice(0, index); 15098 } 15099 } 15100 return result + omission; 15101 } 15102 15103 /** 15104 * The inverse of `_.escape`; this method converts the HTML entities 15105 * `&`, `<`, `>`, `"`, and `'` in `string` to 15106 * their corresponding characters. 15107 * 15108 * **Note:** No other HTML entities are unescaped. To unescape additional 15109 * HTML entities use a third-party library like [_he_](https://mths.be/he). 15110 * 15111 * @static 15112 * @memberOf _ 15113 * @since 0.6.0 15114 * @category String 15115 * @param {string} [string=''] The string to unescape. 15116 * @returns {string} Returns the unescaped string. 15117 * @example 15118 * 15119 * _.unescape('fred, barney, & pebbles'); 15120 * // => 'fred, barney, & pebbles' 15121 */ 15122 function unescape(string) { 15123 string = toString(string); 15124 return (string && reHasEscapedHtml.test(string)) 15125 ? string.replace(reEscapedHtml, unescapeHtmlChar) 15126 : string; 15127 } 15128 15129 /** 15130 * Converts `string`, as space separated words, to upper case. 15131 * 15132 * @static 15133 * @memberOf _ 15134 * @since 4.0.0 15135 * @category String 15136 * @param {string} [string=''] The string to convert. 15137 * @returns {string} Returns the upper cased string. 15138 * @example 15139 * 15140 * _.upperCase('--foo-bar'); 15141 * // => 'FOO BAR' 15142 * 15143 * _.upperCase('fooBar'); 15144 * // => 'FOO BAR' 15145 * 15146 * _.upperCase('__foo_bar__'); 15147 * // => 'FOO BAR' 15148 */ 15149 var upperCase = createCompounder(function(result, word, index) { 15150 return result + (index ? ' ' : '') + word.toUpperCase(); 15151 }); 15152 15153 /** 15154 * Converts the first character of `string` to upper case. 15155 * 15156 * @static 15157 * @memberOf _ 15158 * @since 4.0.0 15159 * @category String 15160 * @param {string} [string=''] The string to convert. 15161 * @returns {string} Returns the converted string. 15162 * @example 15163 * 15164 * _.upperFirst('fred'); 15165 * // => 'Fred' 15166 * 15167 * _.upperFirst('FRED'); 15168 * // => 'FRED' 15169 */ 15170 var upperFirst = createCaseFirst('toUpperCase'); 15171 15172 /** 15173 * Splits `string` into an array of its words. 15174 * 15175 * @static 15176 * @memberOf _ 15177 * @since 3.0.0 15178 * @category String 15179 * @param {string} [string=''] The string to inspect. 15180 * @param {RegExp|string} [pattern] The pattern to match words. 15181 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15182 * @returns {Array} Returns the words of `string`. 15183 * @example 15184 * 15185 * _.words('fred, barney, & pebbles'); 15186 * // => ['fred', 'barney', 'pebbles'] 15187 * 15188 * _.words('fred, barney, & pebbles', /[^, ]+/g); 15189 * // => ['fred', 'barney', '&', 'pebbles'] 15190 */ 15191 function words(string, pattern, guard) { 15192 string = toString(string); 15193 pattern = guard ? undefined : pattern; 15194 15195 if (pattern === undefined) { 15196 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 15197 } 15198 return string.match(pattern) || []; 15199 } 15200 15201 /*------------------------------------------------------------------------*/ 15202 15203 /** 15204 * Attempts to invoke `func`, returning either the result or the caught error 15205 * object. Any additional arguments are provided to `func` when it's invoked. 15206 * 15207 * @static 15208 * @memberOf _ 15209 * @since 3.0.0 15210 * @category Util 15211 * @param {Function} func The function to attempt. 15212 * @param {...*} [args] The arguments to invoke `func` with. 15213 * @returns {*} Returns the `func` result or error object. 15214 * @example 15215 * 15216 * // Avoid throwing errors for invalid selectors. 15217 * var elements = _.attempt(function(selector) { 15218 * return document.querySelectorAll(selector); 15219 * }, '>_>'); 15220 * 15221 * if (_.isError(elements)) { 15222 * elements = []; 15223 * } 15224 */ 15225 var attempt = baseRest(function(func, args) { 15226 try { 15227 return apply(func, undefined, args); 15228 } catch (e) { 15229 return isError(e) ? e : new Error(e); 15230 } 15231 }); 15232 15233 /** 15234 * Binds methods of an object to the object itself, overwriting the existing 15235 * method. 15236 * 15237 * **Note:** This method doesn't set the "length" property of bound functions. 15238 * 15239 * @static 15240 * @since 0.1.0 15241 * @memberOf _ 15242 * @category Util 15243 * @param {Object} object The object to bind and assign the bound methods to. 15244 * @param {...(string|string[])} methodNames The object method names to bind. 15245 * @returns {Object} Returns `object`. 15246 * @example 15247 * 15248 * var view = { 15249 * 'label': 'docs', 15250 * 'click': function() { 15251 * console.log('clicked ' + this.label); 15252 * } 15253 * }; 15254 * 15255 * _.bindAll(view, ['click']); 15256 * jQuery(element).on('click', view.click); 15257 * // => Logs 'clicked docs' when clicked. 15258 */ 15259 var bindAll = flatRest(function(object, methodNames) { 15260 arrayEach(methodNames, function(key) { 15261 key = toKey(key); 15262 baseAssignValue(object, key, bind(object[key], object)); 15263 }); 15264 return object; 15265 }); 15266 15267 /** 15268 * Creates a function that iterates over `pairs` and invokes the corresponding 15269 * function of the first predicate to return truthy. The predicate-function 15270 * pairs are invoked with the `this` binding and arguments of the created 15271 * function. 15272 * 15273 * @static 15274 * @memberOf _ 15275 * @since 4.0.0 15276 * @category Util 15277 * @param {Array} pairs The predicate-function pairs. 15278 * @returns {Function} Returns the new composite function. 15279 * @example 15280 * 15281 * var func = _.cond([ 15282 * [_.matches({ 'a': 1 }), _.constant('matches A')], 15283 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 15284 * [_.stubTrue, _.constant('no match')] 15285 * ]); 15286 * 15287 * func({ 'a': 1, 'b': 2 }); 15288 * // => 'matches A' 15289 * 15290 * func({ 'a': 0, 'b': 1 }); 15291 * // => 'matches B' 15292 * 15293 * func({ 'a': '1', 'b': '2' }); 15294 * // => 'no match' 15295 */ 15296 function cond(pairs) { 15297 var length = pairs == null ? 0 : pairs.length, 15298 toIteratee = getIteratee(); 15299 15300 pairs = !length ? [] : arrayMap(pairs, function(pair) { 15301 if (typeof pair[1] != 'function') { 15302 throw new TypeError(FUNC_ERROR_TEXT); 15303 } 15304 return [toIteratee(pair[0]), pair[1]]; 15305 }); 15306 15307 return baseRest(function(args) { 15308 var index = -1; 15309 while (++index < length) { 15310 var pair = pairs[index];
vendor: 19,681 bytes, lines 15311-16006
15311 if (apply(pair[0], this, args)) { 15312 return apply(pair[1], this, args); 15313 } 15314 } 15315 }); 15316 } 15317 15318 /** 15319 * Creates a function that invokes the predicate properties of `source` with 15320 * the corresponding property values of a given object, returning `true` if 15321 * all predicates return truthy, else `false`. 15322 * 15323 * **Note:** The created function is equivalent to `_.conformsTo` with 15324 * `source` partially applied. 15325 * 15326 * @static 15327 * @memberOf _ 15328 * @since 4.0.0 15329 * @category Util 15330 * @param {Object} source The object of property predicates to conform to. 15331 * @returns {Function} Returns the new spec function. 15332 * @example 15333 * 15334 * var objects = [ 15335 * { 'a': 2, 'b': 1 }, 15336 * { 'a': 1, 'b': 2 } 15337 * ]; 15338 * 15339 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 15340 * // => [{ 'a': 1, 'b': 2 }] 15341 */ 15342 function conforms(source) { 15343 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 15344 } 15345 15346 /** 15347 * Creates a function that returns `value`. 15348 * 15349 * @static 15350 * @memberOf _ 15351 * @since 2.4.0 15352 * @category Util 15353 * @param {*} value The value to return from the new function. 15354 * @returns {Function} Returns the new constant function. 15355 * @example 15356 * 15357 * var objects = _.times(2, _.constant({ 'a': 1 })); 15358 * 15359 * console.log(objects); 15360 * // => [{ 'a': 1 }, { 'a': 1 }] 15361 * 15362 * console.log(objects[0] === objects[1]); 15363 * // => true 15364 */ 15365 function constant(value) { 15366 return function() { 15367 return value; 15368 }; 15369 } 15370 15371 /** 15372 * Checks `value` to determine whether a default value should be returned in 15373 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 15374 * or `undefined`. 15375 * 15376 * @static 15377 * @memberOf _ 15378 * @since 4.14.0 15379 * @category Util 15380 * @param {*} value The value to check. 15381 * @param {*} defaultValue The default value. 15382 * @returns {*} Returns the resolved value. 15383 * @example 15384 * 15385 * _.defaultTo(1, 10); 15386 * // => 1 15387 * 15388 * _.defaultTo(undefined, 10); 15389 * // => 10 15390 */ 15391 function defaultTo(value, defaultValue) { 15392 return (value == null || value !== value) ? defaultValue : value; 15393 } 15394 15395 /** 15396 * Creates a function that returns the result of invoking the given functions 15397 * with the `this` binding of the created function, where each successive 15398 * invocation is supplied the return value of the previous. 15399 * 15400 * @static 15401 * @memberOf _ 15402 * @since 3.0.0 15403 * @category Util 15404 * @param {...(Function|Function[])} [funcs] The functions to invoke. 15405 * @returns {Function} Returns the new composite function. 15406 * @see _.flowRight 15407 * @example 15408 * 15409 * function square(n) { 15410 * return n * n; 15411 * } 15412 * 15413 * var addSquare = _.flow([_.add, square]); 15414 * addSquare(1, 2); 15415 * // => 9 15416 */ 15417 var flow = createFlow(); 15418 15419 /** 15420 * This method is like `_.flow` except that it creates a function that 15421 * invokes the given functions from right to left. 15422 * 15423 * @static 15424 * @since 3.0.0 15425 * @memberOf _ 15426 * @category Util 15427 * @param {...(Function|Function[])} [funcs] The functions to invoke. 15428 * @returns {Function} Returns the new composite function. 15429 * @see _.flow 15430 * @example 15431 * 15432 * function square(n) { 15433 * return n * n; 15434 * } 15435 * 15436 * var addSquare = _.flowRight([square, _.add]); 15437 * addSquare(1, 2); 15438 * // => 9 15439 */ 15440 var flowRight = createFlow(true); 15441 15442 /** 15443 * This method returns the first argument it receives. 15444 * 15445 * @static 15446 * @since 0.1.0 15447 * @memberOf _ 15448 * @category Util 15449 * @param {*} value Any value. 15450 * @returns {*} Returns `value`. 15451 * @example 15452 * 15453 * var object = { 'a': 1 }; 15454 * 15455 * console.log(_.identity(object) === object); 15456 * // => true 15457 */ 15458 function identity(value) { 15459 return value; 15460 } 15461 15462 /** 15463 * Creates a function that invokes `func` with the arguments of the created 15464 * function. If `func` is a property name, the created function returns the 15465 * property value for a given element. If `func` is an array or object, the 15466 * created function returns `true` for elements that contain the equivalent 15467 * source properties, otherwise it returns `false`. 15468 * 15469 * @static 15470 * @since 4.0.0 15471 * @memberOf _ 15472 * @category Util 15473 * @param {*} [func=_.identity] The value to convert to a callback. 15474 * @returns {Function} Returns the callback. 15475 * @example 15476 * 15477 * var users = [ 15478 * { 'user': 'barney', 'age': 36, 'active': true }, 15479 * { 'user': 'fred', 'age': 40, 'active': false } 15480 * ]; 15481 * 15482 * // The `_.matches` iteratee shorthand. 15483 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 15484 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 15485 * 15486 * // The `_.matchesProperty` iteratee shorthand. 15487 * _.filter(users, _.iteratee(['user', 'fred'])); 15488 * // => [{ 'user': 'fred', 'age': 40 }] 15489 * 15490 * // The `_.property` iteratee shorthand. 15491 * _.map(users, _.iteratee('user')); 15492 * // => ['barney', 'fred'] 15493 * 15494 * // Create custom iteratee shorthands. 15495 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 15496 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 15497 * return func.test(string); 15498 * }; 15499 * }); 15500 * 15501 * _.filter(['abc', 'def'], /ef/); 15502 * // => ['def'] 15503 */ 15504 function iteratee(func) { 15505 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 15506 } 15507 15508 /** 15509 * Creates a function that performs a partial deep comparison between a given 15510 * object and `source`, returning `true` if the given object has equivalent 15511 * property values, else `false`. 15512 * 15513 * **Note:** The created function is equivalent to `_.isMatch` with `source` 15514 * partially applied. 15515 * 15516 * Partial comparisons will match empty array and empty object `source` 15517 * values against any array or object value, respectively. See `_.isEqual` 15518 * for a list of supported value comparisons. 15519 * 15520 * @static 15521 * @memberOf _ 15522 * @since 3.0.0 15523 * @category Util 15524 * @param {Object} source The object of property values to match. 15525 * @returns {Function} Returns the new spec function. 15526 * @example 15527 * 15528 * var objects = [ 15529 * { 'a': 1, 'b': 2, 'c': 3 }, 15530 * { 'a': 4, 'b': 5, 'c': 6 } 15531 * ]; 15532 * 15533 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 15534 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 15535 */ 15536 function matches(source) { 15537 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 15538 } 15539 15540 /** 15541 * Creates a function that performs a partial deep comparison between the 15542 * value at `path` of a given object to `srcValue`, returning `true` if the 15543 * object value is equivalent, else `false`. 15544 * 15545 * **Note:** Partial comparisons will match empty array and empty object 15546 * `srcValue` values against any array or object value, respectively. See 15547 * `_.isEqual` for a list of supported value comparisons. 15548 * 15549 * @static 15550 * @memberOf _ 15551 * @since 3.2.0 15552 * @category Util 15553 * @param {Array|string} path The path of the property to get. 15554 * @param {*} srcValue The value to match. 15555 * @returns {Function} Returns the new spec function. 15556 * @example 15557 * 15558 * var objects = [ 15559 * { 'a': 1, 'b': 2, 'c': 3 }, 15560 * { 'a': 4, 'b': 5, 'c': 6 } 15561 * ]; 15562 * 15563 * _.find(objects, _.matchesProperty('a', 4)); 15564 * // => { 'a': 4, 'b': 5, 'c': 6 } 15565 */ 15566 function matchesProperty(path, srcValue) { 15567 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 15568 } 15569 15570 /** 15571 * Creates a function that invokes the method at `path` of a given object. 15572 * Any additional arguments are provided to the invoked method. 15573 * 15574 * @static 15575 * @memberOf _ 15576 * @since 3.7.0 15577 * @category Util 15578 * @param {Array|string} path The path of the method to invoke. 15579 * @param {...*} [args] The arguments to invoke the method with. 15580 * @returns {Function} Returns the new invoker function. 15581 * @example 15582 * 15583 * var objects = [ 15584 * { 'a': { 'b': _.constant(2) } }, 15585 * { 'a': { 'b': _.constant(1) } } 15586 * ]; 15587 * 15588 * _.map(objects, _.method('a.b')); 15589 * // => [2, 1] 15590 * 15591 * _.map(objects, _.method(['a', 'b'])); 15592 * // => [2, 1] 15593 */ 15594 var method = baseRest(function(path, args) { 15595 return function(object) { 15596 return baseInvoke(object, path, args); 15597 }; 15598 }); 15599 15600 /** 15601 * The opposite of `_.method`; this method creates a function that invokes 15602 * the method at a given path of `object`. Any additional arguments are 15603 * provided to the invoked method. 15604 * 15605 * @static 15606 * @memberOf _ 15607 * @since 3.7.0 15608 * @category Util 15609 * @param {Object} object The object to query. 15610 * @param {...*} [args] The arguments to invoke the method with. 15611 * @returns {Function} Returns the new invoker function. 15612 * @example 15613 * 15614 * var array = _.times(3, _.constant), 15615 * object = { 'a': array, 'b': array, 'c': array }; 15616 * 15617 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 15618 * // => [2, 0] 15619 * 15620 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 15621 * // => [2, 0] 15622 */ 15623 var methodOf = baseRest(function(object, args) { 15624 return function(path) { 15625 return baseInvoke(object, path, args); 15626 }; 15627 }); 15628 15629 /** 15630 * Adds all own enumerable string keyed function properties of a source 15631 * object to the destination object. If `object` is a function, then methods 15632 * are added to its prototype as well. 15633 * 15634 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 15635 * avoid conflicts caused by modifying the original. 15636 * 15637 * @static 15638 * @since 0.1.0 15639 * @memberOf _ 15640 * @category Util 15641 * @param {Function|Object} [object=lodash] The destination object. 15642 * @param {Object} source The object of functions to add. 15643 * @param {Object} [options={}] The options object. 15644 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 15645 * @returns {Function|Object} Returns `object`. 15646 * @example 15647 * 15648 * function vowels(string) { 15649 * return _.filter(string, function(v) { 15650 * return /[aeiou]/i.test(v); 15651 * }); 15652 * } 15653 * 15654 * _.mixin({ 'vowels': vowels }); 15655 * _.vowels('fred'); 15656 * // => ['e'] 15657 * 15658 * _('fred').vowels().value(); 15659 * // => ['e'] 15660 * 15661 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 15662 * _('fred').vowels(); 15663 * // => ['e'] 15664 */ 15665 function mixin(object, source, options) { 15666 var props = keys(source), 15667 methodNames = baseFunctions(source, props); 15668 15669 if (options == null && 15670 !(isObject(source) && (methodNames.length || !props.length))) { 15671 options = source; 15672 source = object; 15673 object = this; 15674 methodNames = baseFunctions(source, keys(source)); 15675 } 15676 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 15677 isFunc = isFunction(object); 15678 15679 arrayEach(methodNames, function(methodName) { 15680 var func = source[methodName]; 15681 object[methodName] = func; 15682 if (isFunc) { 15683 object.prototype[methodName] = function() { 15684 var chainAll = this.__chain__; 15685 if (chain || chainAll) { 15686 var result = object(this.__wrapped__), 15687 actions = result.__actions__ = copyArray(this.__actions__); 15688 15689 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 15690 result.__chain__ = chainAll; 15691 return result; 15692 } 15693 return func.apply(object, arrayPush([this.value()], arguments)); 15694 }; 15695 } 15696 }); 15697 15698 return object; 15699 } 15700 15701 /** 15702 * Reverts the `_` variable to its previous value and returns a reference to 15703 * the `lodash` function. 15704 * 15705 * @static 15706 * @since 0.1.0 15707 * @memberOf _ 15708 * @category Util 15709 * @returns {Function} Returns the `lodash` function. 15710 * @example 15711 * 15712 * var lodash = _.noConflict(); 15713 */ 15714 function noConflict() { 15715 if (root._ === this) { 15716 root._ = oldDash; 15717 } 15718 return this; 15719 } 15720 15721 /** 15722 * This method returns `undefined`. 15723 * 15724 * @static 15725 * @memberOf _ 15726 * @since 2.3.0 15727 * @category Util 15728 * @example 15729 * 15730 * _.times(2, _.noop); 15731 * // => [undefined, undefined] 15732 */ 15733 function noop() { 15734 // No operation performed. 15735 } 15736 15737 /** 15738 * Creates a function that gets the argument at index `n`. If `n` is negative, 15739 * the nth argument from the end is returned. 15740 * 15741 * @static 15742 * @memberOf _ 15743 * @since 4.0.0 15744 * @category Util 15745 * @param {number} [n=0] The index of the argument to return. 15746 * @returns {Function} Returns the new pass-thru function. 15747 * @example 15748 * 15749 * var func = _.nthArg(1); 15750 * func('a', 'b', 'c', 'd'); 15751 * // => 'b' 15752 * 15753 * var func = _.nthArg(-2); 15754 * func('a', 'b', 'c', 'd'); 15755 * // => 'c' 15756 */ 15757 function nthArg(n) { 15758 n = toInteger(n); 15759 return baseRest(function(args) { 15760 return baseNth(args, n); 15761 }); 15762 } 15763 15764 /** 15765 * Creates a function that invokes `iteratees` with the arguments it receives 15766 * and returns their results. 15767 * 15768 * @static 15769 * @memberOf _ 15770 * @since 4.0.0 15771 * @category Util 15772 * @param {...(Function|Function[])} [iteratees=[_.identity]] 15773 * The iteratees to invoke. 15774 * @returns {Function} Returns the new function. 15775 * @example 15776 * 15777 * var func = _.over([Math.max, Math.min]); 15778 * 15779 * func(1, 2, 3, 4); 15780 * // => [4, 1] 15781 */ 15782 var over = createOver(arrayMap); 15783 15784 /** 15785 * Creates a function that checks if **all** of the `predicates` return 15786 * truthy when invoked with the arguments it receives. 15787 * 15788 * @static 15789 * @memberOf _ 15790 * @since 4.0.0 15791 * @category Util 15792 * @param {...(Function|Function[])} [predicates=[_.identity]] 15793 * The predicates to check. 15794 * @returns {Function} Returns the new function. 15795 * @example 15796 * 15797 * var func = _.overEvery([Boolean, isFinite]); 15798 * 15799 * func('1'); 15800 * // => true 15801 * 15802 * func(null); 15803 * // => false 15804 * 15805 * func(NaN); 15806 * // => false 15807 */ 15808 var overEvery = createOver(arrayEvery); 15809 15810 /** 15811 * Creates a function that checks if **any** of the `predicates` return 15812 * truthy when invoked with the arguments it receives. 15813 * 15814 * @static 15815 * @memberOf _ 15816 * @since 4.0.0 15817 * @category Util 15818 * @param {...(Function|Function[])} [predicates=[_.identity]] 15819 * The predicates to check. 15820 * @returns {Function} Returns the new function. 15821 * @example 15822 * 15823 * var func = _.overSome([Boolean, isFinite]); 15824 * 15825 * func('1'); 15826 * // => true 15827 * 15828 * func(null); 15829 * // => true 15830 * 15831 * func(NaN); 15832 * // => false 15833 */ 15834 var overSome = createOver(arraySome); 15835 15836 /** 15837 * Creates a function that returns the value at `path` of a given object. 15838 * 15839 * @static 15840 * @memberOf _ 15841 * @since 2.4.0 15842 * @category Util 15843 * @param {Array|string} path The path of the property to get. 15844 * @returns {Function} Returns the new accessor function. 15845 * @example 15846 * 15847 * var objects = [ 15848 * { 'a': { 'b': 2 } }, 15849 * { 'a': { 'b': 1 } } 15850 * ]; 15851 * 15852 * _.map(objects, _.property('a.b')); 15853 * // => [2, 1] 15854 * 15855 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 15856 * // => [1, 2] 15857 */ 15858 function property(path) { 15859 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 15860 } 15861 15862 /** 15863 * The opposite of `_.property`; this method creates a function that returns 15864 * the value at a given path of `object`. 15865 * 15866 * @static 15867 * @memberOf _ 15868 * @since 3.0.0 15869 * @category Util 15870 * @param {Object} object The object to query. 15871 * @returns {Function} Returns the new accessor function. 15872 * @example 15873 * 15874 * var array = [0, 1, 2], 15875 * object = { 'a': array, 'b': array, 'c': array }; 15876 * 15877 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 15878 * // => [2, 0] 15879 * 15880 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 15881 * // => [2, 0] 15882 */ 15883 function propertyOf(object) { 15884 return function(path) { 15885 return object == null ? undefined : baseGet(object, path); 15886 }; 15887 } 15888 15889 /** 15890 * Creates an array of numbers (positive and/or negative) progressing from 15891 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 15892 * `start` is specified without an `end` or `step`. If `end` is not specified, 15893 * it's set to `start` with `start` then set to `0`. 15894 * 15895 * **Note:** JavaScript follows the IEEE-754 standard for resolving 15896 * floating-point values which can produce unexpected results. 15897 * 15898 * @static 15899 * @since 0.1.0 15900 * @memberOf _ 15901 * @category Util 15902 * @param {number} [start=0] The start of the range. 15903 * @param {number} end The end of the range. 15904 * @param {number} [step=1] The value to increment or decrement by. 15905 * @returns {Array} Returns the range of numbers. 15906 * @see _.inRange, _.rangeRight 15907 * @example 15908 * 15909 * _.range(4); 15910 * // => [0, 1, 2, 3] 15911 * 15912 * _.range(-4); 15913 * // => [0, -1, -2, -3] 15914 * 15915 * _.range(1, 5); 15916 * // => [1, 2, 3, 4] 15917 * 15918 * _.range(0, 20, 5); 15919 * // => [0, 5, 10, 15] 15920 * 15921 * _.range(0, -4, -1); 15922 * // => [0, -1, -2, -3] 15923 * 15924 * _.range(1, 4, 0); 15925 * // => [1, 1, 1] 15926 * 15927 * _.range(0); 15928 * // => [] 15929 */ 15930 var range = createRange(); 15931 15932 /** 15933 * This method is like `_.range` except that it populates values in 15934 * descending order. 15935 * 15936 * @static 15937 * @memberOf _ 15938 * @since 4.0.0 15939 * @category Util 15940 * @param {number} [start=0] The start of the range. 15941 * @param {number} end The end of the range. 15942 * @param {number} [step=1] The value to increment or decrement by. 15943 * @returns {Array} Returns the range of numbers. 15944 * @see _.inRange, _.range 15945 * @example 15946 * 15947 * _.rangeRight(4); 15948 * // => [3, 2, 1, 0] 15949 * 15950 * _.rangeRight(-4); 15951 * // => [-3, -2, -1, 0] 15952 * 15953 * _.rangeRight(1, 5); 15954 * // => [4, 3, 2, 1] 15955 * 15956 * _.rangeRight(0, 20, 5); 15957 * // => [15, 10, 5, 0] 15958 * 15959 * _.rangeRight(0, -4, -1); 15960 * // => [-3, -2, -1, 0] 15961 * 15962 * _.rangeRight(1, 4, 0); 15963 * // => [1, 1, 1] 15964 * 15965 * _.rangeRight(0); 15966 * // => [] 15967 */ 15968 var rangeRight = createRange(true); 15969 15970 /** 15971 * This method returns a new empty array. 15972 * 15973 * @static 15974 * @memberOf _ 15975 * @since 4.13.0 15976 * @category Util 15977 * @returns {Array} Returns the new empty array. 15978 * @example 15979 * 15980 * var arrays = _.times(2, _.stubArray); 15981 * 15982 * console.log(arrays); 15983 * // => [[], []] 15984 * 15985 * console.log(arrays[0] === arrays[1]); 15986 * // => false 15987 */ 15988 function stubArray() { 15989 return []; 15990 } 15991 15992 /** 15993 * This method returns `false`. 15994 * 15995 * @static 15996 * @memberOf _ 15997 * @since 4.13.0 15998 * @category Util 15999 * @returns {boolean} Returns `false`. 16000 * @example 16001 * 16002 * _.times(2, _.stubFalse); 16003 * // => [false, false] 16004 */ 16005 function stubFalse() { 16006 return false;
vendor: 1,044 bytes, lines 16007-16060
16007 } 16008 16009 /** 16010 * This method returns a new empty object. 16011 * 16012 * @static 16013 * @memberOf _ 16014 * @since 4.13.0 16015 * @category Util 16016 * @returns {Object} Returns the new empty object. 16017 * @example 16018 * 16019 * var objects = _.times(2, _.stubObject); 16020 * 16021 * console.log(objects); 16022 * // => [{}, {}] 16023 * 16024 * console.log(objects[0] === objects[1]); 16025 * // => false 16026 */ 16027 function stubObject() { 16028 return {}; 16029 } 16030 16031 /** 16032 * This method returns an empty string. 16033 * 16034 * @static 16035 * @memberOf _ 16036 * @since 4.13.0 16037 * @category Util 16038 * @returns {string} Returns the empty string. 16039 * @example 16040 * 16041 * _.times(2, _.stubString); 16042 * // => ['', ''] 16043 */ 16044 function stubString() { 16045 return ''; 16046 } 16047 16048 /** 16049 * This method returns `true`. 16050 * 16051 * @static 16052 * @memberOf _ 16053 * @since 4.13.0 16054 * @category Util 16055 * @returns {boolean} Returns `true`. 16056 * @example 16057 * 16058 * _.times(2, _.stubTrue); 16059 * // => [true, true] 16060 */
vendor: 9,081 bytes, lines 16061-16404
16061 function stubTrue() { 16062 return true; 16063 } 16064 16065 /** 16066 * Invokes the iteratee `n` times, returning an array of the results of 16067 * each invocation. The iteratee is invoked with one argument; (index). 16068 * 16069 * @static 16070 * @since 0.1.0 16071 * @memberOf _ 16072 * @category Util 16073 * @param {number} n The number of times to invoke `iteratee`. 16074 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 16075 * @returns {Array} Returns the array of results. 16076 * @example 16077 * 16078 * _.times(3, String); 16079 * // => ['0', '1', '2'] 16080 * 16081 * _.times(4, _.constant(0)); 16082 * // => [0, 0, 0, 0] 16083 */ 16084 function times(n, iteratee) { 16085 n = toInteger(n); 16086 if (n < 1 || n > MAX_SAFE_INTEGER) { 16087 return []; 16088 } 16089 var index = MAX_ARRAY_LENGTH, 16090 length = nativeMin(n, MAX_ARRAY_LENGTH); 16091 16092 iteratee = getIteratee(iteratee); 16093 n -= MAX_ARRAY_LENGTH; 16094 16095 var result = baseTimes(length, iteratee); 16096 while (++index < n) { 16097 iteratee(index); 16098 } 16099 return result; 16100 } 16101 16102 /** 16103 * Converts `value` to a property path array. 16104 * 16105 * @static 16106 * @memberOf _ 16107 * @since 4.0.0 16108 * @category Util 16109 * @param {*} value The value to convert. 16110 * @returns {Array} Returns the new property path array. 16111 * @example 16112 * 16113 * _.toPath('a.b.c'); 16114 * // => ['a', 'b', 'c'] 16115 * 16116 * _.toPath('a[0].b.c'); 16117 * // => ['a', '0', 'b', 'c'] 16118 */ 16119 function toPath(value) { 16120 if (isArray(value)) { 16121 return arrayMap(value, toKey); 16122 } 16123 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 16124 } 16125 16126 /** 16127 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 16128 * 16129 * @static 16130 * @since 0.1.0 16131 * @memberOf _ 16132 * @category Util 16133 * @param {string} [prefix=''] The value to prefix the ID with. 16134 * @returns {string} Returns the unique ID. 16135 * @example 16136 * 16137 * _.uniqueId('contact_'); 16138 * // => 'contact_104' 16139 * 16140 * _.uniqueId(); 16141 * // => '105' 16142 */ 16143 function uniqueId(prefix) { 16144 var id = ++idCounter; 16145 return toString(prefix) + id; 16146 } 16147 16148 /*------------------------------------------------------------------------*/ 16149 16150 /** 16151 * Adds two numbers. 16152 * 16153 * @static 16154 * @memberOf _ 16155 * @since 3.4.0 16156 * @category Math 16157 * @param {number} augend The first number in an addition. 16158 * @param {number} addend The second number in an addition. 16159 * @returns {number} Returns the total. 16160 * @example 16161 * 16162 * _.add(6, 4); 16163 * // => 10 16164 */ 16165 var add = createMathOperation(function(augend, addend) { 16166 return augend + addend; 16167 }, 0); 16168 16169 /** 16170 * Computes `number` rounded up to `precision`. 16171 * 16172 * @static 16173 * @memberOf _ 16174 * @since 3.10.0 16175 * @category Math 16176 * @param {number} number The number to round up. 16177 * @param {number} [precision=0] The precision to round up to. 16178 * @returns {number} Returns the rounded up number. 16179 * @example 16180 * 16181 * _.ceil(4.006); 16182 * // => 5 16183 * 16184 * _.ceil(6.004, 2); 16185 * // => 6.01 16186 * 16187 * _.ceil(6040, -2); 16188 * // => 6100 16189 */ 16190 var ceil = createRound('ceil'); 16191 16192 /** 16193 * Divide two numbers. 16194 * 16195 * @static 16196 * @memberOf _ 16197 * @since 4.7.0 16198 * @category Math 16199 * @param {number} dividend The first number in a division. 16200 * @param {number} divisor The second number in a division. 16201 * @returns {number} Returns the quotient. 16202 * @example 16203 * 16204 * _.divide(6, 4); 16205 * // => 1.5 16206 */ 16207 var divide = createMathOperation(function(dividend, divisor) { 16208 return dividend / divisor; 16209 }, 1); 16210 16211 /** 16212 * Computes `number` rounded down to `precision`. 16213 * 16214 * @static 16215 * @memberOf _ 16216 * @since 3.10.0 16217 * @category Math 16218 * @param {number} number The number to round down. 16219 * @param {number} [precision=0] The precision to round down to. 16220 * @returns {number} Returns the rounded down number. 16221 * @example 16222 * 16223 * _.floor(4.006); 16224 * // => 4 16225 * 16226 * _.floor(0.046, 2); 16227 * // => 0.04 16228 * 16229 * _.floor(4060, -2); 16230 * // => 4000 16231 */ 16232 var floor = createRound('floor'); 16233 16234 /** 16235 * Computes the maximum value of `array`. If `array` is empty or falsey, 16236 * `undefined` is returned. 16237 * 16238 * @static 16239 * @since 0.1.0 16240 * @memberOf _ 16241 * @category Math 16242 * @param {Array} array The array to iterate over. 16243 * @returns {*} Returns the maximum value. 16244 * @example 16245 * 16246 * _.max([4, 2, 8, 6]); 16247 * // => 8 16248 * 16249 * _.max([]); 16250 * // => undefined 16251 */ 16252 function max(array) { 16253 return (array && array.length) 16254 ? baseExtremum(array, identity, baseGt) 16255 : undefined; 16256 } 16257 16258 /** 16259 * This method is like `_.max` except that it accepts `iteratee` which is 16260 * invoked for each element in `array` to generate the criterion by which 16261 * the value is ranked. The iteratee is invoked with one argument: (value). 16262 * 16263 * @static 16264 * @memberOf _ 16265 * @since 4.0.0 16266 * @category Math 16267 * @param {Array} array The array to iterate over. 16268 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16269 * @returns {*} Returns the maximum value. 16270 * @example 16271 * 16272 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 16273 * 16274 * _.maxBy(objects, function(o) { return o.n; }); 16275 * // => { 'n': 2 } 16276 * 16277 * // The `_.property` iteratee shorthand. 16278 * _.maxBy(objects, 'n'); 16279 * // => { 'n': 2 } 16280 */ 16281 function maxBy(array, iteratee) { 16282 return (array && array.length) 16283 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 16284 : undefined; 16285 } 16286 16287 /** 16288 * Computes the mean of the values in `array`. 16289 * 16290 * @static 16291 * @memberOf _ 16292 * @since 4.0.0 16293 * @category Math 16294 * @param {Array} array The array to iterate over. 16295 * @returns {number} Returns the mean. 16296 * @example 16297 * 16298 * _.mean([4, 2, 8, 6]); 16299 * // => 5 16300 */ 16301 function mean(array) { 16302 return baseMean(array, identity); 16303 } 16304 16305 /** 16306 * This method is like `_.mean` except that it accepts `iteratee` which is 16307 * invoked for each element in `array` to generate the value to be averaged. 16308 * The iteratee is invoked with one argument: (value). 16309 * 16310 * @static 16311 * @memberOf _ 16312 * @since 4.7.0 16313 * @category Math 16314 * @param {Array} array The array to iterate over. 16315 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16316 * @returns {number} Returns the mean. 16317 * @example 16318 * 16319 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 16320 * 16321 * _.meanBy(objects, function(o) { return o.n; }); 16322 * // => 5 16323 * 16324 * // The `_.property` iteratee shorthand. 16325 * _.meanBy(objects, 'n'); 16326 * // => 5 16327 */ 16328 function meanBy(array, iteratee) { 16329 return baseMean(array, getIteratee(iteratee, 2)); 16330 } 16331 16332 /** 16333 * Computes the minimum value of `array`. If `array` is empty or falsey, 16334 * `undefined` is returned. 16335 * 16336 * @static 16337 * @since 0.1.0 16338 * @memberOf _ 16339 * @category Math 16340 * @param {Array} array The array to iterate over. 16341 * @returns {*} Returns the minimum value. 16342 * @example 16343 * 16344 * _.min([4, 2, 8, 6]); 16345 * // => 2 16346 * 16347 * _.min([]); 16348 * // => undefined 16349 */ 16350 function min(array) { 16351 return (array && array.length) 16352 ? baseExtremum(array, identity, baseLt) 16353 : undefined; 16354 } 16355 16356 /** 16357 * This method is like `_.min` except that it accepts `iteratee` which is 16358 * invoked for each element in `array` to generate the criterion by which 16359 * the value is ranked. The iteratee is invoked with one argument: (value). 16360 * 16361 * @static 16362 * @memberOf _ 16363 * @since 4.0.0 16364 * @category Math 16365 * @param {Array} array The array to iterate over. 16366 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16367 * @returns {*} Returns the minimum value. 16368 * @example 16369 * 16370 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 16371 * 16372 * _.minBy(objects, function(o) { return o.n; }); 16373 * // => { 'n': 1 } 16374 * 16375 * // The `_.property` iteratee shorthand. 16376 * _.minBy(objects, 'n'); 16377 * // => { 'n': 1 } 16378 */ 16379 function minBy(array, iteratee) { 16380 return (array && array.length) 16381 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 16382 : undefined; 16383 } 16384 16385 /** 16386 * Multiply two numbers. 16387 * 16388 * @static 16389 * @memberOf _ 16390 * @since 4.7.0 16391 * @category Math 16392 * @param {number} multiplier The first number in a multiplication. 16393 * @param {number} multiplicand The second number in a multiplication. 16394 * @returns {number} Returns the product. 16395 * @example 16396 * 16397 * _.multiply(6, 4); 16398 * // => 24 16399 */ 16400 var multiply = createMathOperation(function(multiplier, multiplicand) { 16401 return multiplier * multiplicand; 16402 }, 1); 16403 16404 /**
vendor: 13,137 bytes, lines 16405-16843
16405 * Computes `number` rounded to `precision`. 16406 * 16407 * @static 16408 * @memberOf _ 16409 * @since 3.10.0 16410 * @category Math 16411 * @param {number} number The number to round. 16412 * @param {number} [precision=0] The precision to round to. 16413 * @returns {number} Returns the rounded number. 16414 * @example 16415 * 16416 * _.round(4.006); 16417 * // => 4 16418 * 16419 * _.round(4.006, 2); 16420 * // => 4.01 16421 * 16422 * _.round(4060, -2); 16423 * // => 4100 16424 */ 16425 var round = createRound('round'); 16426 16427 /** 16428 * Subtract two numbers. 16429 * 16430 * @static 16431 * @memberOf _ 16432 * @since 4.0.0 16433 * @category Math 16434 * @param {number} minuend The first number in a subtraction. 16435 * @param {number} subtrahend The second number in a subtraction. 16436 * @returns {number} Returns the difference. 16437 * @example 16438 * 16439 * _.subtract(6, 4); 16440 * // => 2 16441 */ 16442 var subtract = createMathOperation(function(minuend, subtrahend) { 16443 return minuend - subtrahend; 16444 }, 0); 16445 16446 /** 16447 * Computes the sum of the values in `array`. 16448 * 16449 * @static 16450 * @memberOf _ 16451 * @since 3.4.0 16452 * @category Math 16453 * @param {Array} array The array to iterate over. 16454 * @returns {number} Returns the sum. 16455 * @example 16456 * 16457 * _.sum([4, 2, 8, 6]); 16458 * // => 20 16459 */ 16460 function sum(array) { 16461 return (array && array.length) 16462 ? baseSum(array, identity) 16463 : 0; 16464 } 16465 16466 /** 16467 * This method is like `_.sum` except that it accepts `iteratee` which is 16468 * invoked for each element in `array` to generate the value to be summed. 16469 * The iteratee is invoked with one argument: (value). 16470 * 16471 * @static 16472 * @memberOf _ 16473 * @since 4.0.0 16474 * @category Math 16475 * @param {Array} array The array to iterate over. 16476 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 16477 * @returns {number} Returns the sum. 16478 * @example 16479 * 16480 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 16481 * 16482 * _.sumBy(objects, function(o) { return o.n; }); 16483 * // => 20 16484 * 16485 * // The `_.property` iteratee shorthand. 16486 * _.sumBy(objects, 'n'); 16487 * // => 20 16488 */ 16489 function sumBy(array, iteratee) { 16490 return (array && array.length) 16491 ? baseSum(array, getIteratee(iteratee, 2)) 16492 : 0; 16493 } 16494 16495 /*------------------------------------------------------------------------*/ 16496 16497 // Add methods that return wrapped values in chain sequences. 16498 lodash.after = after; 16499 lodash.ary = ary; 16500 lodash.assign = assign; 16501 lodash.assignIn = assignIn; 16502 lodash.assignInWith = assignInWith; 16503 lodash.assignWith = assignWith; 16504 lodash.at = at; 16505 lodash.before = before; 16506 lodash.bind = bind; 16507 lodash.bindAll = bindAll; 16508 lodash.bindKey = bindKey; 16509 lodash.castArray = castArray; 16510 lodash.chain = chain; 16511 lodash.chunk = chunk; 16512 lodash.compact = compact; 16513 lodash.concat = concat; 16514 lodash.cond = cond; 16515 lodash.conforms = conforms; 16516 lodash.constant = constant; 16517 lodash.countBy = countBy; 16518 lodash.create = create; 16519 lodash.curry = curry; 16520 lodash.curryRight = curryRight; 16521 lodash.debounce = debounce; 16522 lodash.defaults = defaults; 16523 lodash.defaultsDeep = defaultsDeep; 16524 lodash.defer = defer; 16525 lodash.delay = delay; 16526 lodash.difference = difference; 16527 lodash.differenceBy = differenceBy; 16528 lodash.differenceWith = differenceWith; 16529 lodash.drop = drop; 16530 lodash.dropRight = dropRight; 16531 lodash.dropRightWhile = dropRightWhile; 16532 lodash.dropWhile = dropWhile; 16533 lodash.fill = fill; 16534 lodash.filter = filter; 16535 lodash.flatMap = flatMap; 16536 lodash.flatMapDeep = flatMapDeep; 16537 lodash.flatMapDepth = flatMapDepth; 16538 lodash.flatten = flatten; 16539 lodash.flattenDeep = flattenDeep; 16540 lodash.flattenDepth = flattenDepth; 16541 lodash.flip = flip; 16542 lodash.flow = flow; 16543 lodash.flowRight = flowRight; 16544 lodash.fromPairs = fromPairs; 16545 lodash.functions = functions; 16546 lodash.functionsIn = functionsIn; 16547 lodash.groupBy = groupBy; 16548 lodash.initial = initial; 16549 lodash.intersection = intersection; 16550 lodash.intersectionBy = intersectionBy; 16551 lodash.intersectionWith = intersectionWith; 16552 lodash.invert = invert; 16553 lodash.invertBy = invertBy; 16554 lodash.invokeMap = invokeMap; 16555 lodash.iteratee = iteratee; 16556 lodash.keyBy = keyBy; 16557 lodash.keys = keys; 16558 lodash.keysIn = keysIn; 16559 lodash.map = map; 16560 lodash.mapKeys = mapKeys; 16561 lodash.mapValues = mapValues; 16562 lodash.matches = matches; 16563 lodash.matchesProperty = matchesProperty; 16564 lodash.memoize = memoize; 16565 lodash.merge = merge; 16566 lodash.mergeWith = mergeWith; 16567 lodash.method = method; 16568 lodash.methodOf = methodOf; 16569 lodash.mixin = mixin; 16570 lodash.negate = negate; 16571 lodash.nthArg = nthArg; 16572 lodash.omit = omit; 16573 lodash.omitBy = omitBy; 16574 lodash.once = once; 16575 lodash.orderBy = orderBy; 16576 lodash.over = over; 16577 lodash.overArgs = overArgs; 16578 lodash.overEvery = overEvery; 16579 lodash.overSome = overSome; 16580 lodash.partial = partial; 16581 lodash.partialRight = partialRight; 16582 lodash.partition = partition; 16583 lodash.pick = pick; 16584 lodash.pickBy = pickBy; 16585 lodash.property = property; 16586 lodash.propertyOf = propertyOf; 16587 lodash.pull = pull; 16588 lodash.pullAll = pullAll; 16589 lodash.pullAllBy = pullAllBy; 16590 lodash.pullAllWith = pullAllWith; 16591 lodash.pullAt = pullAt; 16592 lodash.range = range; 16593 lodash.rangeRight = rangeRight; 16594 lodash.rearg = rearg; 16595 lodash.reject = reject; 16596 lodash.remove = remove; 16597 lodash.rest = rest; 16598 lodash.reverse = reverse; 16599 lodash.sampleSize = sampleSize; 16600 lodash.set = set; 16601 lodash.setWith = setWith; 16602 lodash.shuffle = shuffle; 16603 lodash.slice = slice; 16604 lodash.sortBy = sortBy; 16605 lodash.sortedUniq = sortedUniq; 16606 lodash.sortedUniqBy = sortedUniqBy; 16607 lodash.split = split; 16608 lodash.spread = spread; 16609 lodash.tail = tail; 16610 lodash.take = take; 16611 lodash.takeRight = takeRight; 16612 lodash.takeRightWhile = takeRightWhile; 16613 lodash.takeWhile = takeWhile; 16614 lodash.tap = tap; 16615 lodash.throttle = throttle; 16616 lodash.thru = thru; 16617 lodash.toArray = toArray; 16618 lodash.toPairs = toPairs; 16619 lodash.toPairsIn = toPairsIn; 16620 lodash.toPath = toPath; 16621 lodash.toPlainObject = toPlainObject; 16622 lodash.transform = transform; 16623 lodash.unary = unary; 16624 lodash.union = union; 16625 lodash.unionBy = unionBy; 16626 lodash.unionWith = unionWith; 16627 lodash.uniq = uniq; 16628 lodash.uniqBy = uniqBy; 16629 lodash.uniqWith = uniqWith; 16630 lodash.unset = unset; 16631 lodash.unzip = unzip; 16632 lodash.unzipWith = unzipWith; 16633 lodash.update = update; 16634 lodash.updateWith = updateWith; 16635 lodash.values = values; 16636 lodash.valuesIn = valuesIn; 16637 lodash.without = without; 16638 lodash.words = words; 16639 lodash.wrap = wrap; 16640 lodash.xor = xor; 16641 lodash.xorBy = xorBy; 16642 lodash.xorWith = xorWith; 16643 lodash.zip = zip; 16644 lodash.zipObject = zipObject; 16645 lodash.zipObjectDeep = zipObjectDeep; 16646 lodash.zipWith = zipWith; 16647 16648 // Add aliases. 16649 lodash.entries = toPairs; 16650 lodash.entriesIn = toPairsIn; 16651 lodash.extend = assignIn; 16652 lodash.extendWith = assignInWith; 16653 16654 // Add methods to `lodash.prototype`. 16655 mixin(lodash, lodash); 16656 16657 /*------------------------------------------------------------------------*/ 16658 16659 // Add methods that return unwrapped values in chain sequences. 16660 lodash.add = add; 16661 lodash.attempt = attempt; 16662 lodash.camelCase = camelCase; 16663 lodash.capitalize = capitalize; 16664 lodash.ceil = ceil; 16665 lodash.clamp = clamp; 16666 lodash.clone = clone; 16667 lodash.cloneDeep = cloneDeep; 16668 lodash.cloneDeepWith = cloneDeepWith; 16669 lodash.cloneWith = cloneWith; 16670 lodash.conformsTo = conformsTo; 16671 lodash.deburr = deburr; 16672 lodash.defaultTo = defaultTo; 16673 lodash.divide = divide; 16674 lodash.endsWith = endsWith; 16675 lodash.eq = eq; 16676 lodash.escape = escape; 16677 lodash.escapeRegExp = escapeRegExp; 16678 lodash.every = every; 16679 lodash.find = find; 16680 lodash.findIndex = findIndex; 16681 lodash.findKey = findKey; 16682 lodash.findLast = findLast; 16683 lodash.findLastIndex = findLastIndex; 16684 lodash.findLastKey = findLastKey; 16685 lodash.floor = floor; 16686 lodash.forEach = forEach; 16687 lodash.forEachRight = forEachRight; 16688 lodash.forIn = forIn; 16689 lodash.forInRight = forInRight; 16690 lodash.forOwn = forOwn; 16691 lodash.forOwnRight = forOwnRight; 16692 lodash.get = get; 16693 lodash.gt = gt; 16694 lodash.gte = gte; 16695 lodash.has = has; 16696 lodash.hasIn = hasIn; 16697 lodash.head = head; 16698 lodash.identity = identity; 16699 lodash.includes = includes; 16700 lodash.indexOf = indexOf; 16701 lodash.inRange = inRange; 16702 lodash.invoke = invoke; 16703 lodash.isArguments = isArguments; 16704 lodash.isArray = isArray; 16705 lodash.isArrayBuffer = isArrayBuffer; 16706 lodash.isArrayLike = isArrayLike; 16707 lodash.isArrayLikeObject = isArrayLikeObject; 16708 lodash.isBoolean = isBoolean; 16709 lodash.isBuffer = isBuffer; 16710 lodash.isDate = isDate; 16711 lodash.isElement = isElement; 16712 lodash.isEmpty = isEmpty; 16713 lodash.isEqual = isEqual; 16714 lodash.isEqualWith = isEqualWith; 16715 lodash.isError = isError; 16716 lodash.isFinite = isFinite; 16717 lodash.isFunction = isFunction; 16718 lodash.isInteger = isInteger; 16719 lodash.isLength = isLength; 16720 lodash.isMap = isMap; 16721 lodash.isMatch = isMatch; 16722 lodash.isMatchWith = isMatchWith; 16723 lodash.isNaN = isNaN; 16724 lodash.isNative = isNative; 16725 lodash.isNil = isNil; 16726 lodash.isNull = isNull; 16727 lodash.isNumber = isNumber; 16728 lodash.isObject = isObject; 16729 lodash.isObjectLike = isObjectLike; 16730 lodash.isPlainObject = isPlainObject; 16731 lodash.isRegExp = isRegExp; 16732 lodash.isSafeInteger = isSafeInteger; 16733 lodash.isSet = isSet; 16734 lodash.isString = isString; 16735 lodash.isSymbol = isSymbol; 16736 lodash.isTypedArray = isTypedArray; 16737 lodash.isUndefined = isUndefined; 16738 lodash.isWeakMap = isWeakMap; 16739 lodash.isWeakSet = isWeakSet; 16740 lodash.join = join; 16741 lodash.kebabCase = kebabCase; 16742 lodash.last = last; 16743 lodash.lastIndexOf = lastIndexOf; 16744 lodash.lowerCase = lowerCase; 16745 lodash.lowerFirst = lowerFirst; 16746 lodash.lt = lt; 16747 lodash.lte = lte; 16748 lodash.max = max; 16749 lodash.maxBy = maxBy; 16750 lodash.mean = mean; 16751 lodash.meanBy = meanBy; 16752 lodash.min = min; 16753 lodash.minBy = minBy; 16754 lodash.stubArray = stubArray; 16755 lodash.stubFalse = stubFalse; 16756 lodash.stubObject = stubObject; 16757 lodash.stubString = stubString; 16758 lodash.stubTrue = stubTrue; 16759 lodash.multiply = multiply; 16760 lodash.nth = nth; 16761 lodash.noConflict = noConflict; 16762 lodash.noop = noop; 16763 lodash.now = now; 16764 lodash.pad = pad; 16765 lodash.padEnd = padEnd; 16766 lodash.padStart = padStart; 16767 lodash.parseInt = parseInt; 16768 lodash.random = random; 16769 lodash.reduce = reduce; 16770 lodash.reduceRight = reduceRight; 16771 lodash.repeat = repeat; 16772 lodash.replace = replace; 16773 lodash.result = result; 16774 lodash.round = round; 16775 lodash.runInContext = runInContext; 16776 lodash.sample = sample; 16777 lodash.size = size; 16778 lodash.snakeCase = snakeCase; 16779 lodash.some = some; 16780 lodash.sortedIndex = sortedIndex; 16781 lodash.sortedIndexBy = sortedIndexBy; 16782 lodash.sortedIndexOf = sortedIndexOf; 16783 lodash.sortedLastIndex = sortedLastIndex; 16784 lodash.sortedLastIndexBy = sortedLastIndexBy; 16785 lodash.sortedLastIndexOf = sortedLastIndexOf; 16786 lodash.startCase = startCase; 16787 lodash.startsWith = startsWith; 16788 lodash.subtract = subtract; 16789 lodash.sum = sum; 16790 lodash.sumBy = sumBy; 16791 lodash.template = template; 16792 lodash.times = times; 16793 lodash.toFinite = toFinite; 16794 lodash.toInteger = toInteger; 16795 lodash.toLength = toLength; 16796 lodash.toLower = toLower; 16797 lodash.toNumber = toNumber; 16798 lodash.toSafeInteger = toSafeInteger; 16799 lodash.toString = toString; 16800 lodash.toUpper = toUpper; 16801 lodash.trim = trim; 16802 lodash.trimEnd = trimEnd; 16803 lodash.trimStart = trimStart; 16804 lodash.truncate = truncate; 16805 lodash.unescape = unescape; 16806 lodash.uniqueId = uniqueId; 16807 lodash.upperCase = upperCase; 16808 lodash.upperFirst = upperFirst; 16809 16810 // Add aliases. 16811 lodash.each = forEach; 16812 lodash.eachRight = forEachRight; 16813 lodash.first = head; 16814 16815 mixin(lodash, (function() { 16816 var source = {}; 16817 baseForOwn(lodash, function(func, methodName) { 16818 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 16819 source[methodName] = func; 16820 } 16821 }); 16822 return source; 16823 }()), { 'chain': false }); 16824 16825 /*------------------------------------------------------------------------*/ 16826 16827 /** 16828 * The semantic version number. 16829 * 16830 * @static 16831 * @memberOf _ 16832 * @type {string} 16833 */ 16834 lodash.VERSION = VERSION; 16835 16836 // Assign default placeholders. 16837 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 16838 lodash[methodName].placeholder = lodash; 16839 }); 16840 16841 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 16842 arrayEach(['drop', 'take'], function(methodName, index) { 16843 LazyWrapper.prototype[methodName] = function(n) {
vendor: 6,109 bytes, lines 16844-17019
16844 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 16845 16846 var result = (this.__filtered__ && !index) 16847 ? new LazyWrapper(this) 16848 : this.clone(); 16849 16850 if (result.__filtered__) { 16851 result.__takeCount__ = nativeMin(n, result.__takeCount__); 16852 } else { 16853 result.__views__.push({ 16854 'size': nativeMin(n, MAX_ARRAY_LENGTH), 16855 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 16856 }); 16857 } 16858 return result; 16859 }; 16860 16861 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 16862 return this.reverse()[methodName](n).reverse(); 16863 }; 16864 }); 16865 16866 // Add `LazyWrapper` methods that accept an `iteratee` value. 16867 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 16868 var type = index + 1, 16869 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 16870 16871 LazyWrapper.prototype[methodName] = function(iteratee) { 16872 var result = this.clone(); 16873 result.__iteratees__.push({ 16874 'iteratee': getIteratee(iteratee, 3), 16875 'type': type 16876 }); 16877 result.__filtered__ = result.__filtered__ || isFilter; 16878 return result; 16879 }; 16880 }); 16881 16882 // Add `LazyWrapper` methods for `_.head` and `_.last`. 16883 arrayEach(['head', 'last'], function(methodName, index) { 16884 var takeName = 'take' + (index ? 'Right' : ''); 16885 16886 LazyWrapper.prototype[methodName] = function() { 16887 return this[takeName](1).value()[0]; 16888 }; 16889 }); 16890 16891 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 16892 arrayEach(['initial', 'tail'], function(methodName, index) { 16893 var dropName = 'drop' + (index ? '' : 'Right'); 16894 16895 LazyWrapper.prototype[methodName] = function() { 16896 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 16897 }; 16898 }); 16899 16900 LazyWrapper.prototype.compact = function() { 16901 return this.filter(identity); 16902 }; 16903 16904 LazyWrapper.prototype.find = function(predicate) { 16905 return this.filter(predicate).head(); 16906 }; 16907 16908 LazyWrapper.prototype.findLast = function(predicate) { 16909 return this.reverse().find(predicate); 16910 }; 16911 16912 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 16913 if (typeof path == 'function') { 16914 return new LazyWrapper(this); 16915 } 16916 return this.map(function(value) { 16917 return baseInvoke(value, path, args); 16918 }); 16919 }); 16920 16921 LazyWrapper.prototype.reject = function(predicate) { 16922 return this.filter(negate(getIteratee(predicate))); 16923 }; 16924 16925 LazyWrapper.prototype.slice = function(start, end) { 16926 start = toInteger(start); 16927 16928 var result = this; 16929 if (result.__filtered__ && (start > 0 || end < 0)) { 16930 return new LazyWrapper(result); 16931 } 16932 if (start < 0) { 16933 result = result.takeRight(-start); 16934 } else if (start) { 16935 result = result.drop(start); 16936 } 16937 if (end !== undefined) { 16938 end = toInteger(end); 16939 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 16940 } 16941 return result; 16942 }; 16943 16944 LazyWrapper.prototype.takeRightWhile = function(predicate) { 16945 return this.reverse().takeWhile(predicate).reverse(); 16946 }; 16947 16948 LazyWrapper.prototype.toArray = function() { 16949 return this.take(MAX_ARRAY_LENGTH); 16950 }; 16951 16952 // Add `LazyWrapper` methods to `lodash.prototype`. 16953 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 16954 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 16955 isTaker = /^(?:head|last)$/.test(methodName), 16956 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 16957 retUnwrapped = isTaker || /^find/.test(methodName); 16958 16959 if (!lodashFunc) { 16960 return; 16961 } 16962 lodash.prototype[methodName] = function() { 16963 var value = this.__wrapped__, 16964 args = isTaker ? [1] : arguments, 16965 isLazy = value instanceof LazyWrapper, 16966 iteratee = args[0], 16967 useLazy = isLazy || isArray(value); 16968 16969 var interceptor = function(value) { 16970 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 16971 return (isTaker && chainAll) ? result[0] : result; 16972 }; 16973 16974 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 16975 // Avoid lazy use if the iteratee has a "length" value other than `1`. 16976 isLazy = useLazy = false; 16977 } 16978 var chainAll = this.__chain__, 16979 isHybrid = !!this.__actions__.length, 16980 isUnwrapped = retUnwrapped && !chainAll, 16981 onlyLazy = isLazy && !isHybrid; 16982 16983 if (!retUnwrapped && useLazy) { 16984 value = onlyLazy ? value : new LazyWrapper(this); 16985 var result = func.apply(value, args); 16986 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 16987 return new LodashWrapper(result, chainAll); 16988 } 16989 if (isUnwrapped && onlyLazy) { 16990 return func.apply(this, args); 16991 } 16992 result = this.thru(interceptor); 16993 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 16994 }; 16995 }); 16996 16997 // Add `Array` methods to `lodash.prototype`. 16998 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 16999 var func = arrayProto[methodName], 17000 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 17001 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 17002 17003 lodash.prototype[methodName] = function() { 17004 var args = arguments; 17005 if (retUnwrapped && !this.__chain__) { 17006 var value = this.value(); 17007 return func.apply(isArray(value) ? value : [], args); 17008 } 17009 return this[chainName](function(value) { 17010 return func.apply(isArray(value) ? value : [], args); 17011 }); 17012 }; 17013 }); 17014 17015 // Map minified method names to their real names. 17016 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 17017 var lodashFunc = lodash[methodName]; 17018 if (lodashFunc) { 17019 var key =
vendor: 2,149 bytes, lines 17019-17084
17019(lodashFunc.name + ''), 17020 names = realNames[key] || (realNames[key] = []); 17021 17022 names.push({ 'name': methodName, 'func': lodashFunc }); 17023 } 17024 }); 17025 17026 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 17027 'name': 'wrapper', 17028 'func': undefined 17029 }]; 17030 17031 // Add methods to `LazyWrapper`. 17032 LazyWrapper.prototype.clone = lazyClone; 17033 LazyWrapper.prototype.reverse = lazyReverse; 17034 LazyWrapper.prototype.value = lazyValue; 17035 17036 // Add chain sequence methods to the `lodash` wrapper. 17037 lodash.prototype.at = wrapperAt; 17038 lodash.prototype.chain = wrapperChain; 17039 lodash.prototype.commit = wrapperCommit; 17040 lodash.prototype.next = wrapperNext; 17041 lodash.prototype.plant = wrapperPlant; 17042 lodash.prototype.reverse = wrapperReverse; 17043 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 17044 17045 // Add lazy aliases. 17046 lodash.prototype.first = lodash.prototype.head; 17047 17048 if (symIterator) { 17049 lodash.prototype[symIterator] = wrapperToIterator; 17050 } 17051 return lodash; 17052 }); 17053 17054 /*--------------------------------------------------------------------------*/ 17055 17056 // Export lodash. 17057 var _ = runInContext(); 17058 17059 // Some AMD build optimizers, like r.js, check for condition patterns like: 17060 if (false && typeof define == 'function' && typeof define.amd == 'object' && define.amd) { 17061 // Expose Lodash on the global object to prevent errors when Lodash is 17062 // loaded by a script tag in the presence of an AMD loader. 17063 // See http://requirejs.org/docs/errors.html#mismatch for more details. 17064 // Use `_.noConflict` to remove Lodash from the global object. 17065 root._ = _; 17066 17067 // Define as an anonymous module so, through path mapping, it can be 17068 // referenced as the "underscore" module. 17069 define(function() { 17070 return _; 17071 }); 17072 } 17073 // Check for `exports` after `define` in case a build optimizer adds it. 17074 else if (freeModule) { 17075 // Export for Node.js. 17076 (freeModule.exports = _)._ = _; 17077 // Export for CommonJS support. 17078 freeExports._ = _; 17079 } 17080 else { 17081 // Export to the global object. 17082 root._ = _; 17083 } 17084}.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.