lodash.js (lodash-4.0.0) | : | lodash.js (lodash-4.17.21) |
---|---|---|
/** | /** | |
* @license | * @license | |
* lodash 4.0.0 (Custom Build) <https://lodash.com/> | * Lodash <https://lodash.com/> | |
* Build: `lodash -o ./dist/lodash.js` | * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> | |
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | * Released under MIT license <https://lodash.com/license> | |
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | |
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporter | * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editor | |
s & Editors | s | |
* Available under MIT license <https://lodash.com/license> | ||
*/ | */ | |
;(function() { | ;(function() { | |
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ | /** Used as a safe reference for `undefined` in pre-ES5 environments. */ | |
var undefined; | var undefined; | |
/** Used as the semantic version number. */ | /** Used as the semantic version number. */ | |
var VERSION = '4.0.0'; | var VERSION = '4.17.21'; | |
/** Used to compose bitmasks for wrapper metadata. */ | /** Used as the size to enable large array optimizations. */ | |
var BIND_FLAG = 1, | var LARGE_ARRAY_SIZE = 200; | |
BIND_KEY_FLAG = 2, | ||
CURRY_BOUND_FLAG = 4, | /** Error message constants. */ | |
CURRY_FLAG = 8, | var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=p | |
CURRY_RIGHT_FLAG = 16, | onyfill.', | |
PARTIAL_FLAG = 32, | FUNC_ERROR_TEXT = 'Expected a function', | |
PARTIAL_RIGHT_FLAG = 64, | INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.t | |
ARY_FLAG = 128, | emplate`'; | |
REARG_FLAG = 256, | ||
FLIP_FLAG = 512; | /** Used to stand-in for `undefined` hash values. */ | |
var HASH_UNDEFINED = '__lodash_hash_undefined__'; | ||
/** Used to compose bitmasks for comparison styles. */ | ||
var UNORDERED_COMPARE_FLAG = 1, | /** Used as the maximum memoize cache size. */ | |
PARTIAL_COMPARE_FLAG = 2; | var MAX_MEMOIZE_SIZE = 500; | |
/** Used as the internal argument placeholder. */ | ||
var PLACEHOLDER = '__lodash_placeholder__'; | ||
/** Used to compose bitmasks for cloning. */ | ||
var CLONE_DEEP_FLAG = 1, | ||
CLONE_FLAT_FLAG = 2, | ||
CLONE_SYMBOLS_FLAG = 4; | ||
/** Used to compose bitmasks for value comparisons. */ | ||
var COMPARE_PARTIAL_FLAG = 1, | ||
COMPARE_UNORDERED_FLAG = 2; | ||
/** Used to compose bitmasks for function metadata. */ | ||
var WRAP_BIND_FLAG = 1, | ||
WRAP_BIND_KEY_FLAG = 2, | ||
WRAP_CURRY_BOUND_FLAG = 4, | ||
WRAP_CURRY_FLAG = 8, | ||
WRAP_CURRY_RIGHT_FLAG = 16, | ||
WRAP_PARTIAL_FLAG = 32, | ||
WRAP_PARTIAL_RIGHT_FLAG = 64, | ||
WRAP_ARY_FLAG = 128, | ||
WRAP_REARG_FLAG = 256, | ||
WRAP_FLIP_FLAG = 512; | ||
/** Used as default options for `_.truncate`. */ | /** Used as default options for `_.truncate`. */ | |
var DEFAULT_TRUNC_LENGTH = 30, | var DEFAULT_TRUNC_LENGTH = 30, | |
DEFAULT_TRUNC_OMISSION = '...'; | DEFAULT_TRUNC_OMISSION = '...'; | |
/** Used to detect hot functions by number of calls within a span of milliseco nds. */ | /** Used to detect hot functions by number of calls within a span of milliseco nds. */ | |
var HOT_COUNT = 150, | var HOT_COUNT = 800, | |
HOT_SPAN = 16; | HOT_SPAN = 16; | |
/** Used as the size to enable large array optimizations. */ | ||
var LARGE_ARRAY_SIZE = 200; | ||
/** Used to indicate the type of lazy iteratees. */ | /** Used to indicate the type of lazy iteratees. */ | |
var LAZY_FILTER_FLAG = 1, | var LAZY_FILTER_FLAG = 1, | |
LAZY_MAP_FLAG = 2, | LAZY_MAP_FLAG = 2, | |
LAZY_WHILE_FLAG = 3; | LAZY_WHILE_FLAG = 3; | |
/** Used as the `TypeError` message for "Functions" methods. */ | ||
var FUNC_ERROR_TEXT = 'Expected a function'; | ||
/** Used to stand-in for `undefined` hash values. */ | ||
var HASH_UNDEFINED = '__lodash_hash_undefined__'; | ||
/** Used as references for various `Number` constants. */ | /** Used as references for various `Number` constants. */ | |
var INFINITY = 1 / 0, | var INFINITY = 1 / 0, | |
MAX_SAFE_INTEGER = 9007199254740991, | MAX_SAFE_INTEGER = 9007199254740991, | |
MAX_INTEGER = 1.7976931348623157e+308, | MAX_INTEGER = 1.7976931348623157e+308, | |
NAN = 0 / 0; | NAN = 0 / 0; | |
/** Used as references for the maximum length and index of an array. */ | /** Used as references for the maximum length and index of an array. */ | |
var MAX_ARRAY_LENGTH = 4294967295, | var MAX_ARRAY_LENGTH = 4294967295, | |
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, | MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, | |
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; | HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; | |
/** Used as the internal argument placeholder. */ | /** Used to associate wrap methods with their bit flags. */ | |
var PLACEHOLDER = '__lodash_placeholder__'; | var wrapFlags = [ | |
['ary', WRAP_ARY_FLAG], | ||
['bind', WRAP_BIND_FLAG], | ||
['bindKey', WRAP_BIND_KEY_FLAG], | ||
['curry', WRAP_CURRY_FLAG], | ||
['curryRight', WRAP_CURRY_RIGHT_FLAG], | ||
['flip', WRAP_FLIP_FLAG], | ||
['partial', WRAP_PARTIAL_FLAG], | ||
['partialRight', WRAP_PARTIAL_RIGHT_FLAG], | ||
['rearg', WRAP_REARG_FLAG] | ||
]; | ||
/** `Object#toString` result references. */ | /** `Object#toString` result references. */ | |
var argsTag = '[object Arguments]', | var argsTag = '[object Arguments]', | |
arrayTag = '[object Array]', | arrayTag = '[object Array]', | |
asyncTag = '[object AsyncFunction]', | ||
boolTag = '[object Boolean]', | boolTag = '[object Boolean]', | |
dateTag = '[object Date]', | dateTag = '[object Date]', | |
domExcTag = '[object DOMException]', | ||
errorTag = '[object Error]', | errorTag = '[object Error]', | |
funcTag = '[object Function]', | funcTag = '[object Function]', | |
genTag = '[object GeneratorFunction]', | genTag = '[object GeneratorFunction]', | |
mapTag = '[object Map]', | mapTag = '[object Map]', | |
numberTag = '[object Number]', | numberTag = '[object Number]', | |
nullTag = '[object Null]', | ||
objectTag = '[object Object]', | objectTag = '[object Object]', | |
promiseTag = '[object Promise]', | ||
proxyTag = '[object Proxy]', | ||
regexpTag = '[object RegExp]', | regexpTag = '[object RegExp]', | |
setTag = '[object Set]', | setTag = '[object Set]', | |
stringTag = '[object String]', | stringTag = '[object String]', | |
symbolTag = '[object Symbol]', | symbolTag = '[object Symbol]', | |
weakMapTag = '[object WeakMap]'; | undefinedTag = '[object Undefined]', | |
weakMapTag = '[object WeakMap]', | ||
weakSetTag = '[object WeakSet]'; | ||
var arrayBufferTag = '[object ArrayBuffer]', | var arrayBufferTag = '[object ArrayBuffer]', | |
dataViewTag = '[object DataView]', | ||
float32Tag = '[object Float32Array]', | float32Tag = '[object Float32Array]', | |
float64Tag = '[object Float64Array]', | float64Tag = '[object Float64Array]', | |
int8Tag = '[object Int8Array]', | int8Tag = '[object Int8Array]', | |
int16Tag = '[object Int16Array]', | int16Tag = '[object Int16Array]', | |
int32Tag = '[object Int32Array]', | int32Tag = '[object Int32Array]', | |
uint8Tag = '[object Uint8Array]', | uint8Tag = '[object Uint8Array]', | |
uint8ClampedTag = '[object Uint8ClampedArray]', | uint8ClampedTag = '[object Uint8ClampedArray]', | |
uint16Tag = '[object Uint16Array]', | uint16Tag = '[object Uint16Array]', | |
uint32Tag = '[object Uint32Array]'; | uint32Tag = '[object Uint32Array]'; | |
/** Used to match empty string literals in compiled template source. */ | /** Used to match empty string literals in compiled template source. */ | |
var reEmptyStringLeading = /\b__p \+= '';/g, | var reEmptyStringLeading = /\b__p \+= '';/g, | |
reEmptyStringMiddle = /\b(__p \+=) '' \+/g, | reEmptyStringMiddle = /\b(__p \+=) '' \+/g, | |
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; | reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; | |
/** Used to match HTML entities and HTML characters. */ | /** Used to match HTML entities and HTML characters. */ | |
var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, | var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, | |
reUnescapedHtml = /[&<>"'`]/g, | reUnescapedHtml = /[&<>"']/g, | |
reHasEscapedHtml = RegExp(reEscapedHtml.source), | reHasEscapedHtml = RegExp(reEscapedHtml.source), | |
reHasUnescapedHtml = RegExp(reUnescapedHtml.source); | reHasUnescapedHtml = RegExp(reUnescapedHtml.source); | |
/** Used to match template delimiters. */ | /** Used to match template delimiters. */ | |
var reEscape = /<%-([\s\S]+?)%>/g, | var reEscape = /<%-([\s\S]+?)%>/g, | |
reEvaluate = /<%([\s\S]+?)%>/g, | reEvaluate = /<%([\s\S]+?)%>/g, | |
reInterpolate = /<%=([\s\S]+?)%>/g; | reInterpolate = /<%=([\s\S]+?)%>/g; | |
/** Used to match property names within property paths. */ | /** Used to match property names within property paths. */ | |
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, | var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, | |
reIsPlainProp = /^\w*$/, | reIsPlainProp = /^\w*$/, | |
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*? )\2)\]/g; | rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*? )\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | |
/** Used to match `RegExp` [syntax characters](http://ecma-international.org/e | /** | |
cma-262/6.0/#sec-patterns). */ | * Used to match `RegExp` | |
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-pattern | ||
s). | ||
*/ | ||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, | var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, | |
reHasRegExpChar = RegExp(reRegExpChar.source); | reHasRegExpChar = RegExp(reRegExpChar.source); | |
/** Used to match leading and trailing whitespace. */ | /** Used to match leading whitespace. */ | |
var reTrim = /^\s+|\s+$/g, | var reTrimStart = /^\s+/; | |
reTrimStart = /^\s+/, | ||
reTrimEnd = /\s+$/; | /** Used to match a single whitespace character. */ | |
var reWhitespace = /\s/; | ||
/** Used to match wrap detail comments. */ | ||
var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, | ||
reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, | ||
reSplitDetails = /,? & /; | ||
/** Used to match words composed of alphanumeric characters. */ | ||
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; | ||
/** | ||
* Used to validate the `validate` option in `_.template` variable. | ||
* | ||
* Forbids characters which could potentially change the meaning of the functi | ||
on argument definition: | ||
* - "()," (modification of function parameters) | ||
* - "=" (default value) | ||
* - "[]{}" (destructuring of function parameters) | ||
* - "/" (beginning of a comment) | ||
* - whitespace | ||
*/ | ||
var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; | ||
/** Used to match backslashes in property paths. */ | /** Used to match backslashes in property paths. */ | |
var reEscapeChar = /\\(\\)?/g; | var reEscapeChar = /\\(\\)?/g; | |
/** Used to match [ES template delimiters](http://ecma-international.org/ecma- | /** | |
262/6.0/#sec-template-literal-lexical-components). */ | * Used to match | |
* [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-te | ||
mplate-literal-lexical-components). | ||
*/ | ||
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; | var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; | |
/** Used to match `RegExp` flags from their coerced string values. */ | /** Used to match `RegExp` flags from their coerced string values. */ | |
var reFlags = /\w*$/; | var reFlags = /\w*$/; | |
/** Used to detect hexadecimal string values. */ | ||
var reHasHexPrefix = /^0x/i; | ||
/** Used to detect bad signed hexadecimal string values. */ | /** Used to detect bad signed hexadecimal string values. */ | |
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; | var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; | |
/** Used to detect binary string values. */ | /** Used to detect binary string values. */ | |
var reIsBinary = /^0b[01]+$/i; | var reIsBinary = /^0b[01]+$/i; | |
/** Used to detect host constructors (Safari > 5). */ | /** Used to detect host constructors (Safari). */ | |
var reIsHostCtor = /^\[object .+?Constructor\]$/; | var reIsHostCtor = /^\[object .+?Constructor\]$/; | |
/** Used to detect octal string values. */ | /** Used to detect octal string values. */ | |
var reIsOctal = /^0o[0-7]+$/i; | var reIsOctal = /^0o[0-7]+$/i; | |
/** Used to detect unsigned integer values. */ | /** Used to detect unsigned integer values. */ | |
var reIsUint = /^(?:0|[1-9]\d*)$/; | var reIsUint = /^(?:0|[1-9]\d*)$/; | |
/** Used to match latin-1 supplementary letters (excluding mathematical operat | /** Used to match Latin Unicode letters (excluding mathematical operators). */ | |
ors). */ | var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; | |
var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; | ||
/** Used to ensure capturing order of template delimiters. */ | /** Used to ensure capturing order of template delimiters. */ | |
var reNoMatch = /($^)/; | var reNoMatch = /($^)/; | |
/** Used to match unescaped characters in compiled string literals. */ | /** Used to match unescaped characters in compiled string literals. */ | |
var reUnescapedString = /['\n\r\u2028\u2029\\]/g; | var reUnescapedString = /['\n\r\u2028\u2029\\]/g; | |
/** Used to compose unicode character classes. */ | /** Used to compose unicode character classes. */ | |
var rsAstralRange = '\\ud800-\\udfff', | var rsAstralRange = '\\ud800-\\udfff', | |
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23', | rsComboMarksRange = '\\u0300-\\u036f', | |
reComboHalfMarksRange = '\\ufe20-\\ufe2f', | ||
rsComboSymbolsRange = '\\u20d0-\\u20ff', | ||
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsR | ||
ange, | ||
rsDingbatRange = '\\u2700-\\u27bf', | rsDingbatRange = '\\u2700-\\u27bf', | |
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', | rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', | |
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', | rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', | |
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', | rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', | |
rsQuoteRange = '\\u2018\\u2019\\u201c\\u201d', | rsPunctuationRange = '\\u2000-\\u206f', | |
rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e \\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u 202f\\u205f\\u3000', | rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e \\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u 202f\\u205f\\u3000', | |
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', | rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', | |
rsVarRange = '\\ufe0e\\ufe0f', | rsVarRange = '\\ufe0e\\ufe0f', | |
rsBreakRange = rsMathOpRange + rsNonCharRange + rsQuoteRange + rsSpaceRang e; | rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpa ceRange; | |
/** Used to compose unicode capture groups. */ | /** Used to compose unicode capture groups. */ | |
var rsAstral = '[' + rsAstralRange + ']', | var rsApos = "['\u2019]", | |
rsAstral = '[' + rsAstralRange + ']', | ||
rsBreak = '[' + rsBreakRange + ']', | rsBreak = '[' + rsBreakRange + ']', | |
rsCombo = '[' + rsComboRange + ']', | rsCombo = '[' + rsComboRange + ']', | |
rsDigits = '\\d+', | rsDigits = '\\d+', | |
rsDingbat = '[' + rsDingbatRange + ']', | rsDingbat = '[' + rsDingbatRange + ']', | |
rsLower = '[' + rsLowerRange + ']', | rsLower = '[' + rsLowerRange + ']', | |
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', | rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', | |
rsModifier = '(?:\\ud83c[\\udffb-\\udfff])', | rsFitz = '\\ud83c[\\udffb-\\udfff]', | |
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', | ||
rsNonAstral = '[^' + rsAstralRange + ']', | rsNonAstral = '[^' + rsAstralRange + ']', | |
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', | rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', | |
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', | rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', | |
rsUpper = '[' + rsUpperRange + ']', | rsUpper = '[' + rsUpperRange + ']', | |
rsZWJ = '\\u200d'; | rsZWJ = '\\u200d'; | |
/** Used to compose unicode regexes. */ | /** Used to compose unicode regexes. */ | |
var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')', | var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', | |
rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')', | rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', | |
rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', | ||
rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', | ||
reOptMod = rsModifier + '?', | reOptMod = rsModifier + '?', | |
rsOptVar = '[' + rsVarRange + ']?', | rsOptVar = '[' + rsVarRange + ']?', | |
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair]. join('|') + ')' + rsOptVar + reOptMod + ')*', | rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair]. join('|') + ')' + rsOptVar + reOptMod + ')*', | |
rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', | ||
rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', | ||
rsSeq = rsOptVar + reOptMod + rsOptJoin, | rsSeq = rsOptVar + reOptMod + rsOptJoin, | |
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rs Seq, | rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rs Seq, | |
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSu rrPair, rsAstral].join('|') + ')'; | rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSu rrPair, rsAstral].join('|') + ')'; | |
/** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/ | /** Used to match apostrophes. */ | |
Combining_Diacritical_Marks). */ | var reApos = RegExp(rsApos, 'g'); | |
/** | ||
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/C | ||
ombining_Diacritical_Marks) and | ||
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Com | ||
bining_Diacritical_Marks_for_Symbols). | ||
*/ | ||
var reComboMark = RegExp(rsCombo, 'g'); | var reComboMark = RegExp(rsCombo, 'g'); | |
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-u nicode). */ | /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-u nicode). */ | |
var reComplexSymbol = RegExp(rsSymbol + rsSeq, 'g'); | var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g') | |
; | ||
/** Used to detect strings with [zero-width joiners or code points from the as | ||
tral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ | ||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + r | ||
sVarRange + ']'); | ||
/** Used to match non-compound words composed of alphanumeric characters. */ | ||
var reBasicWord = /[a-zA-Z0-9]+/g; | ||
/** Used to match complex or compound words. */ | /** Used to match complex or compound words. */ | |
var reComplexWord = RegExp([ | var reUnicodeWord = RegExp([ | |
rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', | rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, | |
rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')' | '$'].join('|') + ')', | |
, | rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLowe | |
rsUpper + '?' + rsLowerMisc + '+', | r, '$'].join('|') + ')', | |
rsDigits + '(?:' + rsLowerMisc + '+)?', | rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, | |
rsUpper + '+' + rsOptContrUpper, | ||
rsOrdUpper, | ||
rsOrdLower, | ||
rsDigits, | ||
rsEmoji | rsEmoji | |
].join('|'), 'g'); | ].join('|'), 'g'); | |
/** Used to detect strings with [zero-width joiners or code points from the as | ||
tral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ | ||
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarR | ||
ange + ']'); | ||
/** Used to detect strings that need a more robust regexp to match words. */ | /** Used to detect strings that need a more robust regexp to match words. */ | |
var reHasComplexWord = /[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; | var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[ ^a-zA-Z0-9 ]/; | |
/** Used to assign default `context` object properties. */ | /** Used to assign default `context` object properties. */ | |
var contextProps = [ | var contextProps = [ | |
'Array', 'Date', 'Error', 'Float32Array', 'Float64Array', 'Function', | 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Arra | |
'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', | y', | |
'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', | 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object' | |
'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', '_', | , | |
'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' | 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', | |
'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', | ||
'_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' | ||
]; | ]; | |
/** Used to make template sourceURLs easier to identify. */ | /** Used to make template sourceURLs easier to identify. */ | |
var templateCounter = -1; | var templateCounter = -1; | |
/** Used to identify `toStringTag` values of typed arrays. */ | /** Used to identify `toStringTag` values of typed arrays. */ | |
var typedArrayTags = {}; | var typedArrayTags = {}; | |
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = | typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = | |
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = | typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = | |
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = | typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = | |
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = | typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = | |
typedArrayTags[uint32Tag] = true; | typedArrayTags[uint32Tag] = true; | |
typedArrayTags[argsTag] = typedArrayTags[arrayTag] = | typedArrayTags[argsTag] = typedArrayTags[arrayTag] = | |
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = | typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = | |
typedArrayTags[dateTag] = typedArrayTags[errorTag] = | typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = | |
typedArrayTags[funcTag] = typedArrayTags[mapTag] = | typedArrayTags[errorTag] = typedArrayTags[funcTag] = | |
typedArrayTags[numberTag] = typedArrayTags[objectTag] = | typedArrayTags[mapTag] = typedArrayTags[numberTag] = | |
typedArrayTags[regexpTag] = typedArrayTags[setTag] = | typedArrayTags[objectTag] = typedArrayTags[regexpTag] = | |
typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; | typedArrayTags[setTag] = typedArrayTags[stringTag] = | |
typedArrayTags[weakMapTag] = false; | ||
/** Used to identify `toStringTag` values supported by `_.clone`. */ | /** Used to identify `toStringTag` values supported by `_.clone`. */ | |
var cloneableTags = {}; | var cloneableTags = {}; | |
cloneableTags[argsTag] = cloneableTags[arrayTag] = | cloneableTags[argsTag] = cloneableTags[arrayTag] = | |
cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = | cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = | |
cloneableTags[dateTag] = cloneableTags[float32Tag] = | cloneableTags[boolTag] = cloneableTags[dateTag] = | |
cloneableTags[float64Tag] = cloneableTags[int8Tag] = | cloneableTags[float32Tag] = cloneableTags[float64Tag] = | |
cloneableTags[int16Tag] = cloneableTags[int32Tag] = | cloneableTags[int8Tag] = cloneableTags[int16Tag] = | |
cloneableTags[mapTag] = cloneableTags[numberTag] = | cloneableTags[int32Tag] = cloneableTags[mapTag] = | |
cloneableTags[objectTag] = cloneableTags[regexpTag] = | cloneableTags[numberTag] = cloneableTags[objectTag] = | |
cloneableTags[setTag] = cloneableTags[stringTag] = | cloneableTags[regexpTag] = cloneableTags[setTag] = | |
cloneableTags[symbolTag] = cloneableTags[uint8Tag] = | cloneableTags[stringTag] = cloneableTags[symbolTag] = | |
cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = | cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = | |
cloneableTags[uint32Tag] = true; | cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; | |
cloneableTags[errorTag] = cloneableTags[funcTag] = | cloneableTags[errorTag] = cloneableTags[funcTag] = | |
cloneableTags[weakMapTag] = false; | cloneableTags[weakMapTag] = false; | |
/** Used to map latin-1 supplementary letters to basic latin letters. */ | /** Used to map Latin Unicode letters to basic Latin letters. */ | |
var deburredLetters = { | var deburredLetters = { | |
// Latin-1 Supplement block. | ||
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A ', | '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A ', | |
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a ', | '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a ', | |
'\xc7': 'C', '\xe7': 'c', | '\xc7': 'C', '\xe7': 'c', | |
'\xd0': 'D', '\xf0': 'd', | '\xd0': 'D', '\xf0': 'd', | |
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', | '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', | |
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', | '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', | |
'\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', | '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', | |
'\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', | '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', | |
'\xd1': 'N', '\xf1': 'n', | '\xd1': 'N', '\xf1': 'n', | |
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O ', | '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O ', | |
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o ', | '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o ', | |
'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', | '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', | |
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', | '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', | |
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y', | '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', | |
'\xc6': 'Ae', '\xe6': 'ae', | '\xc6': 'Ae', '\xe6': 'ae', | |
'\xde': 'Th', '\xfe': 'th', | '\xde': 'Th', '\xfe': 'th', | |
'\xdf': 'ss' | '\xdf': 'ss', | |
// Latin Extended-A block. | ||
'\u0100': 'A', '\u0102': 'A', '\u0104': 'A', | ||
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a', | ||
'\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', | ||
'\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', | ||
'\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', | ||
'\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', | ||
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', | ||
'\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', | ||
'\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', | ||
'\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', | ||
'\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', | ||
'\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', | ||
'\u0134': 'J', '\u0135': 'j', | ||
'\u0136': 'K', '\u0137': 'k', '\u0138': 'k', | ||
'\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', | ||
'\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', | ||
'\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', | ||
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', | ||
'\u014c': 'O', '\u014e': 'O', '\u0150': 'O', | ||
'\u014d': 'o', '\u014f': 'o', '\u0151': 'o', | ||
'\u0154': 'R', '\u0156': 'R', '\u0158': 'R', | ||
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r', | ||
'\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', | ||
'\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', | ||
'\u0162': 'T', '\u0164': 'T', '\u0166': 'T', | ||
'\u0163': 't', '\u0165': 't', '\u0167': 't', | ||
'\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', | ||
'\u0172': 'U', | ||
'\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', | ||
'\u0173': 'u', | ||
'\u0174': 'W', '\u0175': 'w', | ||
'\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', | ||
'\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', | ||
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z', | ||
'\u0132': 'IJ', '\u0133': 'ij', | ||
'\u0152': 'Oe', '\u0153': 'oe', | ||
'\u0149': "'n", '\u017f': 's' | ||
}; | }; | |
/** Used to map characters to HTML entities. */ | /** Used to map characters to HTML entities. */ | |
var htmlEscapes = { | var htmlEscapes = { | |
'&': '&', | '&': '&', | |
'<': '<', | '<': '<', | |
'>': '>', | '>': '>', | |
'"': '"', | '"': '"', | |
"'": ''', | "'": ''' | |
'`': '`' | ||
}; | }; | |
/** Used to map HTML entities to characters. */ | /** Used to map HTML entities to characters. */ | |
var htmlUnescapes = { | var htmlUnescapes = { | |
'&': '&', | '&': '&', | |
'<': '<', | '<': '<', | |
'>': '>', | '>': '>', | |
'"': '"', | '"': '"', | |
''': "'", | ''': "'" | |
'`': '`' | ||
}; | ||
/** Used to determine if values are of the language type `Object`. */ | ||
var objectTypes = { | ||
'function': true, | ||
'object': true | ||
}; | }; | |
/** Used to escape characters for inclusion in compiled string literals. */ | /** Used to escape characters for inclusion in compiled string literals. */ | |
var stringEscapes = { | var stringEscapes = { | |
'\\': '\\', | '\\': '\\', | |
"'": "'", | "'": "'", | |
'\n': 'n', | '\n': 'n', | |
'\r': 'r', | '\r': 'r', | |
'\u2028': 'u2028', | '\u2028': 'u2028', | |
'\u2029': 'u2029' | '\u2029': 'u2029' | |
}; | }; | |
/** Built-in method references without a dependency on `root`. */ | /** Built-in method references without a dependency on `root`. */ | |
var freeParseFloat = parseFloat, | var freeParseFloat = parseFloat, | |
freeParseInt = parseInt; | freeParseInt = parseInt; | |
/** Detect free variable `exports`. */ | ||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType | ||
) ? exports : null; | ||
/** Detect free variable `module`. */ | ||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? | ||
module : null; | ||
/** Detect free variable `global` from Node.js. */ | /** Detect free variable `global` from Node.js. */ | |
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'ob ject' && global); | var freeGlobal = typeof global == 'object' && global && global.Object === Obje ct && global; | |
/** Detect free variable `self`. */ | /** Detect free variable `self`. */ | |
var freeSelf = checkGlobal(objectTypes[typeof self] && self); | var freeSelf = typeof self == 'object' && self && self.Object === Object && se lf; | |
/** Detect free variable `window`. */ | /** Used as a reference to the global object. */ | |
var freeWindow = checkGlobal(objectTypes[typeof window] && window); | var root = freeGlobal || freeSelf || Function('return this')(); | |
/** Detect the popular CommonJS extension `module.exports`. */ | /** Detect free variable `exports`. */ | |
var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeE | var freeExports = typeof exports == 'object' && exports && !exports.nodeType & | |
xports : null; | & exports; | |
/** Detect `this` as the global object. */ | /** Detect free variable `module`. */ | |
var thisGlobal = checkGlobal(objectTypes[typeof this] && this); | var freeModule = freeExports && typeof module == 'object' && module && !module | |
.nodeType && module; | ||
/** | /** Detect the popular CommonJS extension `module.exports`. */ | |
* Used as a reference to the global object. | var moduleExports = freeModule && freeModule.exports === freeExports; | |
* | ||
* The `this` value is used if it's the global object to avoid Greasemonkey's | ||
* restricted `window` object, otherwise the `window` object is used. | ||
*/ | ||
var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) & | ||
& freeWindow) || freeSelf || thisGlobal || Function('return this')(); | ||
/*--------------------------------------------------------------------------*/ | /** Detect free variable `process` from Node.js. */ | |
var freeProcess = moduleExports && freeGlobal.process; | ||
/** | /** Used to access faster Node.js helpers. */ | |
* Adds the key-value `pair` to `map`. | var nodeUtil = (function() { | |
* | try { | |
* @private | // Use `util.types` for Node.js 10+. | |
* @param {Object} map The map to modify. | var types = freeModule && freeModule.require && freeModule.require('util') | |
* @param {Array} pair The key-value pair to add. | .types; | |
* @returns {Object} Returns `map`. | ||
*/ | if (types) { | |
function addMapEntry(map, pair) { | return types; | |
map.set(pair[0], pair[1]); | } | |
return map; | ||
} | // Legacy `process.binding('util')` for Node.js < 10. | |
return freeProcess && freeProcess.binding && freeProcess.binding('util'); | ||
} catch (e) {} | ||
}()); | ||
/* Node.js helper references. */ | ||
var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, | ||
nodeIsDate = nodeUtil && nodeUtil.isDate, | ||
nodeIsMap = nodeUtil && nodeUtil.isMap, | ||
nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, | ||
nodeIsSet = nodeUtil && nodeUtil.isSet, | ||
nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; | ||
/** | /*--------------------------------------------------------------------------*/ | |
* Adds `value` to `set`. | ||
* | ||
* @private | ||
* @param {Object} set The set to modify. | ||
* @param {*} value The value to add. | ||
* @returns {Object} Returns `set`. | ||
*/ | ||
function addSetEntry(set, value) { | ||
set.add(value); | ||
return set; | ||
} | ||
/** | /** | |
* A faster alternative to `Function#apply`, this function invokes `func` | * A faster alternative to `Function#apply`, this function invokes `func` | |
* with the `this` binding of `thisArg` and the arguments of `args`. | * with the `this` binding of `thisArg` and the arguments of `args`. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to invoke. | * @param {Function} func The function to invoke. | |
* @param {*} thisArg The `this` binding of `func`. | * @param {*} thisArg The `this` binding of `func`. | |
* @param {...*} [args] The arguments to invoke `func` with. | * @param {Array} args The arguments to invoke `func` with. | |
* @returns {*} Returns the result of `func`. | * @returns {*} Returns the result of `func`. | |
*/ | */ | |
function apply(func, thisArg, args) { | function apply(func, thisArg, args) { | |
var length = args ? args.length : 0; | switch (args.length) { | |
switch (length) { | ||
case 0: return func.call(thisArg); | case 0: return func.call(thisArg); | |
case 1: return func.call(thisArg, args[0]); | case 1: return func.call(thisArg, args[0]); | |
case 2: return func.call(thisArg, args[0], args[1]); | case 2: return func.call(thisArg, args[0], args[1]); | |
case 3: return func.call(thisArg, args[0], args[1], args[2]); | case 3: return func.call(thisArg, args[0], args[1], args[2]); | |
} | } | |
return func.apply(thisArg, args); | return func.apply(thisArg, args); | |
} | } | |
/** | /** | |
* Creates a new array concatenating `array` with `other`. | * A specialized version of `baseAggregator` for arrays. | |
* | * | |
* @private | * @private | |
* @param {Array} array The first array to concatenate. | * @param {Array} [array] The array to iterate over. | |
* @param {Array} other The second array to concatenate. | * @param {Function} setter The function to set `accumulator` values. | |
* @returns {Array} Returns the new concatenated array. | * @param {Function} iteratee The iteratee to transform keys. | |
* @param {Object} accumulator The initial aggregated object. | ||
* @returns {Function} Returns `accumulator`. | ||
*/ | */ | |
function arrayConcat(array, other) { | function arrayAggregator(array, setter, iteratee, accumulator) { | |
var index = -1, | var index = -1, | |
length = array.length, | length = array == null ? 0 : array.length; | |
othIndex = -1, | ||
othLength = other.length, | ||
result = Array(length + othLength); | ||
while (++index < length) { | while (++index < length) { | |
result[index] = array[index]; | var value = array[index]; | |
} | setter(accumulator, value, iteratee(value), array); | |
while (++othIndex < othLength) { | ||
result[index++] = other[othIndex]; | ||
} | } | |
return result; | return accumulator; | |
} | } | |
/** | /** | |
* A specialized version of `_.forEach` for arrays without support for | * A specialized version of `_.forEach` for arrays without support for | |
* iteratee shorthands. | * iteratee shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array} Returns `array`. | * @returns {Array} Returns `array`. | |
*/ | */ | |
function arrayEach(array, iteratee) { | function arrayEach(array, iteratee) { | |
var index = -1, | var index = -1, | |
length = array.length; | length = array == null ? 0 : array.length; | |
while (++index < length) { | while (++index < length) { | |
if (iteratee(array[index], index, array) === false) { | if (iteratee(array[index], index, array) === false) { | |
break; | break; | |
} | } | |
} | } | |
return array; | return array; | |
} | } | |
/** | /** | |
* A specialized version of `_.forEachRight` for arrays without support for | * A specialized version of `_.forEachRight` for arrays without support for | |
* iteratee shorthands. | * iteratee shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array} Returns `array`. | * @returns {Array} Returns `array`. | |
*/ | */ | |
function arrayEachRight(array, iteratee) { | function arrayEachRight(array, iteratee) { | |
var length = array.length; | var length = array == null ? 0 : array.length; | |
while (length--) { | while (length--) { | |
if (iteratee(array[length], length, array) === false) { | if (iteratee(array[length], length, array) === false) { | |
break; | break; | |
} | } | |
} | } | |
return array; | return array; | |
} | } | |
/** | /** | |
* A specialized version of `_.every` for arrays without support for | * A specialized version of `_.every` for arrays without support for | |
* iteratee shorthands. | * iteratee shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {Array} [array] The array to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | * @param {Function} predicate The function invoked per iteration. | |
* @returns {boolean} Returns `true` if all elements pass the predicate check, | * @returns {boolean} Returns `true` if all elements pass the predicate check, | |
else `false`. | * else `false`. | |
*/ | */ | |
function arrayEvery(array, predicate) { | function arrayEvery(array, predicate) { | |
var index = -1, | var index = -1, | |
length = array.length; | length = array == null ? 0 : array.length; | |
while (++index < length) { | while (++index < length) { | |
if (!predicate(array[index], index, array)) { | if (!predicate(array[index], index, array)) { | |
return false; | return false; | |
} | } | |
} | } | |
return true; | return true; | |
} | } | |
/** | /** | |
* A specialized version of `_.filter` for arrays without support for | * A specialized version of `_.filter` for arrays without support for | |
* iteratee shorthands. | * iteratee shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {Array} [array] The array to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | * @param {Function} predicate The function invoked per iteration. | |
* @returns {Array} Returns the new filtered array. | * @returns {Array} Returns the new filtered array. | |
*/ | */ | |
function arrayFilter(array, predicate) { | function arrayFilter(array, predicate) { | |
var index = -1, | var index = -1, | |
length = array.length, | length = array == null ? 0 : array.length, | |
resIndex = -1, | resIndex = 0, | |
result = []; | result = []; | |
while (++index < length) { | while (++index < length) { | |
var value = array[index]; | var value = array[index]; | |
if (predicate(value, index, array)) { | if (predicate(value, index, array)) { | |
result[++resIndex] = value; | result[resIndex++] = value; | |
} | } | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* A specialized version of `_.includes` for arrays without support for | * A specialized version of `_.includes` for arrays without support for | |
* specifying an index to search from. | * specifying an index to search from. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to search. | * @param {Array} [array] The array to inspect. | |
* @param {*} target The value to search for. | * @param {*} target The value to search for. | |
* @returns {boolean} Returns `true` if `target` is found, else `false`. | * @returns {boolean} Returns `true` if `target` is found, else `false`. | |
*/ | */ | |
function arrayIncludes(array, value) { | function arrayIncludes(array, value) { | |
return !!array.length && baseIndexOf(array, value, 0) > -1; | var length = array == null ? 0 : array.length; | |
return !!length && baseIndexOf(array, value, 0) > -1; | ||
} | } | |
/** | /** | |
* A specialized version of `_.includesWith` for arrays without support for | * This function is like `arrayIncludes` except that it accepts a comparator. | |
* specifying an index to search from. | ||
* | * | |
* @private | * @private | |
* @param {Array} array The array to search. | * @param {Array} [array] The array to inspect. | |
* @param {*} target The value to search for. | * @param {*} target The value to search for. | |
* @param {Function} comparator The comparator invoked per element. | * @param {Function} comparator The comparator invoked per element. | |
* @returns {boolean} Returns `true` if `target` is found, else `false`. | * @returns {boolean} Returns `true` if `target` is found, else `false`. | |
*/ | */ | |
function arrayIncludesWith(array, value, comparator) { | function arrayIncludesWith(array, value, comparator) { | |
var index = -1, | var index = -1, | |
length = array.length; | length = array == null ? 0 : array.length; | |
while (++index < length) { | while (++index < length) { | |
if (comparator(value, array[index])) { | if (comparator(value, array[index])) { | |
return true; | return true; | |
} | } | |
} | } | |
return false; | return false; | |
} | } | |
/** | /** | |
* A specialized version of `_.map` for arrays without support for iteratee | * A specialized version of `_.map` for arrays without support for iteratee | |
* shorthands. | * shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array} Returns the new mapped array. | * @returns {Array} Returns the new mapped array. | |
*/ | */ | |
function arrayMap(array, iteratee) { | function arrayMap(array, iteratee) { | |
var index = -1, | var index = -1, | |
length = array.length, | length = array == null ? 0 : array.length, | |
result = Array(length); | result = Array(length); | |
while (++index < length) { | while (++index < length) { | |
result[index] = iteratee(array[index], index, array); | result[index] = iteratee(array[index], index, array); | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* Appends the elements of `values` to `array`. | * Appends the elements of `values` to `array`. | |
skipping to change at line 597 | skipping to change at line 682 | |
array[offset + index] = values[index]; | array[offset + index] = values[index]; | |
} | } | |
return array; | return array; | |
} | } | |
/** | /** | |
* A specialized version of `_.reduce` for arrays without support for | * A specialized version of `_.reduce` for arrays without support for | |
* iteratee shorthands. | * iteratee shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @param {*} [accumulator] The initial value. | * @param {*} [accumulator] The initial value. | |
* @param {boolean} [initFromArray] Specify using the first element of `array` | * @param {boolean} [initAccum] Specify using the first element of `array` as | |
as the initial value. | * the initial value. | |
* @returns {*} Returns the accumulated value. | * @returns {*} Returns the accumulated value. | |
*/ | */ | |
function arrayReduce(array, iteratee, accumulator, initFromArray) { | function arrayReduce(array, iteratee, accumulator, initAccum) { | |
var index = -1, | var index = -1, | |
length = array.length; | length = array == null ? 0 : array.length; | |
if (initFromArray && length) { | if (initAccum && length) { | |
accumulator = array[++index]; | accumulator = array[++index]; | |
} | } | |
while (++index < length) { | while (++index < length) { | |
accumulator = iteratee(accumulator, array[index], index, array); | accumulator = iteratee(accumulator, array[index], index, array); | |
} | } | |
return accumulator; | return accumulator; | |
} | } | |
/** | /** | |
* A specialized version of `_.reduceRight` for arrays without support for | * A specialized version of `_.reduceRight` for arrays without support for | |
* iteratee shorthands. | * iteratee shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @param {*} [accumulator] The initial value. | * @param {*} [accumulator] The initial value. | |
* @param {boolean} [initFromArray] Specify using the last element of `array` | * @param {boolean} [initAccum] Specify using the last element of `array` as | |
as the initial value. | * the initial value. | |
* @returns {*} Returns the accumulated value. | * @returns {*} Returns the accumulated value. | |
*/ | */ | |
function arrayReduceRight(array, iteratee, accumulator, initFromArray) { | function arrayReduceRight(array, iteratee, accumulator, initAccum) { | |
var length = array.length; | var length = array == null ? 0 : array.length; | |
if (initFromArray && length) { | if (initAccum && length) { | |
accumulator = array[--length]; | accumulator = array[--length]; | |
} | } | |
while (length--) { | while (length--) { | |
accumulator = iteratee(accumulator, array[length], length, array); | accumulator = iteratee(accumulator, array[length], length, array); | |
} | } | |
return accumulator; | return accumulator; | |
} | } | |
/** | /** | |
* A specialized version of `_.some` for arrays without support for iteratee | * A specialized version of `_.some` for arrays without support for iteratee | |
* shorthands. | * shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {Array} [array] The array to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | * @param {Function} predicate The function invoked per iteration. | |
* @returns {boolean} Returns `true` if any element passes the predicate check | * @returns {boolean} Returns `true` if any element passes the predicate check | |
, else `false`. | , | |
* else `false`. | ||
*/ | */ | |
function arraySome(array, predicate) { | function arraySome(array, predicate) { | |
var index = -1, | var index = -1, | |
length = array.length; | length = array == null ? 0 : array.length; | |
while (++index < length) { | while (++index < length) { | |
if (predicate(array[index], index, array)) { | if (predicate(array[index], index, array)) { | |
return true; | return true; | |
} | } | |
} | } | |
return false; | return false; | |
} | } | |
/** | /** | |
* The base implementation of methods like `_.max` and `_.min` which accepts a | * Gets the size of an ASCII `string`. | |
* `comparator` to determine the extremum value. | ||
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {string} string The string inspect. | |
* @param {Function} iteratee The iteratee invoked per iteration. | * @returns {number} Returns the string size. | |
* @param {Function} comparator The comparator used to compare values. | ||
* @returns {*} Returns the extremum value. | ||
*/ | */ | |
function baseExtremum(array, iteratee, comparator) { | var asciiSize = baseProperty('length'); | |
var index = -1, | ||
length = array.length; | ||
while (++index < length) { | /** | |
var value = array[index], | * Converts an ASCII `string` to an array. | |
current = iteratee(value); | * | |
* @private | ||
* @param {string} string The string to convert. | ||
* @returns {Array} Returns the converted array. | ||
*/ | ||
function asciiToArray(string) { | ||
return string.split(''); | ||
} | ||
if (current != null && (computed === undefined | /** | |
? current === current | * Splits an ASCII `string` into an array of its words. | |
: comparator(current, computed) | * | |
)) { | * @private | |
var computed = current, | * @param {string} The string to inspect. | |
result = value; | * @returns {Array} Returns the words of `string`. | |
} | */ | |
} | function asciiWords(string) { | |
return result; | return string.match(reAsciiWord) || []; | |
} | } | |
/** | /** | |
* The base implementation of methods like `_.find` and `_.findKey`, without | * The base implementation of methods like `_.findKey` and `_.findLastKey`, | |
* support for iteratee shorthands, which iterates over `collection` using | * without support for iteratee shorthands, which iterates over `collection` | |
* the provided `eachFunc`. | * using `eachFunc`. | |
* | * | |
* @private | * @private | |
* @param {Array|Object} collection The collection to search. | * @param {Array|Object} collection The collection to inspect. | |
* @param {Function} predicate The function invoked per iteration. | * @param {Function} predicate The function invoked per iteration. | |
* @param {Function} eachFunc The function to iterate over `collection`. | * @param {Function} eachFunc The function to iterate over `collection`. | |
* @param {boolean} [retKey] Specify returning the key of the found element in stead of the element itself. | ||
* @returns {*} Returns the found element or its key, else `undefined`. | * @returns {*} Returns the found element or its key, else `undefined`. | |
*/ | */ | |
function baseFind(collection, predicate, eachFunc, retKey) { | function baseFindKey(collection, predicate, eachFunc) { | |
var result; | var result; | |
eachFunc(collection, function(value, key, collection) { | eachFunc(collection, function(value, key, collection) { | |
if (predicate(value, key, collection)) { | if (predicate(value, key, collection)) { | |
result = retKey ? key : value; | result = key; | |
return false; | return false; | |
} | } | |
}); | }); | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.findIndex` and `_.findLastIndex` without | * The base implementation of `_.findIndex` and `_.findLastIndex` without | |
* support for iteratee shorthands. | * support for iteratee shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to search. | * @param {Array} array The array to inspect. | |
* @param {Function} predicate The function invoked per iteration. | * @param {Function} predicate The function invoked per iteration. | |
* @param {number} fromIndex The index to search from. | ||
* @param {boolean} [fromRight] Specify iterating from right to left. | * @param {boolean} [fromRight] Specify iterating from right to left. | |
* @returns {number} Returns the index of the matched value, else `-1`. | * @returns {number} Returns the index of the matched value, else `-1`. | |
*/ | */ | |
function baseFindIndex(array, predicate, fromRight) { | function baseFindIndex(array, predicate, fromIndex, fromRight) { | |
var length = array.length, | var length = array.length, | |
index = fromRight ? length : -1; | index = fromIndex + (fromRight ? 1 : -1); | |
while ((fromRight ? index-- : ++index < length)) { | while ((fromRight ? index-- : ++index < length)) { | |
if (predicate(array[index], index, array)) { | if (predicate(array[index], index, array)) { | |
return index; | return index; | |
} | } | |
} | } | |
return -1; | return -1; | |
} | } | |
/** | /** | |
* The base implementation of `_.indexOf` without `fromIndex` bounds checks. | * The base implementation of `_.indexOf` without `fromIndex` bounds checks. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to search. | * @param {Array} array The array to inspect. | |
* @param {*} value The value to search for. | * @param {*} value The value to search for. | |
* @param {number} fromIndex The index to search from. | * @param {number} fromIndex The index to search from. | |
* @returns {number} Returns the index of the matched value, else `-1`. | * @returns {number} Returns the index of the matched value, else `-1`. | |
*/ | */ | |
function baseIndexOf(array, value, fromIndex) { | function baseIndexOf(array, value, fromIndex) { | |
if (value !== value) { | return value === value | |
return indexOfNaN(array, fromIndex); | ? strictIndexOf(array, value, fromIndex) | |
} | : baseFindIndex(array, baseIsNaN, fromIndex); | |
} | ||
/** | ||
* This function is like `baseIndexOf` except that it accepts a comparator. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {*} value The value to search for. | ||
* @param {number} fromIndex The index to search from. | ||
* @param {Function} comparator The comparator invoked per element. | ||
* @returns {number} Returns the index of the matched value, else `-1`. | ||
*/ | ||
function baseIndexOfWith(array, value, fromIndex, comparator) { | ||
var index = fromIndex - 1, | var index = fromIndex - 1, | |
length = array.length; | length = array.length; | |
while (++index < length) { | while (++index < length) { | |
if (array[index] === value) { | if (comparator(array[index], value)) { | |
return index; | return index; | |
} | } | |
} | } | |
return -1; | return -1; | |
} | } | |
/** | /** | |
* The base implementation of `_.isNaN` without support for number objects. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. | ||
*/ | ||
function baseIsNaN(value) { | ||
return value !== value; | ||
} | ||
/** | ||
* The base implementation of `_.mean` and `_.meanBy` without support for | ||
* iteratee shorthands. | ||
* | ||
* @private | ||
* @param {Array} array The array to iterate over. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {number} Returns the mean. | ||
*/ | ||
function baseMean(array, iteratee) { | ||
var length = array == null ? 0 : array.length; | ||
return length ? (baseSum(array, iteratee) / length) : NAN; | ||
} | ||
/** | ||
* The base implementation of `_.property` without support for deep paths. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @returns {Function} Returns the new accessor function. | ||
*/ | ||
function baseProperty(key) { | ||
return function(object) { | ||
return object == null ? undefined : object[key]; | ||
}; | ||
} | ||
/** | ||
* The base implementation of `_.propertyOf` without support for deep paths. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Function} Returns the new accessor function. | ||
*/ | ||
function basePropertyOf(object) { | ||
return function(key) { | ||
return object == null ? undefined : object[key]; | ||
}; | ||
} | ||
/** | ||
* The base implementation of `_.reduce` and `_.reduceRight`, without support | * The base implementation of `_.reduce` and `_.reduceRight`, without support | |
* for iteratee shorthands, which iterates over `collection` using the provide | * for iteratee shorthands, which iterates over `collection` using `eachFunc`. | |
d | ||
* `eachFunc`. | ||
* | * | |
* @private | * @private | |
* @param {Array|Object} collection The collection to iterate over. | * @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @param {*} accumulator The initial value. | * @param {*} accumulator The initial value. | |
* @param {boolean} initFromCollection Specify using the first or last element | * @param {boolean} initAccum Specify using the first or last element of | |
of `collection` as the initial value. | * `collection` as the initial value. | |
* @param {Function} eachFunc The function to iterate over `collection`. | * @param {Function} eachFunc The function to iterate over `collection`. | |
* @returns {*} Returns the accumulated value. | * @returns {*} Returns the accumulated value. | |
*/ | */ | |
function baseReduce(collection, iteratee, accumulator, initFromCollection, eac hFunc) { | function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { | |
eachFunc(collection, function(value, index, collection) { | eachFunc(collection, function(value, index, collection) { | |
accumulator = initFromCollection | accumulator = initAccum | |
? (initFromCollection = false, value) | ? (initAccum = false, value) | |
: iteratee(accumulator, value, index, collection); | : iteratee(accumulator, value, index, collection); | |
}); | }); | |
return accumulator; | return accumulator; | |
} | } | |
/** | /** | |
* The base implementation of `_.sortBy` which uses `comparer` to define | * The base implementation of `_.sortBy` which uses `comparer` to define the | |
* the sort order of `array` and replaces criteria objects with their | * sort order of `array` and replaces criteria objects with their correspondin | |
* corresponding values. | g | |
* values. | ||
* | * | |
* @private | * @private | |
* @param {Array} array The array to sort. | * @param {Array} array The array to sort. | |
* @param {Function} comparer The function to define sort order. | * @param {Function} comparer The function to define sort order. | |
* @returns {Array} Returns `array`. | * @returns {Array} Returns `array`. | |
*/ | */ | |
function baseSortBy(array, comparer) { | function baseSortBy(array, comparer) { | |
var length = array.length; | var length = array.length; | |
array.sort(comparer); | array.sort(comparer); | |
while (length--) { | while (length--) { | |
array[length] = array[length].value; | array[length] = array[length].value; | |
} | } | |
return array; | return array; | |
} | } | |
/** | /** | |
* The base implementation of `_.sum` without support for iteratee shorthands. | * The base implementation of `_.sum` and `_.sumBy` without support for | |
* iteratee shorthands. | ||
* | * | |
* @private | * @private | |
* @param {Array} array The array to iterate over. | * @param {Array} array The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @returns {number} Returns the sum. | * @returns {number} Returns the sum. | |
*/ | */ | |
function baseSum(array, iteratee) { | function baseSum(array, iteratee) { | |
var result, | var result, | |
index = -1, | index = -1, | |
length = array.length; | length = array.length; | |
skipping to change at line 847 | skipping to change at line 1002 | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.toPairs` and `_.toPairsIn` which creates an a rray | * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an a rray | |
* of key-value pairs for `object` corresponding to the property names of `pro ps`. | * of key-value pairs for `object` corresponding to the property names of `pro ps`. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @param {Array} props The property names to get values for. | * @param {Array} props The property names to get values for. | |
* @returns {Object} Returns the new array of key-value pairs. | * @returns {Object} Returns the key-value pairs. | |
*/ | */ | |
function baseToPairs(object, props) { | function baseToPairs(object, props) { | |
return arrayMap(props, function(key) { | return arrayMap(props, function(key) { | |
return [key, object[key]]; | return [key, object[key]]; | |
}); | }); | |
} | } | |
/** | /** | |
* The base implementation of `_.unary` without support for storing wrapper me | * The base implementation of `_.trim`. | |
tadata. | * | |
* @private | ||
* @param {string} string The string to trim. | ||
* @returns {string} Returns the trimmed string. | ||
*/ | ||
function baseTrim(string) { | ||
return string | ||
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') | ||
: string; | ||
} | ||
/** | ||
* The base implementation of `_.unary` without support for storing metadata. | ||
* | * | |
* @private | * @private | |
* @param {Function} func The function to cap arguments for. | * @param {Function} func The function to cap arguments for. | |
* @returns {Function} Returns the new function. | * @returns {Function} Returns the new capped function. | |
*/ | */ | |
function baseUnary(func) { | function baseUnary(func) { | |
return function(value) { | return function(value) { | |
return func(value); | return func(value); | |
}; | }; | |
} | } | |
/** | /** | |
* The base implementation of `_.values` and `_.valuesIn` which creates an | * The base implementation of `_.values` and `_.valuesIn` which creates an | |
* array of `object` property values corresponding to the property names | * array of `object` property values corresponding to the property names | |
skipping to change at line 885 | skipping to change at line 1053 | |
* @param {Array} props The property names to get values for. | * @param {Array} props The property names to get values for. | |
* @returns {Object} Returns the array of property values. | * @returns {Object} Returns the array of property values. | |
*/ | */ | |
function baseValues(object, props) { | function baseValues(object, props) { | |
return arrayMap(props, function(key) { | return arrayMap(props, function(key) { | |
return object[key]; | return object[key]; | |
}); | }); | |
} | } | |
/** | /** | |
* Checks if a `cache` value for `key` exists. | ||
* | ||
* @private | ||
* @param {Object} cache The cache to query. | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false | ||
`. | ||
*/ | ||
function cacheHas(cache, key) { | ||
return cache.has(key); | ||
} | ||
/** | ||
* Used by `_.trim` and `_.trimStart` to get the index of the first string sym bol | * Used by `_.trim` and `_.trimStart` to get the index of the first string sym bol | |
* that is not found in the character symbols. | * that is not found in the character symbols. | |
* | * | |
* @private | * @private | |
* @param {Array} strSymbols The string symbols to inspect. | * @param {Array} strSymbols The string symbols to inspect. | |
* @param {Array} chrSymbols The character symbols to find. | * @param {Array} chrSymbols The character symbols to find. | |
* @returns {number} Returns the index of the first unmatched string symbol. | * @returns {number} Returns the index of the first unmatched string symbol. | |
*/ | */ | |
function charsStartIndex(strSymbols, chrSymbols) { | function charsStartIndex(strSymbols, chrSymbols) { | |
var index = -1, | var index = -1, | |
skipping to change at line 918 | skipping to change at line 1098 | |
* @returns {number} Returns the index of the last unmatched string symbol. | * @returns {number} Returns the index of the last unmatched string symbol. | |
*/ | */ | |
function charsEndIndex(strSymbols, chrSymbols) { | function charsEndIndex(strSymbols, chrSymbols) { | |
var index = strSymbols.length; | var index = strSymbols.length; | |
while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} | while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} | |
return index; | return index; | |
} | } | |
/** | /** | |
* Checks if `value` is a global object. | * Gets the number of `placeholder` occurrences in `array`. | |
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {null|Object} Returns `value` if it's a global object, else `null` | ||
. | ||
*/ | ||
function checkGlobal(value) { | ||
return (value && value.Object === Object) ? value : null; | ||
} | ||
/** | ||
* Compares values to sort them in ascending order. | ||
* | ||
* @private | ||
* @param {*} value The value to compare. | ||
* @param {*} other The other value to compare. | ||
* @returns {number} Returns the sort order indicator for `value`. | ||
*/ | ||
function compareAscending(value, other) { | ||
if (value !== other) { | ||
var valIsNull = value === null, | ||
valIsUndef = value === undefined, | ||
valIsReflexive = value === value; | ||
var othIsNull = other === null, | ||
othIsUndef = other === undefined, | ||
othIsReflexive = other === other; | ||
if ((value > other && !othIsNull) || !valIsReflexive || | ||
(valIsNull && !othIsUndef && othIsReflexive) || | ||
(valIsUndef && othIsReflexive)) { | ||
return 1; | ||
} | ||
if ((value < other && !valIsNull) || !othIsReflexive || | ||
(othIsNull && !valIsUndef && valIsReflexive) || | ||
(othIsUndef && valIsReflexive)) { | ||
return -1; | ||
} | ||
} | ||
return 0; | ||
} | ||
/** | ||
* Used by `_.orderBy` to compare multiple properties of a value to another | ||
* and stable sort them. | ||
* | ||
* If `orders` is unspecified, all values are sorted in ascending order. Other | ||
wise, | ||
* specify an order of "desc" for descending or "asc" for ascending sort order | ||
* of corresponding values. | ||
* | * | |
* @private | * @private | |
* @param {Object} object The object to compare. | * @param {Array} array The array to inspect. | |
* @param {Object} other The other object to compare. | * @param {*} placeholder The placeholder to search for. | |
* @param {boolean[]|string[]} orders The order to sort by for each property. | * @returns {number} Returns the placeholder count. | |
* @returns {number} Returns the sort order indicator for `object`. | ||
*/ | */ | |
function compareMultiple(object, other, orders) { | function countHolders(array, placeholder) { | |
var index = -1, | var length = array.length, | |
objCriteria = object.criteria, | result = 0; | |
othCriteria = other.criteria, | ||
length = objCriteria.length, | ||
ordersLength = orders.length; | ||
while (++index < length) { | while (length--) { | |
var result = compareAscending(objCriteria[index], othCriteria[index]); | if (array[length] === placeholder) { | |
if (result) { | ++result; | |
if (index >= ordersLength) { | ||
return result; | ||
} | ||
var order = orders[index]; | ||
return result * (order == 'desc' ? -1 : 1); | ||
} | } | |
} | } | |
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications | return result; | |
// that causes it, under certain circumstances, to provide the same value fo | ||
r | ||
// `object` and `other`. See https://github.com/jashkenas/underscore/pull/12 | ||
47 | ||
// for more details. | ||
// | ||
// This also ensures a stable sort in V8 and other engines. | ||
// See https://code.google.com/p/v8/issues/detail?id=90 for more details. | ||
return object.index - other.index; | ||
} | } | |
/** | /** | |
* Used by `_.deburr` to convert latin-1 supplementary letters to basic latin | * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A | |
letters. | * letters to basic Latin letters. | |
* | * | |
* @private | * @private | |
* @param {string} letter The matched letter to deburr. | * @param {string} letter The matched letter to deburr. | |
* @returns {string} Returns the deburred letter. | * @returns {string} Returns the deburred letter. | |
*/ | */ | |
function deburrLetter(letter) { | var deburrLetter = basePropertyOf(deburredLetters); | |
return deburredLetters[letter]; | ||
} | ||
/** | /** | |
* Used by `_.escape` to convert characters to HTML entities. | * Used by `_.escape` to convert characters to HTML entities. | |
* | * | |
* @private | * @private | |
* @param {string} chr The matched character to escape. | * @param {string} chr The matched character to escape. | |
* @returns {string} Returns the escaped character. | * @returns {string} Returns the escaped character. | |
*/ | */ | |
function escapeHtmlChar(chr) { | var escapeHtmlChar = basePropertyOf(htmlEscapes); | |
return htmlEscapes[chr]; | ||
} | ||
/** | /** | |
* Used by `_.template` to escape characters for inclusion in compiled string literals. | * Used by `_.template` to escape characters for inclusion in compiled string literals. | |
* | * | |
* @private | * @private | |
* @param {string} chr The matched character to escape. | * @param {string} chr The matched character to escape. | |
* @returns {string} Returns the escaped character. | * @returns {string} Returns the escaped character. | |
*/ | */ | |
function escapeStringChar(chr) { | function escapeStringChar(chr) { | |
return '\\' + stringEscapes[chr]; | return '\\' + stringEscapes[chr]; | |
} | } | |
/** | /** | |
* Gets the index at which the first occurrence of `NaN` is found in `array`. | * Gets the value at `key` of `object`. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to search. | * @param {Object} [object] The object to query. | |
* @param {number} fromIndex The index to search from. | * @param {string} key The key of the property to get. | |
* @param {boolean} [fromRight] Specify iterating from right to left. | * @returns {*} Returns the property value. | |
* @returns {number} Returns the index of the matched `NaN`, else `-1`. | ||
*/ | */ | |
function indexOfNaN(array, fromIndex, fromRight) { | function getValue(object, key) { | |
var length = array.length, | return object == null ? undefined : object[key]; | |
index = fromIndex + (fromRight ? 0 : -1); | ||
while ((fromRight ? index-- : ++index < length)) { | ||
var other = array[index]; | ||
if (other !== other) { | ||
return index; | ||
} | ||
} | ||
return -1; | ||
} | } | |
/** | /** | |
* Checks if `value` is a host object in IE < 9. | * Checks if `string` contains Unicode symbols. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to check. | * @param {string} string The string to inspect. | |
* @returns {boolean} Returns `true` if `value` is a host object, else `false` | * @returns {boolean} Returns `true` if a symbol is found, else `false`. | |
. | ||
*/ | */ | |
function isHostObject(value) { | function hasUnicode(string) { | |
// Many host objects are `Object` objects that can coerce to strings | return reHasUnicode.test(string); | |
// despite having improperly defined `toString` methods. | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
try { | ||
result = !!(value + ''); | ||
} catch (e) {} | ||
} | ||
return result; | ||
} | } | |
/** | /** | |
* Checks if `value` is a valid array-like index. | * Checks if `string` contains a word composed of Unicode symbols. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to check. | * @param {string} string The string to inspect. | |
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index | * @returns {boolean} Returns `true` if a word is found, else `false`. | |
. | ||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false` | ||
. | ||
*/ | */ | |
function isIndex(value, length) { | function hasUnicodeWord(string) { | |
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; | return reHasUnicodeWord.test(string); | |
length = length == null ? MAX_SAFE_INTEGER : length; | ||
return value > -1 && value % 1 == 0 && value < length; | ||
} | } | |
/** | /** | |
* Converts `iterator` to an array. | * Converts `iterator` to an array. | |
* | * | |
* @private | * @private | |
* @param {Object} iterator The iterator to convert. | * @param {Object} iterator The iterator to convert. | |
* @returns {Array} Returns the converted array. | * @returns {Array} Returns the converted array. | |
*/ | */ | |
function iteratorToArray(iterator) { | function iteratorToArray(iterator) { | |
var data, | var data, | |
result = []; | result = []; | |
while (!(data = iterator.next()).done) { | while (!(data = iterator.next()).done) { | |
result.push(data.value); | result.push(data.value); | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* Converts `map` to an array. | * Converts `map` to its key-value pairs. | |
* | * | |
* @private | * @private | |
* @param {Object} map The map to convert. | * @param {Object} map The map to convert. | |
* @returns {Array} Returns the converted array. | * @returns {Array} Returns the key-value pairs. | |
*/ | */ | |
function mapToArray(map) { | function mapToArray(map) { | |
var index = -1, | var index = -1, | |
result = Array(map.size); | result = Array(map.size); | |
map.forEach(function(value, key) { | map.forEach(function(value, key) { | |
result[++index] = [key, value]; | result[++index] = [key, value]; | |
}); | }); | |
return result; | return result; | |
} | } | |
/** | /** | |
* Creates a unary function that invokes `func` with its argument transformed. | ||
* | ||
* @private | ||
* @param {Function} func The function to wrap. | ||
* @param {Function} transform The argument transform. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function overArg(func, transform) { | ||
return function(arg) { | ||
return func(transform(arg)); | ||
}; | ||
} | ||
/** | ||
* Replaces all `placeholder` elements in `array` with an internal placeholder | * Replaces all `placeholder` elements in `array` with an internal placeholder | |
* and returns an array of their indexes. | * and returns an array of their indexes. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to modify. | * @param {Array} array The array to modify. | |
* @param {*} placeholder The placeholder to replace. | * @param {*} placeholder The placeholder to replace. | |
* @returns {Array} Returns the new array of placeholder indexes. | * @returns {Array} Returns the new array of placeholder indexes. | |
*/ | */ | |
function replaceHolders(array, placeholder) { | function replaceHolders(array, placeholder) { | |
var index = -1, | var index = -1, | |
length = array.length, | length = array.length, | |
resIndex = -1, | resIndex = 0, | |
result = []; | result = []; | |
while (++index < length) { | while (++index < length) { | |
if (array[index] === placeholder) { | var value = array[index]; | |
if (value === placeholder || value === PLACEHOLDER) { | ||
array[index] = PLACEHOLDER; | array[index] = PLACEHOLDER; | |
result[++resIndex] = index; | result[resIndex++] = index; | |
} | } | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* Converts `set` to an array. | * Converts `set` to an array of its values. | |
* | * | |
* @private | * @private | |
* @param {Object} set The set to convert. | * @param {Object} set The set to convert. | |
* @returns {Array} Returns the converted array. | * @returns {Array} Returns the values. | |
*/ | */ | |
function setToArray(set) { | function setToArray(set) { | |
var index = -1, | var index = -1, | |
result = Array(set.size); | result = Array(set.size); | |
set.forEach(function(value) { | set.forEach(function(value) { | |
result[++index] = value; | result[++index] = value; | |
}); | }); | |
return result; | return result; | |
} | } | |
/** | /** | |
* Converts `set` to its value-value pairs. | ||
* | ||
* @private | ||
* @param {Object} set The set to convert. | ||
* @returns {Array} Returns the value-value pairs. | ||
*/ | ||
function setToPairs(set) { | ||
var index = -1, | ||
result = Array(set.size); | ||
set.forEach(function(value) { | ||
result[++index] = [value, value]; | ||
}); | ||
return result; | ||
} | ||
/** | ||
* A specialized version of `_.indexOf` which performs strict equality | ||
* comparisons of values, i.e. `===`. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {*} value The value to search for. | ||
* @param {number} fromIndex The index to search from. | ||
* @returns {number} Returns the index of the matched value, else `-1`. | ||
*/ | ||
function strictIndexOf(array, value, fromIndex) { | ||
var index = fromIndex - 1, | ||
length = array.length; | ||
while (++index < length) { | ||
if (array[index] === value) { | ||
return index; | ||
} | ||
} | ||
return -1; | ||
} | ||
/** | ||
* A specialized version of `_.lastIndexOf` which performs strict equality | ||
* comparisons of values, i.e. `===`. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {*} value The value to search for. | ||
* @param {number} fromIndex The index to search from. | ||
* @returns {number} Returns the index of the matched value, else `-1`. | ||
*/ | ||
function strictLastIndexOf(array, value, fromIndex) { | ||
var index = fromIndex + 1; | ||
while (index--) { | ||
if (array[index] === value) { | ||
return index; | ||
} | ||
} | ||
return index; | ||
} | ||
/** | ||
* Gets the number of symbols in `string`. | * Gets the number of symbols in `string`. | |
* | * | |
* @private | ||
* @param {string} string The string to inspect. | * @param {string} string The string to inspect. | |
* @returns {number} Returns the string size. | * @returns {number} Returns the string size. | |
*/ | */ | |
function stringSize(string) { | function stringSize(string) { | |
if (!(string && reHasComplexSymbol.test(string))) { | return hasUnicode(string) | |
return string.length; | ? unicodeSize(string) | |
} | : asciiSize(string); | |
var result = reComplexSymbol.lastIndex = 0; | ||
while (reComplexSymbol.test(string)) { | ||
result++; | ||
} | ||
return result; | ||
} | } | |
/** | /** | |
* Converts `string` to an array. | * Converts `string` to an array. | |
* | * | |
* @private | * @private | |
* @param {string} string The string to convert. | * @param {string} string The string to convert. | |
* @returns {Array} Returns the converted array. | * @returns {Array} Returns the converted array. | |
*/ | */ | |
function stringToArray(string) { | function stringToArray(string) { | |
return string.match(reComplexSymbol); | return hasUnicode(string) | |
? unicodeToArray(string) | ||
: asciiToArray(string); | ||
} | ||
/** | ||
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespac | ||
e | ||
* character of `string`. | ||
* | ||
* @private | ||
* @param {string} string The string to inspect. | ||
* @returns {number} Returns the index of the last non-whitespace character. | ||
*/ | ||
function trimmedEndIndex(string) { | ||
var index = string.length; | ||
while (index-- && reWhitespace.test(string.charAt(index))) {} | ||
return index; | ||
} | } | |
/** | /** | |
* Used by `_.unescape` to convert HTML entities to characters. | * Used by `_.unescape` to convert HTML entities to characters. | |
* | * | |
* @private | * @private | |
* @param {string} chr The matched character to unescape. | * @param {string} chr The matched character to unescape. | |
* @returns {string} Returns the unescaped character. | * @returns {string} Returns the unescaped character. | |
*/ | */ | |
function unescapeHtmlChar(chr) { | var unescapeHtmlChar = basePropertyOf(htmlUnescapes); | |
return htmlUnescapes[chr]; | ||
/** | ||
* Gets the size of a Unicode `string`. | ||
* | ||
* @private | ||
* @param {string} string The string inspect. | ||
* @returns {number} Returns the string size. | ||
*/ | ||
function unicodeSize(string) { | ||
var result = reUnicode.lastIndex = 0; | ||
while (reUnicode.test(string)) { | ||
++result; | ||
} | ||
return result; | ||
} | ||
/** | ||
* Converts a Unicode `string` to an array. | ||
* | ||
* @private | ||
* @param {string} string The string to convert. | ||
* @returns {Array} Returns the converted array. | ||
*/ | ||
function unicodeToArray(string) { | ||
return string.match(reUnicode) || []; | ||
} | ||
/** | ||
* Splits a Unicode `string` into an array of its words. | ||
* | ||
* @private | ||
* @param {string} The string to inspect. | ||
* @returns {Array} Returns the words of `string`. | ||
*/ | ||
function unicodeWords(string) { | ||
return string.match(reUnicodeWord) || []; | ||
} | } | |
/*--------------------------------------------------------------------------*/ | /*--------------------------------------------------------------------------*/ | |
/** | /** | |
* Create a new pristine `lodash` function using the `context` object. | * Create a new pristine `lodash` function using the `context` object. | |
* | * | |
* @static | * @static | |
* @memberOf _ | * @memberOf _ | |
* @since 1.1.0 | ||
* @category Util | * @category Util | |
* @param {Object} [context=root] The context object. | * @param {Object} [context=root] The context object. | |
* @returns {Function} Returns a new `lodash` function. | * @returns {Function} Returns a new `lodash` function. | |
* @example | * @example | |
* | * | |
* _.mixin({ 'foo': _.constant('foo') }); | * _.mixin({ 'foo': _.constant('foo') }); | |
* | * | |
* var lodash = _.runInContext(); | * var lodash = _.runInContext(); | |
* lodash.mixin({ 'bar': lodash.constant('bar') }); | * lodash.mixin({ 'bar': lodash.constant('bar') }); | |
* | * | |
* _.isFunction(_.foo); | * _.isFunction(_.foo); | |
* // => true | * // => true | |
* _.isFunction(_.bar); | * _.isFunction(_.bar); | |
* // => false | * // => false | |
* | * | |
* lodash.isFunction(lodash.foo); | * lodash.isFunction(lodash.foo); | |
* // => false | * // => false | |
* lodash.isFunction(lodash.bar); | * lodash.isFunction(lodash.bar); | |
* // => true | * // => true | |
* | * | |
* // using `context` to mock `Date#getTime` use in `_.now` | * // Create a suped-up `defer` in Node.js. | |
* var mock = _.runInContext({ | ||
* 'Date': function() { | ||
* return { 'getTime': getTimeMock }; | ||
* } | ||
* }); | ||
* | ||
* // or creating a suped-up `defer` in Node.js | ||
* var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; | * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; | |
*/ | */ | |
function runInContext(context) { | var runInContext = (function runInContext(context) { | |
context = context ? _.defaults({}, context, _.pick(root, contextProps)) : ro | context = context == null ? root : _.defaults(root.Object(), context, _.pick | |
ot; | (root, contextProps)); | |
/** Built-in constructor references. */ | /** Built-in constructor references. */ | |
var Date = context.Date, | var Array = context.Array, | |
Date = context.Date, | ||
Error = context.Error, | Error = context.Error, | |
Function = context.Function, | ||
Math = context.Math, | Math = context.Math, | |
Object = context.Object, | ||
RegExp = context.RegExp, | RegExp = context.RegExp, | |
String = context.String, | ||
TypeError = context.TypeError; | TypeError = context.TypeError; | |
/** Used for built-in method references. */ | /** Used for built-in method references. */ | |
var arrayProto = context.Array.prototype, | var arrayProto = Array.prototype, | |
objectProto = context.Object.prototype; | funcProto = Function.prototype, | |
objectProto = Object.prototype; | ||
/** Used to detect overreaching core-js shims. */ | ||
var coreJsData = context['__core-js_shared__']; | ||
/** Used to resolve the decompiled source of functions. */ | /** Used to resolve the decompiled source of functions. */ | |
var funcToString = context.Function.prototype.toString; | var funcToString = funcProto.toString; | |
/** Used to check objects for own properties. */ | /** Used to check objects for own properties. */ | |
var hasOwnProperty = objectProto.hasOwnProperty; | var hasOwnProperty = objectProto.hasOwnProperty; | |
/** Used to generate unique IDs. */ | /** Used to generate unique IDs. */ | |
var idCounter = 0; | var idCounter = 0; | |
/** Used to infer the `Object` constructor. */ | /** Used to detect methods masquerading as native. */ | |
var objectCtorString = funcToString.call(Object); | var maskSrcKey = (function() { | |
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.I | ||
E_PROTO || ''); | ||
return uid ? ('Symbol(src)_1.' + uid) : ''; | ||
}()); | ||
/** | /** | |
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-26 | * Used to resolve the | |
2/6.0/#sec-object.prototype.tostring) | * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.pr | |
ototype.tostring) | ||
* of values. | * of values. | |
*/ | */ | |
var objectToString = objectProto.toString; | var nativeObjectToString = objectProto.toString; | |
/** Used to infer the `Object` constructor. */ | ||
var objectCtorString = funcToString.call(Object); | ||
/** Used to restore the original `_` reference in `_.noConflict`. */ | /** Used to restore the original `_` reference in `_.noConflict`. */ | |
var oldDash = root._; | var oldDash = root._; | |
/** Used to detect if a method is native. */ | /** Used to detect if a method is native. */ | |
var reIsNative = RegExp('^' + | var reIsNative = RegExp('^' + | |
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') | funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') | |
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?' ) + '$' | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?' ) + '$' | |
); | ); | |
/** Built-in value references. */ | /** Built-in value references. */ | |
var _Symbol = context.Symbol, | var Buffer = moduleExports ? context.Buffer : undefined, | |
Reflect = context.Reflect, | Symbol = context.Symbol, | |
Uint8Array = context.Uint8Array, | Uint8Array = context.Uint8Array, | |
clearTimeout = context.clearTimeout, | allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, | |
enumerate = Reflect ? Reflect.enumerate : undefined, | getPrototype = overArg(Object.getPrototypeOf, Object), | |
getPrototypeOf = Object.getPrototypeOf, | objectCreate = Object.create, | |
getOwnPropertySymbols = Object.getOwnPropertySymbols, | ||
iteratorSymbol = typeof (iteratorSymbol = _Symbol && _Symbol.iterator) = | ||
= 'symbol' ? iteratorSymbol : undefined, | ||
propertyIsEnumerable = objectProto.propertyIsEnumerable, | propertyIsEnumerable = objectProto.propertyIsEnumerable, | |
setTimeout = context.setTimeout, | splice = arrayProto.splice, | |
splice = arrayProto.splice; | spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, | |
symIterator = Symbol ? Symbol.iterator : undefined, | ||
symToStringTag = Symbol ? Symbol.toStringTag : undefined; | ||
var defineProperty = (function() { | ||
try { | ||
var func = getNative(Object, 'defineProperty'); | ||
func({}, '', {}); | ||
return func; | ||
} catch (e) {} | ||
}()); | ||
/** Mocked built-ins. */ | ||
var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context. | ||
clearTimeout, | ||
ctxNow = Date && Date.now !== root.Date.now && Date.now, | ||
ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTim | ||
eout; | ||
/* Built-in method references for those with the same name as other `lodash` methods. */ | /* Built-in method references for those with the same name as other `lodash` methods. */ | |
var nativeCeil = Math.ceil, | var nativeCeil = Math.ceil, | |
nativeFloor = Math.floor, | nativeFloor = Math.floor, | |
nativeGetSymbols = Object.getOwnPropertySymbols, | ||
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, | ||
nativeIsFinite = context.isFinite, | nativeIsFinite = context.isFinite, | |
nativeJoin = arrayProto.join, | nativeJoin = arrayProto.join, | |
nativeKeys = Object.keys, | nativeKeys = overArg(Object.keys, Object), | |
nativeMax = Math.max, | nativeMax = Math.max, | |
nativeMin = Math.min, | nativeMin = Math.min, | |
nativeNow = Date.now, | ||
nativeParseInt = context.parseInt, | nativeParseInt = context.parseInt, | |
nativeRandom = Math.random, | nativeRandom = Math.random, | |
nativeReverse = arrayProto.reverse; | nativeReverse = arrayProto.reverse; | |
/* Built-in method references that are verified to be native. */ | /* Built-in method references that are verified to be native. */ | |
var Map = getNative(context, 'Map'), | var DataView = getNative(context, 'DataView'), | |
Map = getNative(context, 'Map'), | ||
Promise = getNative(context, 'Promise'), | ||
Set = getNative(context, 'Set'), | Set = getNative(context, 'Set'), | |
WeakMap = getNative(context, 'WeakMap'), | WeakMap = getNative(context, 'WeakMap'), | |
nativeCreate = getNative(Object, 'create'); | nativeCreate = getNative(Object, 'create'); | |
/** Used to store function metadata. */ | /** Used to store function metadata. */ | |
var metaMap = WeakMap && new WeakMap; | var metaMap = WeakMap && new WeakMap; | |
/** Used to detect maps and sets. */ | ||
var mapCtorString = Map ? funcToString.call(Map) : '', | ||
setCtorString = Set ? funcToString.call(Set) : ''; | ||
/** Used to convert symbols to primitives and strings. */ | ||
var symbolProto = _Symbol ? _Symbol.prototype : undefined, | ||
symbolValueOf = _Symbol ? symbolProto.valueOf : undefined, | ||
symbolToString = _Symbol ? symbolProto.toString : undefined; | ||
/** Used to lookup unminified function names. */ | /** Used to lookup unminified function names. */ | |
var realNames = {}; | var realNames = {}; | |
/** Used to detect maps, sets, and weakmaps. */ | ||
var dataViewCtorString = toSource(DataView), | ||
mapCtorString = toSource(Map), | ||
promiseCtorString = toSource(Promise), | ||
setCtorString = toSource(Set), | ||
weakMapCtorString = toSource(WeakMap); | ||
/** Used to convert symbols to primitives and strings. */ | ||
var symbolProto = Symbol ? Symbol.prototype : undefined, | ||
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, | ||
symbolToString = symbolProto ? symbolProto.toString : undefined; | ||
/*------------------------------------------------------------------------*/ | /*------------------------------------------------------------------------*/ | |
/** | /** | |
* Creates a `lodash` object which wraps `value` to enable implicit method | * Creates a `lodash` object which wraps `value` to enable implicit method | |
* chaining. Methods that operate on and return arrays, collections, and | * chain sequences. Methods that operate on and return arrays, collections, | |
* functions can be chained together. Methods that retrieve a single value o | * and functions can be chained together. Methods that retrieve a single val | |
r | ue | |
* may return a primitive value will automatically end the chain sequence an | * or may return a primitive value will automatically end the chain sequence | |
d | * and return the unwrapped value. Otherwise, the value must be unwrapped | |
* return the unwrapped value. Otherwise, the value must be unwrapped with | * with `_#value`. | |
* `_#value`. | ||
* | * | |
* Explicit chaining, which must be unwrapped with `_#value` in all cases, | * Explicit chain sequences, which must be unwrapped with `_#value`, may be | |
* may be enabled using `_.chain`. | * enabled using `_.chain`. | |
* | * | |
* The execution of chained methods is lazy, that is, it's deferred until | * The execution of chained methods is lazy, that is, it's deferred until | |
* `_#value` is implicitly or explicitly called. | * `_#value` is implicitly or explicitly called. | |
* | * | |
* Lazy evaluation allows several methods to support shortcut fusion. Shortc | * Lazy evaluation allows several methods to support shortcut fusion. | |
ut | * Shortcut fusion is an optimization to merge iteratee calls; this avoids | |
* fusion is an optimization to merge iteratee calls; this avoids the creati | * the creation of intermediate arrays and can greatly reduce the number of | |
on | * iteratee executions. Sections of a chain sequence qualify for shortcut | |
* of intermediate arrays and can greatly reduce the number of iteratee exec | * fusion if the section is applied to an array and iteratees accept only | |
utions. | * one argument. The heuristic for whether a section qualifies for shortcut | |
* Sections of a chain sequence qualify for shortcut fusion if the section i | * fusion is subject to change. | |
s | ||
* applied to an array of at least two hundred elements and any iteratees | ||
* accept only one argument. The heuristic for whether a section qualifies | ||
* for shortcut fusion is subject to change. | ||
* | * | |
* Chaining is supported in custom builds as long as the `_#value` method is | * Chaining is supported in custom builds as long as the `_#value` method is | |
* directly or indirectly included in the build. | * directly or indirectly included in the build. | |
* | * | |
* In addition to lodash methods, wrappers have `Array` and `String` methods . | * In addition to lodash methods, wrappers have `Array` and `String` methods . | |
* | * | |
* The wrapper `Array` methods are: | * The wrapper `Array` methods are: | |
* `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` | * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` | |
* | * | |
* The wrapper `String` methods are: | * The wrapper `String` methods are: | |
* `replace` and `split` | * `replace` and `split` | |
* | * | |
* The wrapper methods that support shortcut fusion are: | * The wrapper methods that support shortcut fusion are: | |
* `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, | * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, | |
* `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice `, | * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice `, | |
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` | * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` | |
* | * | |
* The chainable wrapper methods are: | * The chainable wrapper methods are: | |
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, | * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, | |
* `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`, | * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, | |
* `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry | * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create | |
`, | `, | |
* `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, | * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, | |
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, | * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, | |
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`, | * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, | |
* `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, | * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, | |
* `forOwnRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initi | * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, | |
al`, | * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, | |
* `intersection`, `intersectionBy`, `intersectionWith`, invert`, `invokeMap | * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy | |
`, | `, | |
* `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, | * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesPrope | |
* `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`, | rty`, | |
* `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `order | * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, | |
By`, | * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, | |
* `over`, `overArgs`, `overEvery`, `overSome`, `partial`, `partialRight`, | * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, | |
* `partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, | * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllB | |
* `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, | y`, | |
* `reject`, `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, | * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject` | |
* `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, | , | |
* `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, | * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, | |
* `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform` | * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight | |
, | `, | |
* `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, | * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, | |
* `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, `without` | * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, | |
, | * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, | |
* `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, and `zipWith` | * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, | |
* `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, | ||
* `zipObject`, `zipObjectDeep`, and `zipWith` | ||
* | * | |
* The wrapper methods that are **not** chainable by default are: | * The wrapper methods that are **not** chainable by default are: | |
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, | * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, | |
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`, | * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, | |
* `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, | * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, | |
* `findLast`, `findLastIndex`, `findLastKey`, `floor`, `get`, `gt`, `gte`, | * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, | |
* `has`, `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, | * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRigh | |
* `invoke`, `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, | t`, | |
* `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, | * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has` | |
* `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, | , | |
* `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, | * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, | |
* `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, | * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObj | |
* `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, `last`, | ect`, | |
* `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, | * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, | |
* `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`, `padEnd`, | * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLengt | |
* `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat | h`, | |
`, | * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull` | |
* `result`, `round`, `runInContext`, `sample`, `shift`, `size`, `snakeCase` | , | |
, | * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, | |
* `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, `sortedLastInd | * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, | |
exBy`, | * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, | |
* `startCase`, `startsWith`, `subtract`, `sum`, sumBy`, `template`, `times` | * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, | |
, | * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, | |
* `toLower`, `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, toString | * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight | |
`, | `, | |
* `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqu | * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, | |
eId`, | * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, | |
* `upperCase`, `upperFirst`, `value`, and `words` | * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, | |
* `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, | ||
* `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, | ||
* `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, | ||
* `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, | ||
* `upperFirst`, `value`, and `words` | ||
* | * | |
* @name _ | * @name _ | |
* @constructor | * @constructor | |
* @category Seq | * @category Seq | |
* @param {*} value The value to wrap in a `lodash` instance. | * @param {*} value The value to wrap in a `lodash` instance. | |
* @returns {Object} Returns the new `lodash` wrapper instance. | * @returns {Object} Returns the new `lodash` wrapper instance. | |
* @example | * @example | |
* | * | |
* function square(n) { | * function square(n) { | |
* return n * n; | * return n * n; | |
* } | * } | |
* | * | |
* var wrapped = _([1, 2, 3]); | * var wrapped = _([1, 2, 3]); | |
* | * | |
* // returns an unwrapped value | * // Returns an unwrapped value. | |
* wrapped.reduce(_.add); | * wrapped.reduce(_.add); | |
* // => 6 | * // => 6 | |
* | * | |
* // returns a wrapped value | * // Returns a wrapped value. | |
* var squares = wrapped.map(square); | * var squares = wrapped.map(square); | |
* | * | |
* _.isArray(squares); | * _.isArray(squares); | |
* // => false | * // => false | |
* | * | |
* _.isArray(squares.value()); | * _.isArray(squares.value()); | |
* // => true | * // => true | |
*/ | */ | |
function lodash(value) { | function lodash(value) { | |
if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapp er)) { | if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapp er)) { | |
skipping to change at line 1452 | skipping to change at line 1703 | |
return value; | return value; | |
} | } | |
if (hasOwnProperty.call(value, '__wrapped__')) { | if (hasOwnProperty.call(value, '__wrapped__')) { | |
return wrapperClone(value); | return wrapperClone(value); | |
} | } | |
} | } | |
return new LodashWrapper(value); | return new LodashWrapper(value); | |
} | } | |
/** | /** | |
* The function whose prototype all chaining wrappers inherit from. | * The base implementation of `_.create` without support for assigning | |
* properties to the created object. | ||
* | ||
* @private | ||
* @param {Object} proto The object to inherit from. | ||
* @returns {Object} Returns the new object. | ||
*/ | ||
var baseCreate = (function() { | ||
function object() {} | ||
return function(proto) { | ||
if (!isObject(proto)) { | ||
return {}; | ||
} | ||
if (objectCreate) { | ||
return objectCreate(proto); | ||
} | ||
object.prototype = proto; | ||
var result = new object; | ||
object.prototype = undefined; | ||
return result; | ||
}; | ||
}()); | ||
/** | ||
* The function whose prototype chain sequence wrappers inherit from. | ||
* | * | |
* @private | * @private | |
*/ | */ | |
function baseLodash() { | function baseLodash() { | |
// No operation performed. | // No operation performed. | |
} | } | |
/** | /** | |
* The base constructor for creating `lodash` wrapper objects. | * The base constructor for creating `lodash` wrapper objects. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to wrap. | * @param {*} value The value to wrap. | |
* @param {boolean} [chainAll] Enable chaining for all wrapper methods. | * @param {boolean} [chainAll] Enable explicit method chain sequences. | |
*/ | */ | |
function LodashWrapper(value, chainAll) { | function LodashWrapper(value, chainAll) { | |
this.__wrapped__ = value; | this.__wrapped__ = value; | |
this.__actions__ = []; | this.__actions__ = []; | |
this.__chain__ = !!chainAll; | this.__chain__ = !!chainAll; | |
this.__index__ = 0; | this.__index__ = 0; | |
this.__values__ = undefined; | this.__values__ = undefined; | |
} | } | |
/** | /** | |
* By default, the template delimiters used by lodash are like those in | * By default, the template delimiters used by lodash are like those in | |
* embedded Ruby (ERB). Change the following template settings to use | * embedded Ruby (ERB) as well as ES2015 template strings. Change the | |
* alternative delimiters. | * following template settings to use alternative delimiters. | |
* | * | |
* @static | * @static | |
* @memberOf _ | * @memberOf _ | |
* @type Object | * @type {Object} | |
*/ | */ | |
lodash.templateSettings = { | lodash.templateSettings = { | |
/** | /** | |
* Used to detect `data` property values to be HTML-escaped. | * Used to detect `data` property values to be HTML-escaped. | |
* | * | |
* @memberOf _.templateSettings | * @memberOf _.templateSettings | |
* @type RegExp | * @type {RegExp} | |
*/ | */ | |
'escape': reEscape, | 'escape': reEscape, | |
/** | /** | |
* Used to detect code to be evaluated. | * Used to detect code to be evaluated. | |
* | * | |
* @memberOf _.templateSettings | * @memberOf _.templateSettings | |
* @type RegExp | * @type {RegExp} | |
*/ | */ | |
'evaluate': reEvaluate, | 'evaluate': reEvaluate, | |
/** | /** | |
* Used to detect `data` property values to inject. | * Used to detect `data` property values to inject. | |
* | * | |
* @memberOf _.templateSettings | * @memberOf _.templateSettings | |
* @type RegExp | * @type {RegExp} | |
*/ | */ | |
'interpolate': reInterpolate, | 'interpolate': reInterpolate, | |
/** | /** | |
* Used to reference the data object in the template text. | * Used to reference the data object in the template text. | |
* | * | |
* @memberOf _.templateSettings | * @memberOf _.templateSettings | |
* @type string | * @type {string} | |
*/ | */ | |
'variable': '', | 'variable': '', | |
/** | /** | |
* Used to import variables into the compiled template. | * Used to import variables into the compiled template. | |
* | * | |
* @memberOf _.templateSettings | * @memberOf _.templateSettings | |
* @type Object | * @type {Object} | |
*/ | */ | |
'imports': { | 'imports': { | |
/** | /** | |
* A reference to the `lodash` function. | * A reference to the `lodash` function. | |
* | * | |
* @memberOf _.templateSettings.imports | * @memberOf _.templateSettings.imports | |
* @type Function | * @type {Function} | |
*/ | */ | |
'_': lodash | '_': lodash | |
} | } | |
}; | }; | |
// Ensure wrappers are instances of `baseLodash`. | ||
lodash.prototype = baseLodash.prototype; | ||
lodash.prototype.constructor = lodash; | ||
LodashWrapper.prototype = baseCreate(baseLodash.prototype); | ||
LodashWrapper.prototype.constructor = LodashWrapper; | ||
/*------------------------------------------------------------------------*/ | /*------------------------------------------------------------------------*/ | |
/** | /** | |
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluati on. | * Creates a lazy wrapper object which wraps `value` to enable lazy evaluati on. | |
* | * | |
* @private | * @private | |
* @constructor | ||
* @param {*} value The value to wrap. | * @param {*} value The value to wrap. | |
*/ | */ | |
function LazyWrapper(value) { | function LazyWrapper(value) { | |
this.__wrapped__ = value; | this.__wrapped__ = value; | |
this.__actions__ = []; | this.__actions__ = []; | |
this.__dir__ = 1; | this.__dir__ = 1; | |
this.__filtered__ = false; | this.__filtered__ = false; | |
this.__iteratees__ = []; | this.__iteratees__ = []; | |
this.__takeCount__ = MAX_ARRAY_LENGTH; | this.__takeCount__ = MAX_ARRAY_LENGTH; | |
this.__views__ = []; | this.__views__ = []; | |
skipping to change at line 1617 | skipping to change at line 1900 | |
view = getView(0, arrLength, this.__views__), | view = getView(0, arrLength, this.__views__), | |
start = view.start, | start = view.start, | |
end = view.end, | end = view.end, | |
length = end - start, | length = end - start, | |
index = isRight ? end : (start - 1), | index = isRight ? end : (start - 1), | |
iteratees = this.__iteratees__, | iteratees = this.__iteratees__, | |
iterLength = iteratees.length, | iterLength = iteratees.length, | |
resIndex = 0, | resIndex = 0, | |
takeCount = nativeMin(length, this.__takeCount__); | takeCount = nativeMin(length, this.__takeCount__); | |
if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && take Count == length)) { | if (!isArr || (!isRight && arrLength == length && takeCount == length)) { | |
return baseWrapperValue(array, this.__actions__); | return baseWrapperValue(array, this.__actions__); | |
} | } | |
var result = []; | var result = []; | |
outer: | outer: | |
while (length-- && resIndex < takeCount) { | while (length-- && resIndex < takeCount) { | |
index += dir; | index += dir; | |
var iterIndex = -1, | var iterIndex = -1, | |
value = array[index]; | value = array[index]; | |
skipping to change at line 1650 | skipping to change at line 1933 | |
} else { | } else { | |
break outer; | break outer; | |
} | } | |
} | } | |
} | } | |
result[resIndex++] = value; | result[resIndex++] = value; | |
} | } | |
return result; | return result; | |
} | } | |
// Ensure `LazyWrapper` is an instance of `baseLodash`. | ||
LazyWrapper.prototype = baseCreate(baseLodash.prototype); | ||
LazyWrapper.prototype.constructor = LazyWrapper; | ||
/*------------------------------------------------------------------------*/ | /*------------------------------------------------------------------------*/ | |
/** | /** | |
* Creates an hash object. | * Creates a hash object. | |
* | * | |
* @private | * @private | |
* @returns {Object} Returns the new hash object. | * @constructor | |
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | */ | |
function Hash() {} | function Hash(entries) { | |
var index = -1, | ||
length = entries == null ? 0 : entries.length; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the hash. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf Hash | ||
*/ | ||
function hashClear() { | ||
this.__data__ = nativeCreate ? nativeCreate(null) : {}; | ||
this.size = 0; | ||
} | ||
/** | /** | |
* Removes `key` and its value from the hash. | * Removes `key` and its value from the hash. | |
* | * | |
* @private | * @private | |
* @name delete | ||
* @memberOf Hash | ||
* @param {Object} hash The hash to modify. | * @param {Object} hash The hash to modify. | |
* @param {string} key The key of the value to remove. | * @param {string} key The key of the value to remove. | |
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | * @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
*/ | */ | |
function hashDelete(hash, key) { | function hashDelete(key) { | |
return hashHas(hash, key) && delete hash[key]; | var result = this.has(key) && delete this.__data__[key]; | |
this.size -= result ? 1 : 0; | ||
return result; | ||
} | } | |
/** | /** | |
* Gets the hash value for `key`. | * Gets the hash value for `key`. | |
* | * | |
* @private | * @private | |
* @param {Object} hash The hash to query. | * @name get | |
* @memberOf Hash | ||
* @param {string} key The key of the value to get. | * @param {string} key The key of the value to get. | |
* @returns {*} Returns the entry value. | * @returns {*} Returns the entry value. | |
*/ | */ | |
function hashGet(hash, key) { | function hashGet(key) { | |
var data = this.__data__; | ||
if (nativeCreate) { | if (nativeCreate) { | |
var result = hash[key]; | var result = data[key]; | |
return result === HASH_UNDEFINED ? undefined : result; | return result === HASH_UNDEFINED ? undefined : result; | |
} | } | |
return hasOwnProperty.call(hash, key) ? hash[key] : undefined; | return hasOwnProperty.call(data, key) ? data[key] : undefined; | |
} | } | |
/** | /** | |
* Checks if a hash value for `key` exists. | * Checks if a hash value for `key` exists. | |
* | * | |
* @private | * @private | |
* @param {Object} hash The hash to query. | * @name has | |
* @memberOf Hash | ||
* @param {string} key The key of the entry to check. | * @param {string} key The key of the entry to check. | |
* @returns {boolean} Returns `true` if an entry for `key` exists, else `fal se`. | * @returns {boolean} Returns `true` if an entry for `key` exists, else `fal se`. | |
*/ | */ | |
function hashHas(hash, key) { | function hashHas(key) { | |
return nativeCreate ? hash[key] !== undefined : hasOwnProperty.call(hash, | var data = this.__data__; | |
key); | return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data | |
, key); | ||
} | } | |
/** | /** | |
* Sets the hash `key` to `value`. | * Sets the hash `key` to `value`. | |
* | * | |
* @private | * @private | |
* @param {Object} hash The hash to modify. | * @name set | |
* @memberOf Hash | ||
* @param {string} key The key of the value to set. | * @param {string} key The key of the value to set. | |
* @param {*} value The value to set. | * @param {*} value The value to set. | |
* @returns {Object} Returns the hash instance. | ||
*/ | */ | |
function hashSet(hash, key, value) { | function hashSet(key, value) { | |
hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value | var data = this.__data__; | |
; | this.size += this.has(key) ? 0 : 1; | |
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value | ||
; | ||
return this; | ||
} | } | |
// Add methods to `Hash`. | ||
Hash.prototype.clear = hashClear; | ||
Hash.prototype['delete'] = hashDelete; | ||
Hash.prototype.get = hashGet; | ||
Hash.prototype.has = hashHas; | ||
Hash.prototype.set = hashSet; | ||
/*------------------------------------------------------------------------*/ | ||
/** | ||
* Creates an list cache object. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | ||
function ListCache(entries) { | ||
var index = -1, | ||
length = entries == null ? 0 : entries.length; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the list cache. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf ListCache | ||
*/ | ||
function listCacheClear() { | ||
this.__data__ = []; | ||
this.size = 0; | ||
} | ||
/** | ||
* Removes `key` and its value from the list cache. | ||
* | ||
* @private | ||
* @name delete | ||
* @memberOf ListCache | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function listCacheDelete(key) { | ||
var data = this.__data__, | ||
index = assocIndexOf(data, key); | ||
if (index < 0) { | ||
return false; | ||
} | ||
var lastIndex = data.length - 1; | ||
if (index == lastIndex) { | ||
data.pop(); | ||
} else { | ||
splice.call(data, index, 1); | ||
} | ||
--this.size; | ||
return true; | ||
} | ||
/** | ||
* Gets the list cache value for `key`. | ||
* | ||
* @private | ||
* @name get | ||
* @memberOf ListCache | ||
* @param {string} key The key of the value to get. | ||
* @returns {*} Returns the entry value. | ||
*/ | ||
function listCacheGet(key) { | ||
var data = this.__data__, | ||
index = assocIndexOf(data, key); | ||
return index < 0 ? undefined : data[index][1]; | ||
} | ||
/** | ||
* Checks if a list cache value for `key` exists. | ||
* | ||
* @private | ||
* @name has | ||
* @memberOf ListCache | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `fal | ||
se`. | ||
*/ | ||
function listCacheHas(key) { | ||
return assocIndexOf(this.__data__, key) > -1; | ||
} | ||
/** | ||
* Sets the list cache `key` to `value`. | ||
* | ||
* @private | ||
* @name set | ||
* @memberOf ListCache | ||
* @param {string} key The key of the value to set. | ||
* @param {*} value The value to set. | ||
* @returns {Object} Returns the list cache instance. | ||
*/ | ||
function listCacheSet(key, value) { | ||
var data = this.__data__, | ||
index = assocIndexOf(data, key); | ||
if (index < 0) { | ||
++this.size; | ||
data.push([key, value]); | ||
} else { | ||
data[index][1] = value; | ||
} | ||
return this; | ||
} | ||
// Add methods to `ListCache`. | ||
ListCache.prototype.clear = listCacheClear; | ||
ListCache.prototype['delete'] = listCacheDelete; | ||
ListCache.prototype.get = listCacheGet; | ||
ListCache.prototype.has = listCacheHas; | ||
ListCache.prototype.set = listCacheSet; | ||
/*------------------------------------------------------------------------*/ | /*------------------------------------------------------------------------*/ | |
/** | /** | |
* Creates a map cache object to store key-value pairs. | * Creates a map cache object to store key-value pairs. | |
* | * | |
* @private | * @private | |
* @param {Array} [values] The values to cache. | * @constructor | |
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | */ | |
function MapCache(values) { | function MapCache(entries) { | |
var index = -1, | var index = -1, | |
length = values ? values.length : 0; | length = entries == null ? 0 : entries.length; | |
this.clear(); | this.clear(); | |
while (++index < length) { | while (++index < length) { | |
var entry = values[index]; | var entry = entries[index]; | |
this.set(entry[0], entry[1]); | this.set(entry[0], entry[1]); | |
} | } | |
} | } | |
/** | /** | |
* Removes all key-value entries from the map. | * Removes all key-value entries from the map. | |
* | * | |
* @private | * @private | |
* @name clear | * @name clear | |
* @memberOf MapCache | * @memberOf MapCache | |
*/ | */ | |
function mapClear() { | function mapCacheClear() { | |
this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': n | this.size = 0; | |
ew Hash }; | this.__data__ = { | |
'hash': new Hash, | ||
'map': new (Map || ListCache), | ||
'string': new Hash | ||
}; | ||
} | } | |
/** | /** | |
* Removes `key` and its value from the map. | * Removes `key` and its value from the map. | |
* | * | |
* @private | * @private | |
* @name delete | * @name delete | |
* @memberOf MapCache | * @memberOf MapCache | |
* @param {string} key The key of the value to remove. | * @param {string} key The key of the value to remove. | |
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | * @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
*/ | */ | |
function mapDelete(key) { | function mapCacheDelete(key) { | |
var data = this.__data__; | var result = getMapData(this, key)['delete'](key); | |
if (isKeyable(key)) { | this.size -= result ? 1 : 0; | |
return hashDelete(typeof key == 'string' ? data.string : data.hash, key) | return result; | |
; | ||
} | ||
return Map ? data.map['delete'](key) : assocDelete(data.map, key); | ||
} | } | |
/** | /** | |
* Gets the map value for `key`. | * Gets the map value for `key`. | |
* | * | |
* @private | * @private | |
* @name get | * @name get | |
* @memberOf MapCache | * @memberOf MapCache | |
* @param {string} key The key of the value to get. | * @param {string} key The key of the value to get. | |
* @returns {*} Returns the entry value. | * @returns {*} Returns the entry value. | |
*/ | */ | |
function mapGet(key) { | function mapCacheGet(key) { | |
var data = this.__data__; | return getMapData(this, key).get(key); | |
if (isKeyable(key)) { | ||
return hashGet(typeof key == 'string' ? data.string : data.hash, key); | ||
} | ||
return Map ? data.map.get(key) : assocGet(data.map, key); | ||
} | } | |
/** | /** | |
* Checks if a map value for `key` exists. | * Checks if a map value for `key` exists. | |
* | * | |
* @private | * @private | |
* @name has | * @name has | |
* @memberOf MapCache | * @memberOf MapCache | |
* @param {string} key The key of the entry to check. | * @param {string} key The key of the entry to check. | |
* @returns {boolean} Returns `true` if an entry for `key` exists, else `fal se`. | * @returns {boolean} Returns `true` if an entry for `key` exists, else `fal se`. | |
*/ | */ | |
function mapHas(key) { | function mapCacheHas(key) { | |
var data = this.__data__; | return getMapData(this, key).has(key); | |
if (isKeyable(key)) { | ||
return hashHas(typeof key == 'string' ? data.string : data.hash, key); | ||
} | ||
return Map ? data.map.has(key) : assocHas(data.map, key); | ||
} | } | |
/** | /** | |
* Sets the map `key` to `value`. | * Sets the map `key` to `value`. | |
* | * | |
* @private | * @private | |
* @name set | * @name set | |
* @memberOf MapCache | * @memberOf MapCache | |
* @param {string} key The key of the value to set. | * @param {string} key The key of the value to set. | |
* @param {*} value The value to set. | * @param {*} value The value to set. | |
* @returns {Object} Returns the map cache object. | * @returns {Object} Returns the map cache instance. | |
*/ | */ | |
function mapSet(key, value) { | function mapCacheSet(key, value) { | |
var data = this.__data__; | var data = getMapData(this, key), | |
if (isKeyable(key)) { | size = data.size; | |
hashSet(typeof key == 'string' ? data.string : data.hash, key, value); | ||
} else if (Map) { | data.set(key, value); | |
data.map.set(key, value); | this.size += data.size == size ? 0 : 1; | |
} else { | ||
assocSet(data.map, key, value); | ||
} | ||
return this; | return this; | |
} | } | |
// Add methods to `MapCache`. | ||
MapCache.prototype.clear = mapCacheClear; | ||
MapCache.prototype['delete'] = mapCacheDelete; | ||
MapCache.prototype.get = mapCacheGet; | ||
MapCache.prototype.has = mapCacheHas; | ||
MapCache.prototype.set = mapCacheSet; | ||
/*------------------------------------------------------------------------*/ | /*------------------------------------------------------------------------*/ | |
/** | /** | |
* | * | |
* Creates a set cache object to store unique values. | * Creates an array cache object to store unique values. | |
* | * | |
* @private | * @private | |
* @constructor | ||
* @param {Array} [values] The values to cache. | * @param {Array} [values] The values to cache. | |
*/ | */ | |
function SetCache(values) { | function SetCache(values) { | |
var index = -1, | var index = -1, | |
length = values ? values.length : 0; | length = values == null ? 0 : values.length; | |
this.__data__ = new MapCache; | this.__data__ = new MapCache; | |
while (++index < length) { | while (++index < length) { | |
this.push(values[index]); | this.add(values[index]); | |
} | } | |
} | } | |
/** | /** | |
* Checks if `value` is in `cache`. | * Adds `value` to the array cache. | |
* | * | |
* @private | * @private | |
* @param {Object} cache The set cache to search. | * @name add | |
* @param {*} value The value to search for. | * @memberOf SetCache | |
* @returns {number} Returns `true` if `value` is found, else `false`. | * @alias push | |
* @param {*} value The value to cache. | ||
* @returns {Object} Returns the cache instance. | ||
*/ | */ | |
function cacheHas(cache, value) { | function setCacheAdd(value) { | |
var map = cache.__data__; | this.__data__.set(value, HASH_UNDEFINED); | |
if (isKeyable(value)) { | return this; | |
var data = map.__data__, | ||
hash = typeof value == 'string' ? data.string : data.hash; | ||
return hash[value] === HASH_UNDEFINED; | ||
} | ||
return map.has(value); | ||
} | } | |
/** | /** | |
* Adds `value` to the set cache. | * Checks if `value` is in the array cache. | |
* | * | |
* @private | * @private | |
* @name push | * @name has | |
* @memberOf SetCache | * @memberOf SetCache | |
* @param {*} value The value to cache. | * @param {*} value The value to search for. | |
* @returns {number} Returns `true` if `value` is found, else `false`. | ||
*/ | */ | |
function cachePush(value) { | function setCacheHas(value) { | |
var map = this.__data__; | return this.__data__.has(value); | |
if (isKeyable(value)) { | ||
var data = map.__data__, | ||
hash = typeof value == 'string' ? data.string : data.hash; | ||
hash[value] = HASH_UNDEFINED; | ||
} | ||
else { | ||
map.set(value, HASH_UNDEFINED); | ||
} | ||
} | } | |
// Add methods to `SetCache`. | ||
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; | ||
SetCache.prototype.has = setCacheHas; | ||
/*------------------------------------------------------------------------*/ | /*------------------------------------------------------------------------*/ | |
/** | /** | |
* Creates a stack cache object to store key-value pairs. | * Creates a stack cache object to store key-value pairs. | |
* | * | |
* @private | * @private | |
* @param {Array} [values] The values to cache. | * @constructor | |
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | */ | |
function Stack(values) { | function Stack(entries) { | |
var index = -1, | var data = this.__data__ = new ListCache(entries); | |
length = values ? values.length : 0; | this.size = data.size; | |
this.clear(); | ||
while (++index < length) { | ||
var entry = values[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | } | |
/** | /** | |
* Removes all key-value entries from the stack. | * Removes all key-value entries from the stack. | |
* | * | |
* @private | * @private | |
* @name clear | * @name clear | |
* @memberOf Stack | * @memberOf Stack | |
*/ | */ | |
function stackClear() { | function stackClear() { | |
this.__data__ = { 'array': [], 'map': null }; | this.__data__ = new ListCache; | |
this.size = 0; | ||
} | } | |
/** | /** | |
* Removes `key` and its value from the stack. | * Removes `key` and its value from the stack. | |
* | * | |
* @private | * @private | |
* @name delete | * @name delete | |
* @memberOf Stack | * @memberOf Stack | |
* @param {string} key The key of the value to remove. | * @param {string} key The key of the value to remove. | |
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | * @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
*/ | */ | |
function stackDelete(key) { | function stackDelete(key) { | |
var data = this.__data__, | var data = this.__data__, | |
array = data.array; | result = data['delete'](key); | |
return array ? assocDelete(array, key) : data.map['delete'](key); | this.size = data.size; | |
return result; | ||
} | } | |
/** | /** | |
* Gets the stack value for `key`. | * Gets the stack value for `key`. | |
* | * | |
* @private | * @private | |
* @name get | * @name get | |
* @memberOf Stack | * @memberOf Stack | |
* @param {string} key The key of the value to get. | * @param {string} key The key of the value to get. | |
* @returns {*} Returns the entry value. | * @returns {*} Returns the entry value. | |
*/ | */ | |
function stackGet(key) { | function stackGet(key) { | |
var data = this.__data__, | return this.__data__.get(key); | |
array = data.array; | ||
return array ? assocGet(array, key) : data.map.get(key); | ||
} | } | |
/** | /** | |
* Checks if a stack value for `key` exists. | * Checks if a stack value for `key` exists. | |
* | * | |
* @private | * @private | |
* @name has | * @name has | |
* @memberOf Stack | * @memberOf Stack | |
* @param {string} key The key of the entry to check. | * @param {string} key The key of the entry to check. | |
* @returns {boolean} Returns `true` if an entry for `key` exists, else `fal se`. | * @returns {boolean} Returns `true` if an entry for `key` exists, else `fal se`. | |
*/ | */ | |
function stackHas(key) { | function stackHas(key) { | |
var data = this.__data__, | return this.__data__.has(key); | |
array = data.array; | ||
return array ? assocHas(array, key) : data.map.has(key); | ||
} | } | |
/** | /** | |
* Sets the stack `key` to `value`. | * Sets the stack `key` to `value`. | |
* | * | |
* @private | * @private | |
* @name set | * @name set | |
* @memberOf Stack | * @memberOf Stack | |
* @param {string} key The key of the value to set. | * @param {string} key The key of the value to set. | |
* @param {*} value The value to set. | * @param {*} value The value to set. | |
* @returns {Object} Returns the stack cache object. | * @returns {Object} Returns the stack cache instance. | |
*/ | */ | |
function stackSet(key, value) { | function stackSet(key, value) { | |
var data = this.__data__, | var data = this.__data__; | |
array = data.array; | if (data instanceof ListCache) { | |
var pairs = data.__data__; | ||
if (array) { | if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { | |
if (array.length < (LARGE_ARRAY_SIZE - 1)) { | pairs.push([key, value]); | |
assocSet(array, key, value); | this.size = ++data.size; | |
} else { | return this; | |
data.array = null; | ||
data.map = new MapCache(array); | ||
} | } | |
data = this.__data__ = new MapCache(pairs); | ||
} | } | |
var map = data.map; | data.set(key, value); | |
if (map) { | this.size = data.size; | |
map.set(key, value); | ||
} | ||
return this; | return this; | |
} | } | |
/*------------------------------------------------------------------------*/ | // Add methods to `Stack`. | |
Stack.prototype.clear = stackClear; | ||
Stack.prototype['delete'] = stackDelete; | ||
Stack.prototype.get = stackGet; | ||
Stack.prototype.has = stackHas; | ||
Stack.prototype.set = stackSet; | ||
/** | /*------------------------------------------------------------------------*/ | |
* Removes `key` and its value from the associative array. | ||
* | ||
* @private | ||
* @param {Array} array The array to query. | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function assocDelete(array, key) { | ||
var index = assocIndexOf(array, key); | ||
if (index < 0) { | ||
return false; | ||
} | ||
var lastIndex = array.length - 1; | ||
if (index == lastIndex) { | ||
array.pop(); | ||
} else { | ||
splice.call(array, index, 1); | ||
} | ||
return true; | ||
} | ||
/** | /** | |
* Gets the associative array value for `key`. | * Creates an array of the enumerable property names of the array-like `valu e`. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to query. | * @param {*} value The value to query. | |
* @param {string} key The key of the value to get. | * @param {boolean} inherited Specify returning inherited property names. | |
* @returns {*} Returns the entry value. | * @returns {Array} Returns the array of property names. | |
*/ | */ | |
function assocGet(array, key) { | function arrayLikeKeys(value, inherited) { | |
var index = assocIndexOf(array, key); | var isArr = isArray(value), | |
return index < 0 ? undefined : array[index][1]; | isArg = !isArr && isArguments(value), | |
} | isBuff = !isArr && !isArg && isBuffer(value), | |
isType = !isArr && !isArg && !isBuff && isTypedArray(value), | ||
skipIndexes = isArr || isArg || isBuff || isType, | ||
result = skipIndexes ? baseTimes(value.length, String) : [], | ||
length = result.length; | ||
/** | for (var key in value) { | |
* Checks if an associative array value for `key` exists. | if ((inherited || hasOwnProperty.call(value, key)) && | |
* | !(skipIndexes && ( | |
* @private | // Safari 9 has enumerable `arguments.length` in strict mode. | |
* @param {Array} array The array to query. | key == 'length' || | |
* @param {string} key The key of the entry to check. | // Node.js 0.10 has enumerable non-index properties on buffers. | |
* @returns {boolean} Returns `true` if an entry for `key` exists, else `fal | (isBuff && (key == 'offset' || key == 'parent')) || | |
se`. | // PhantomJS 2 has enumerable non-index properties on typed array | |
*/ | s. | |
function assocHas(array, key) { | (isType && (key == 'buffer' || key == 'byteLength' || key == 'byt | |
return assocIndexOf(array, key) > -1; | eOffset')) || | |
// Skip index properties. | ||
isIndex(key, length) | ||
))) { | ||
result.push(key); | ||
} | ||
} | ||
return result; | ||
} | } | |
/** | /** | |
* Gets the index at which the first occurrence of `key` is found in `array` | * A specialized version of `_.sample` for arrays. | |
* of key-value pairs. | ||
* | * | |
* @private | * @private | |
* @param {Array} array The array to search. | * @param {Array} array The array to sample. | |
* @param {*} key The key to search for. | * @returns {*} Returns the random element. | |
* @returns {number} Returns the index of the matched value, else `-1`. | ||
*/ | */ | |
function assocIndexOf(array, key) { | function arraySample(array) { | |
var length = array.length; | var length = array.length; | |
while (length--) { | return length ? array[baseRandom(0, length - 1)] : undefined; | |
if (eq(array[length][0], key)) { | ||
return length; | ||
} | ||
} | ||
return -1; | ||
} | } | |
/** | /** | |
* Sets the associative array `key` to `value`. | * A specialized version of `_.sampleSize` for arrays. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to modify. | * @param {Array} array The array to sample. | |
* @param {string} key The key of the value to set. | * @param {number} n The number of elements to sample. | |
* @param {*} value The value to set. | * @returns {Array} Returns the random elements. | |
*/ | */ | |
function assocSet(array, key, value) { | function arraySampleSize(array, n) { | |
var index = assocIndexOf(array, key); | return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); | |
if (index < 0) { | ||
array.push([key, value]); | ||
} else { | ||
array[index][1] = value; | ||
} | ||
} | } | |
/*------------------------------------------------------------------------*/ | ||
/** | /** | |
* Used by `_.defaults` to customize its `_.assignIn` use. | * A specialized version of `_.shuffle` for arrays. | |
* | * | |
* @private | * @private | |
* @param {*} objValue The destination value. | * @param {Array} array The array to shuffle. | |
* @param {*} srcValue The source value. | * @returns {Array} Returns the new shuffled array. | |
* @param {string} key The key of the property to assign. | ||
* @param {Object} object The parent object of `objValue`. | ||
* @returns {*} Returns the value to assign. | ||
*/ | */ | |
function assignInDefaults(objValue, srcValue, key, object) { | function arrayShuffle(array) { | |
if (objValue === undefined || | return shuffleSelf(copyArray(array)); | |
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) | ||
{ | ||
return srcValue; | ||
} | ||
return objValue; | ||
} | } | |
/** | /** | |
* This function is like `assignValue` except that it doesn't assign `undefi | * This function is like `assignValue` except that it doesn't assign | |
ned` values. | * `undefined` values. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to modify. | * @param {Object} object The object to modify. | |
* @param {string} key The key of the property to assign. | * @param {string} key The key of the property to assign. | |
* @param {*} value The value to assign. | * @param {*} value The value to assign. | |
*/ | */ | |
function assignMergeValue(object, key, value) { | function assignMergeValue(object, key, value) { | |
if ((value !== undefined && !eq(object[key], value)) || | if ((value !== undefined && !eq(object[key], value)) || | |
(typeof key == 'number' && value === undefined && !(key in object))) { | (value === undefined && !(key in object))) { | |
object[key] = value; | baseAssignValue(object, key, value); | |
} | } | |
} | } | |
/** | /** | |
* Assigns `value` to `key` of `object` if the existing value is not equival ent | * Assigns `value` to `key` of `object` if the existing value is not equival ent | |
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-s amevaluezero) | * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-s amevaluezero) | |
* for equality comparisons. | * for equality comparisons. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to modify. | * @param {Object} object The object to modify. | |
* @param {string} key The key of the property to assign. | * @param {string} key The key of the property to assign. | |
* @param {*} value The value to assign. | * @param {*} value The value to assign. | |
*/ | */ | |
function assignValue(object, key, value) { | function assignValue(object, key, value) { | |
var objValue = object[key]; | var objValue = object[key]; | |
if ((!eq(objValue, value) || | if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || | |
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key) | ||
)) || | ||
(value === undefined && !(key in object))) { | (value === undefined && !(key in object))) { | |
object[key] = value; | baseAssignValue(object, key, value); | |
} | } | |
} | } | |
/** | /** | |
* Gets the index at which the `key` is found in `array` of key-value pairs. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {*} key The key to search for. | ||
* @returns {number} Returns the index of the matched value, else `-1`. | ||
*/ | ||
function assocIndexOf(array, key) { | ||
var length = array.length; | ||
while (length--) { | ||
if (eq(array[length][0], key)) { | ||
return length; | ||
} | ||
} | ||
return -1; | ||
} | ||
/** | ||
* Aggregates elements of `collection` on `accumulator` with keys transforme | ||
d | ||
* by `iteratee` and values set by `setter`. | ||
* | ||
* @private | ||
* @param {Array|Object} collection The collection to iterate over. | ||
* @param {Function} setter The function to set `accumulator` values. | ||
* @param {Function} iteratee The iteratee to transform keys. | ||
* @param {Object} accumulator The initial aggregated object. | ||
* @returns {Function} Returns `accumulator`. | ||
*/ | ||
function baseAggregator(collection, setter, iteratee, accumulator) { | ||
baseEach(collection, function(value, key, collection) { | ||
setter(accumulator, value, iteratee(value), collection); | ||
}); | ||
return accumulator; | ||
} | ||
/** | ||
* The base implementation of `_.assign` without support for multiple source s | * The base implementation of `_.assign` without support for multiple source s | |
* or `customizer` functions. | * or `customizer` functions. | |
* | * | |
* @private | * @private | |
* @param {Object} object The destination object. | * @param {Object} object The destination object. | |
* @param {Object} source The source object. | * @param {Object} source The source object. | |
* @returns {Object} Returns `object`. | * @returns {Object} Returns `object`. | |
*/ | */ | |
function baseAssign(object, source) { | function baseAssign(object, source) { | |
return object && copyObject(source, keys(source), object); | return object && copyObject(source, keys(source), object); | |
} | } | |
/** | /** | |
* The base implementation of `_.assignIn` without support for multiple sour | ||
ces | ||
* or `customizer` functions. | ||
* | ||
* @private | ||
* @param {Object} object The destination object. | ||
* @param {Object} source The source object. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function baseAssignIn(object, source) { | ||
return object && copyObject(source, keysIn(source), object); | ||
} | ||
/** | ||
* The base implementation of `assignValue` and `assignMergeValue` without | ||
* value checks. | ||
* | ||
* @private | ||
* @param {Object} object The object to modify. | ||
* @param {string} key The key of the property to assign. | ||
* @param {*} value The value to assign. | ||
*/ | ||
function baseAssignValue(object, key, value) { | ||
if (key == '__proto__' && defineProperty) { | ||
defineProperty(object, key, { | ||
'configurable': true, | ||
'enumerable': true, | ||
'value': value, | ||
'writable': true | ||
}); | ||
} else { | ||
object[key] = value; | ||
} | ||
} | ||
/** | ||
* The base implementation of `_.at` without support for individual paths. | * The base implementation of `_.at` without support for individual paths. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to iterate over. | * @param {Object} object The object to iterate over. | |
* @param {string[]} paths The property paths of elements to pick. | * @param {string[]} paths The property paths to pick. | |
* @returns {Array} Returns the new array of picked elements. | * @returns {Array} Returns the picked elements. | |
*/ | */ | |
function baseAt(object, paths) { | function baseAt(object, paths) { | |
var index = -1, | var index = -1, | |
isNil = object == null, | ||
length = paths.length, | length = paths.length, | |
result = Array(length); | result = Array(length), | |
skip = object == null; | ||
while (++index < length) { | while (++index < length) { | |
result[index] = isNil ? undefined : get(object, paths[index]); | result[index] = skip ? undefined : get(object, paths[index]); | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.clamp` which doesn't coerce arguments to nu mbers. | * The base implementation of `_.clamp` which doesn't coerce arguments. | |
* | * | |
* @private | * @private | |
* @param {number} number The number to clamp. | * @param {number} number The number to clamp. | |
* @param {number} [lower] The lower bound. | * @param {number} [lower] The lower bound. | |
* @param {number} upper The upper bound. | * @param {number} upper The upper bound. | |
* @returns {number} Returns the clamped number. | * @returns {number} Returns the clamped number. | |
*/ | */ | |
function baseClamp(number, lower, upper) { | function baseClamp(number, lower, upper) { | |
if (number === number) { | if (number === number) { | |
if (upper !== undefined) { | if (upper !== undefined) { | |
skipping to change at line 2180 | skipping to change at line 2652 | |
} | } | |
return number; | return number; | |
} | } | |
/** | /** | |
* The base implementation of `_.clone` and `_.cloneDeep` which tracks | * The base implementation of `_.clone` and `_.cloneDeep` which tracks | |
* traversed objects. | * traversed objects. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to clone. | * @param {*} value The value to clone. | |
* @param {boolean} [isDeep] Specify a deep clone. | * @param {boolean} bitmask The bitmask flags. | |
* 1 - Deep clone | ||
* 2 - Flatten inherited properties | ||
* 4 - Clone symbols | ||
* @param {Function} [customizer] The function to customize cloning. | * @param {Function} [customizer] The function to customize cloning. | |
* @param {string} [key] The key of `value`. | * @param {string} [key] The key of `value`. | |
* @param {Object} [object] The parent object of `value`. | * @param {Object} [object] The parent object of `value`. | |
* @param {Object} [stack] Tracks traversed objects and their clone counterp arts. | * @param {Object} [stack] Tracks traversed objects and their clone counterp arts. | |
* @returns {*} Returns the cloned value. | * @returns {*} Returns the cloned value. | |
*/ | */ | |
function baseClone(value, isDeep, customizer, key, object, stack) { | function baseClone(value, bitmask, customizer, key, object, stack) { | |
var result; | var result, | |
isDeep = bitmask & CLONE_DEEP_FLAG, | ||
isFlat = bitmask & CLONE_FLAT_FLAG, | ||
isFull = bitmask & CLONE_SYMBOLS_FLAG; | ||
if (customizer) { | if (customizer) { | |
result = object ? customizer(value, key, object, stack) : customizer(val ue); | result = object ? customizer(value, key, object, stack) : customizer(val ue); | |
} | } | |
if (result !== undefined) { | if (result !== undefined) { | |
return result; | return result; | |
} | } | |
if (!isObject(value)) { | if (!isObject(value)) { | |
return value; | return value; | |
} | } | |
var isArr = isArray(value); | var isArr = isArray(value); | |
if (isArr) { | if (isArr) { | |
result = initCloneArray(value); | result = initCloneArray(value); | |
if (!isDeep) { | if (!isDeep) { | |
return copyArray(value, result); | return copyArray(value, result); | |
} | } | |
} else { | } else { | |
var tag = getTag(value), | var tag = getTag(value), | |
isFunc = tag == funcTag || tag == genTag; | isFunc = tag == funcTag || tag == genTag; | |
if (isBuffer(value)) { | ||
return cloneBuffer(value, isDeep); | ||
} | ||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) { | if (tag == objectTag || tag == argsTag || (isFunc && !object)) { | |
if (isHostObject(value)) { | result = (isFlat || isFunc) ? {} : initCloneObject(value); | |
return object ? value : {}; | ||
} | ||
result = initCloneObject(isFunc ? {} : value); | ||
if (!isDeep) { | if (!isDeep) { | |
return copySymbols(value, baseAssign(result, value)); | return isFlat | |
? copySymbolsIn(value, baseAssignIn(result, value)) | ||
: copySymbols(value, baseAssign(result, value)); | ||
} | } | |
} else { | } else { | |
return cloneableTags[tag] | if (!cloneableTags[tag]) { | |
? initCloneByTag(value, tag, isDeep) | return object ? value : {}; | |
: (object ? value : {}); | } | |
result = initCloneByTag(value, tag, isDeep); | ||
} | } | |
} | } | |
// Check for circular references and return its corresponding clone. | // Check for circular references and return its corresponding clone. | |
stack || (stack = new Stack); | stack || (stack = new Stack); | |
var stacked = stack.get(value); | var stacked = stack.get(value); | |
if (stacked) { | if (stacked) { | |
return stacked; | return stacked; | |
} | } | |
stack.set(value, result); | stack.set(value, result); | |
// Recursively populate clone (susceptible to call stack limits). | if (isSet(value)) { | |
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { | value.forEach(function(subValue) { | |
assignValue(result, key, baseClone(subValue, isDeep, customizer, key, va | result.add(baseClone(subValue, bitmask, customizer, subValue, value, s | |
lue, stack)); | tack)); | |
}); | ||
} else if (isMap(value)) { | ||
value.forEach(function(subValue, key) { | ||
result.set(key, baseClone(subValue, bitmask, customizer, key, value, s | ||
tack)); | ||
}); | ||
} | ||
var keysFunc = isFull | ||
? (isFlat ? getAllKeysIn : getAllKeys) | ||
: (isFlat ? keysIn : keys); | ||
var props = isArr ? undefined : keysFunc(value); | ||
arrayEach(props || value, function(subValue, key) { | ||
if (props) { | ||
key = subValue; | ||
subValue = value[key]; | ||
} | ||
// Recursively populate clone (susceptible to call stack limits). | ||
assignValue(result, key, baseClone(subValue, bitmask, customizer, key, v | ||
alue, stack)); | ||
}); | }); | |
return isArr ? result : copySymbols(value, result); | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.conforms` which doesn't clone `source`. | * The base implementation of `_.conforms` which doesn't clone `source`. | |
* | * | |
* @private | * @private | |
* @param {Object} source The object of property predicates to conform to. | * @param {Object} source The object of property predicates to conform to. | |
* @returns {Function} Returns the new function. | * @returns {Function} Returns the new spec function. | |
*/ | */ | |
function baseConforms(source) { | function baseConforms(source) { | |
var props = keys(source), | var props = keys(source); | |
length = props.length; | ||
return function(object) { | return function(object) { | |
if (object == null) { | return baseConformsTo(object, source, props); | |
return !length; | ||
} | ||
var index = length; | ||
while (index--) { | ||
var key = props[index], | ||
predicate = source[key], | ||
value = object[key]; | ||
if ((value === undefined && !(key in Object(object))) || !predicate(va | ||
lue)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | }; | |
} | } | |
/** | /** | |
* The base implementation of `_.create` without support for assigning | * The base implementation of `_.conformsTo` which accepts `props` to check. | |
* properties to the created object. | ||
* | * | |
* @private | * @private | |
* @param {Object} prototype The object to inherit from. | * @param {Object} object The object to inspect. | |
* @returns {Object} Returns the new object. | * @param {Object} source The object of property predicates to conform to. | |
* @returns {boolean} Returns `true` if `object` conforms, else `false`. | ||
*/ | */ | |
var baseCreate = (function() { | function baseConformsTo(object, source, props) { | |
function object() {} | var length = props.length; | |
return function(prototype) { | if (object == null) { | |
if (isObject(prototype)) { | return !length; | |
object.prototype = prototype; | } | |
var result = new object; | object = Object(object); | |
object.prototype = undefined; | while (length--) { | |
var key = props[length], | ||
predicate = source[key], | ||
value = object[key]; | ||
if ((value === undefined && !(key in object)) || !predicate(value)) { | ||
return false; | ||
} | } | |
return result || {}; | } | |
}; | return true; | |
}()); | } | |
/** | /** | |
* The base implementation of `_.delay` and `_.defer` which accepts an array | * The base implementation of `_.delay` and `_.defer` which accepts `args` | |
* of `func` arguments. | * to provide to `func`. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to delay. | * @param {Function} func The function to delay. | |
* @param {number} wait The number of milliseconds to delay invocation. | * @param {number} wait The number of milliseconds to delay invocation. | |
* @param {Object} args The arguments provide to `func`. | * @param {Array} args The arguments to provide to `func`. | |
* @returns {number} Returns the timer id. | * @returns {number|Object} Returns the timer id or timeout object. | |
*/ | */ | |
function baseDelay(func, wait, args) { | function baseDelay(func, wait, args) { | |
if (typeof func != 'function') { | if (typeof func != 'function') { | |
throw new TypeError(FUNC_ERROR_TEXT); | throw new TypeError(FUNC_ERROR_TEXT); | |
} | } | |
return setTimeout(function() { func.apply(undefined, args); }, wait); | return setTimeout(function() { func.apply(undefined, args); }, wait); | |
} | } | |
/** | /** | |
* The base implementation of methods like `_.difference` without support fo | * The base implementation of methods like `_.difference` without support | |
r | * for excluding multiple arrays or iteratee shorthands. | |
* excluding multiple arrays or iteratee shorthands. | ||
* | * | |
* @private | * @private | |
* @param {Array} array The array to inspect. | * @param {Array} array The array to inspect. | |
* @param {Array} values The values to exclude. | * @param {Array} values The values to exclude. | |
* @param {Function} [iteratee] The iteratee invoked per element. | * @param {Function} [iteratee] The iteratee invoked per element. | |
* @param {Function} [comparator] The comparator invoked per element. | * @param {Function} [comparator] The comparator invoked per element. | |
* @returns {Array} Returns the new array of filtered values. | * @returns {Array} Returns the new array of filtered values. | |
*/ | */ | |
function baseDifference(array, values, iteratee, comparator) { | function baseDifference(array, values, iteratee, comparator) { | |
var index = -1, | var index = -1, | |
skipping to change at line 2340 | skipping to change at line 2832 | |
isCommon = false; | isCommon = false; | |
} | } | |
else if (values.length >= LARGE_ARRAY_SIZE) { | else if (values.length >= LARGE_ARRAY_SIZE) { | |
includes = cacheHas; | includes = cacheHas; | |
isCommon = false; | isCommon = false; | |
values = new SetCache(values); | values = new SetCache(values); | |
} | } | |
outer: | outer: | |
while (++index < length) { | while (++index < length) { | |
var value = array[index], | var value = array[index], | |
computed = iteratee ? iteratee(value) : value; | computed = iteratee == null ? value : iteratee(value); | |
value = (comparator || value !== 0) ? value : 0; | ||
if (isCommon && computed === computed) { | if (isCommon && computed === computed) { | |
var valuesIndex = valuesLength; | var valuesIndex = valuesLength; | |
while (valuesIndex--) { | while (valuesIndex--) { | |
if (values[valuesIndex] === computed) { | if (values[valuesIndex] === computed) { | |
continue outer; | continue outer; | |
} | } | |
} | } | |
result.push(value); | result.push(value); | |
} | } | |
else if (!includes(values, computed, comparator)) { | else if (!includes(values, computed, comparator)) { | |
skipping to change at line 2384 | skipping to change at line 2877 | |
* @returns {Array|Object} Returns `collection`. | * @returns {Array|Object} Returns `collection`. | |
*/ | */ | |
var baseEachRight = createBaseEach(baseForOwnRight, true); | var baseEachRight = createBaseEach(baseForOwnRight, true); | |
/** | /** | |
* The base implementation of `_.every` without support for iteratee shortha nds. | * The base implementation of `_.every` without support for iteratee shortha nds. | |
* | * | |
* @private | * @private | |
* @param {Array|Object} collection The collection to iterate over. | * @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | * @param {Function} predicate The function invoked per iteration. | |
* @returns {boolean} Returns `true` if all elements pass the predicate chec | * @returns {boolean} Returns `true` if all elements pass the predicate chec | |
k, else `false` | k, | |
* else `false` | ||
*/ | */ | |
function baseEvery(collection, predicate) { | function baseEvery(collection, predicate) { | |
var result = true; | var result = true; | |
baseEach(collection, function(value, index, collection) { | baseEach(collection, function(value, index, collection) { | |
result = !!predicate(value, index, collection); | result = !!predicate(value, index, collection); | |
return result; | return result; | |
}); | }); | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of methods like `_.max` and `_.min` which accepts | ||
a | ||
* `comparator` to determine the extremum value. | ||
* | ||
* @private | ||
* @param {Array} array The array to iterate over. | ||
* @param {Function} iteratee The iteratee invoked per iteration. | ||
* @param {Function} comparator The comparator used to compare values. | ||
* @returns {*} Returns the extremum value. | ||
*/ | ||
function baseExtremum(array, iteratee, comparator) { | ||
var index = -1, | ||
length = array.length; | ||
while (++index < length) { | ||
var value = array[index], | ||
current = iteratee(value); | ||
if (current != null && (computed === undefined | ||
? (current === current && !isSymbol(current)) | ||
: comparator(current, computed) | ||
)) { | ||
var computed = current, | ||
result = value; | ||
} | ||
} | ||
return result; | ||
} | ||
/** | ||
* The base implementation of `_.fill` without an iteratee call guard. | * The base implementation of `_.fill` without an iteratee call guard. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to fill. | * @param {Array} array The array to fill. | |
* @param {*} value The value to fill `array` with. | * @param {*} value The value to fill `array` with. | |
* @param {number} [start=0] The start position. | * @param {number} [start=0] The start position. | |
* @param {number} [end=array.length] The end position. | * @param {number} [end=array.length] The end position. | |
* @returns {Array} Returns `array`. | * @returns {Array} Returns `array`. | |
*/ | */ | |
function baseFill(array, value, start, end) { | function baseFill(array, value, start, end) { | |
skipping to change at line 2446 | skipping to change at line 2969 | |
} | } | |
}); | }); | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.flatten` with support for restricting flatt ening. | * The base implementation of `_.flatten` with support for restricting flatt ening. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to flatten. | * @param {Array} array The array to flatten. | |
* @param {boolean} [isDeep] Specify a deep flatten. | * @param {number} depth The maximum recursion depth. | |
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects. | * @param {boolean} [predicate=isFlattenable] The function invoked per itera | |
tion. | ||
* @param {boolean} [isStrict] Restrict to values that pass `predicate` chec | ||
ks. | ||
* @param {Array} [result=[]] The initial result value. | * @param {Array} [result=[]] The initial result value. | |
* @returns {Array} Returns the new flattened array. | * @returns {Array} Returns the new flattened array. | |
*/ | */ | |
function baseFlatten(array, isDeep, isStrict, result) { | function baseFlatten(array, depth, predicate, isStrict, result) { | |
result || (result = []); | ||
var index = -1, | var index = -1, | |
length = array.length; | length = array.length; | |
predicate || (predicate = isFlattenable); | ||
result || (result = []); | ||
while (++index < length) { | while (++index < length) { | |
var value = array[index]; | var value = array[index]; | |
if (isArrayLikeObject(value) && | if (depth > 0 && predicate(value)) { | |
(isStrict || isArray(value) || isArguments(value))) { | if (depth > 1) { | |
if (isDeep) { | ||
// Recursively flatten arrays (susceptible to call stack limits). | // Recursively flatten arrays (susceptible to call stack limits). | |
baseFlatten(value, isDeep, isStrict, result); | baseFlatten(value, depth - 1, predicate, isStrict, result); | |
} else { | } else { | |
arrayPush(result, value); | arrayPush(result, value); | |
} | } | |
} else if (!isStrict) { | } else if (!isStrict) { | |
result[result.length] = value; | result[result.length] = value; | |
} | } | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `baseForIn` and `baseForOwn` which iterates | * The base implementation of `baseForOwn` which iterates over `object` | |
* over `object` properties returned by `keysFunc` invoking `iteratee` for | * properties returned by `keysFunc` and invokes `iteratee` for each propert | |
* each property. Iteratee functions may exit iteration early by explicitly | y. | |
* returning `false`. | * Iteratee functions may exit iteration early by explicitly returning `fals | |
e`. | ||
* | * | |
* @private | * @private | |
* @param {Object} object The object to iterate over. | * @param {Object} object The object to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @param {Function} keysFunc The function to get the keys of `object`. | * @param {Function} keysFunc The function to get the keys of `object`. | |
* @returns {Object} Returns `object`. | * @returns {Object} Returns `object`. | |
*/ | */ | |
var baseFor = createBaseFor(); | var baseFor = createBaseFor(); | |
/** | /** | |
skipping to change at line 2501 | skipping to change at line 3024 | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to iterate over. | * @param {Object} object The object to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @param {Function} keysFunc The function to get the keys of `object`. | * @param {Function} keysFunc The function to get the keys of `object`. | |
* @returns {Object} Returns `object`. | * @returns {Object} Returns `object`. | |
*/ | */ | |
var baseForRight = createBaseFor(true); | var baseForRight = createBaseFor(true); | |
/** | /** | |
* The base implementation of `_.forIn` without support for iteratee shortha | ||
nds. | ||
* | ||
* @private | ||
* @param {Object} object The object to iterate over. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function baseForIn(object, iteratee) { | ||
return object == null ? object : baseFor(object, iteratee, keysIn); | ||
} | ||
/** | ||
* The base implementation of `_.forOwn` without support for iteratee shorth ands. | * The base implementation of `_.forOwn` without support for iteratee shorth ands. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to iterate over. | * @param {Object} object The object to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @returns {Object} Returns `object`. | * @returns {Object} Returns `object`. | |
*/ | */ | |
function baseForOwn(object, iteratee) { | function baseForOwn(object, iteratee) { | |
return object && baseFor(object, iteratee, keys); | return object && baseFor(object, iteratee, keys); | |
} | } | |
skipping to change at line 2538 | skipping to change at line 3049 | |
* @param {Object} object The object to iterate over. | * @param {Object} object The object to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @returns {Object} Returns `object`. | * @returns {Object} Returns `object`. | |
*/ | */ | |
function baseForOwnRight(object, iteratee) { | function baseForOwnRight(object, iteratee) { | |
return object && baseForRight(object, iteratee, keys); | return object && baseForRight(object, iteratee, keys); | |
} | } | |
/** | /** | |
* The base implementation of `_.functions` which creates an array of | * The base implementation of `_.functions` which creates an array of | |
* `object` function property names filtered from those provided. | * `object` function property names filtered from `props`. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to inspect. | * @param {Object} object The object to inspect. | |
* @param {Array} props The property names to filter. | * @param {Array} props The property names to filter. | |
* @returns {Array} Returns the new array of filtered property names. | * @returns {Array} Returns the function names. | |
*/ | */ | |
function baseFunctions(object, props) { | function baseFunctions(object, props) { | |
return arrayFilter(props, function(key) { | return arrayFilter(props, function(key) { | |
return isFunction(object[key]); | return isFunction(object[key]); | |
}); | }); | |
} | } | |
/** | /** | |
* The base implementation of `_.get` without support for default values. | * The base implementation of `_.get` without support for default values. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @param {Array|string} path The path of the property to get. | * @param {Array|string} path The path of the property to get. | |
* @returns {*} Returns the resolved value. | * @returns {*} Returns the resolved value. | |
*/ | */ | |
function baseGet(object, path) { | function baseGet(object, path) { | |
path = isKey(path, object) ? [path + ''] : baseToPath(path); | path = castPath(path, object); | |
var index = 0, | var index = 0, | |
length = path.length; | length = path.length; | |
while (object != null && index < length) { | while (object != null && index < length) { | |
object = object[path[index++]]; | object = object[toKey(path[index++])]; | |
} | } | |
return (index && index == length) ? object : undefined; | return (index && index == length) ? object : undefined; | |
} | } | |
/** | /** | |
* The base implementation of `_.has` without support for deep paths. | * The base implementation of `getAllKeys` and `getAllKeysIn` which uses | |
* `keysFunc` and `symbolsFunc` to get the enumerable property names and | ||
* symbols of `object`. | ||
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @param {Function} keysFunc The function to get the keys of `object`. | ||
* @param {Function} symbolsFunc The function to get the symbols of `object` | ||
. | ||
* @returns {Array} Returns the array of property names and symbols. | ||
*/ | ||
function baseGetAllKeys(object, keysFunc, symbolsFunc) { | ||
var result = keysFunc(object); | ||
return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); | ||
} | ||
/** | ||
* The base implementation of `getTag` without fallbacks for buggy environme | ||
nts. | ||
* | ||
* @private | ||
* @param {*} value The value to query. | ||
* @returns {string} Returns the `toStringTag`. | ||
*/ | ||
function baseGetTag(value) { | ||
if (value == null) { | ||
return value === undefined ? undefinedTag : nullTag; | ||
} | ||
return (symToStringTag && symToStringTag in Object(value)) | ||
? getRawTag(value) | ||
: objectToString(value); | ||
} | ||
/** | ||
* The base implementation of `_.gt` which doesn't coerce arguments. | ||
* | ||
* @private | ||
* @param {*} value The value to compare. | ||
* @param {*} other The other value to compare. | ||
* @returns {boolean} Returns `true` if `value` is greater than `other`, | ||
* else `false`. | ||
*/ | ||
function baseGt(value, other) { | ||
return value > other; | ||
} | ||
/** | ||
* The base implementation of `_.has` without support for deep paths. | ||
* | ||
* @private | ||
* @param {Object} [object] The object to query. | ||
* @param {Array|string} key The key to check. | * @param {Array|string} key The key to check. | |
* @returns {boolean} Returns `true` if `key` exists, else `false`. | * @returns {boolean} Returns `true` if `key` exists, else `false`. | |
*/ | */ | |
function baseHas(object, key) { | function baseHas(object, key) { | |
// Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`, | return object != null && hasOwnProperty.call(object, key); | |
// that are composed entirely of index properties, return `false` for | ||
// `hasOwnProperty` checks of them. | ||
return hasOwnProperty.call(object, key) || | ||
(typeof object == 'object' && key in object && getPrototypeOf(object) == | ||
= null); | ||
} | } | |
/** | /** | |
* The base implementation of `_.hasIn` without support for deep paths. | * The base implementation of `_.hasIn` without support for deep paths. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} [object] The object to query. | |
* @param {Array|string} key The key to check. | * @param {Array|string} key The key to check. | |
* @returns {boolean} Returns `true` if `key` exists, else `false`. | * @returns {boolean} Returns `true` if `key` exists, else `false`. | |
*/ | */ | |
function baseHasIn(object, key) { | function baseHasIn(object, key) { | |
return key in Object(object); | return object != null && key in Object(object); | |
} | } | |
/** | /** | |
* The base implementation of `_.inRange` which doesn't coerce arguments to numbers. | * The base implementation of `_.inRange` which doesn't coerce arguments. | |
* | * | |
* @private | * @private | |
* @param {number} number The number to check. | * @param {number} number The number to check. | |
* @param {number} start The start of the range. | * @param {number} start The start of the range. | |
* @param {number} end The end of the range. | * @param {number} end The end of the range. | |
* @returns {boolean} Returns `true` if `number` is in the range, else `fals e`. | * @returns {boolean} Returns `true` if `number` is in the range, else `fals e`. | |
*/ | */ | |
function baseInRange(number, start, end) { | function baseInRange(number, start, end) { | |
return number >= nativeMin(start, end) && number < nativeMax(start, end); | return number >= nativeMin(start, end) && number < nativeMax(start, end); | |
} | } | |
skipping to change at line 2624 | skipping to change at line 3176 | |
* for iteratee shorthands, that accepts an array of arrays to inspect. | * for iteratee shorthands, that accepts an array of arrays to inspect. | |
* | * | |
* @private | * @private | |
* @param {Array} arrays The arrays to inspect. | * @param {Array} arrays The arrays to inspect. | |
* @param {Function} [iteratee] The iteratee invoked per element. | * @param {Function} [iteratee] The iteratee invoked per element. | |
* @param {Function} [comparator] The comparator invoked per element. | * @param {Function} [comparator] The comparator invoked per element. | |
* @returns {Array} Returns the new array of shared values. | * @returns {Array} Returns the new array of shared values. | |
*/ | */ | |
function baseIntersection(arrays, iteratee, comparator) { | function baseIntersection(arrays, iteratee, comparator) { | |
var includes = comparator ? arrayIncludesWith : arrayIncludes, | var includes = comparator ? arrayIncludesWith : arrayIncludes, | |
length = arrays[0].length, | ||
othLength = arrays.length, | othLength = arrays.length, | |
othIndex = othLength, | othIndex = othLength, | |
caches = Array(othLength), | caches = Array(othLength), | |
maxLength = Infinity, | ||
result = []; | result = []; | |
while (othIndex--) { | while (othIndex--) { | |
var array = arrays[othIndex]; | var array = arrays[othIndex]; | |
if (othIndex && iteratee) { | if (othIndex && iteratee) { | |
array = arrayMap(array, baseUnary(iteratee)); | array = arrayMap(array, baseUnary(iteratee)); | |
} | } | |
caches[othIndex] = !comparator && (iteratee || array.length >= 120) | maxLength = nativeMin(array.length, maxLength); | |
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.l | ||
ength >= 120)) | ||
? new SetCache(othIndex && array) | ? new SetCache(othIndex && array) | |
: undefined; | : undefined; | |
} | } | |
array = arrays[0]; | array = arrays[0]; | |
var index = -1, | var index = -1, | |
length = array.length, | ||
seen = caches[0]; | seen = caches[0]; | |
outer: | outer: | |
while (++index < length) { | while (++index < length && result.length < maxLength) { | |
var value = array[index], | var value = array[index], | |
computed = iteratee ? iteratee(value) : value; | computed = iteratee ? iteratee(value) : value; | |
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, compa | value = (comparator || value !== 0) ? value : 0; | |
rator))) { | if (!(seen | |
var othIndex = othLength; | ? cacheHas(seen, computed) | |
: includes(result, computed, comparator) | ||
)) { | ||
othIndex = othLength; | ||
while (--othIndex) { | while (--othIndex) { | |
var cache = caches[othIndex]; | var cache = caches[othIndex]; | |
if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], | if (!(cache | |
computed, comparator))) { | ? cacheHas(cache, computed) | |
: includes(arrays[othIndex], computed, comparator)) | ||
) { | ||
continue outer; | continue outer; | |
} | } | |
} | } | |
if (seen) { | if (seen) { | |
seen.push(computed); | seen.push(computed); | |
} | } | |
result.push(value); | result.push(value); | |
} | } | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.invert` and `_.invertBy` which inverts | ||
* `object` with values transformed by `iteratee` and set by `setter`. | ||
* | ||
* @private | ||
* @param {Object} object The object to iterate over. | ||
* @param {Function} setter The function to set `accumulator` values. | ||
* @param {Function} iteratee The iteratee to transform values. | ||
* @param {Object} accumulator The initial inverted object. | ||
* @returns {Function} Returns `accumulator`. | ||
*/ | ||
function baseInverter(object, setter, iteratee, accumulator) { | ||
baseForOwn(object, function(value, key, object) { | ||
setter(accumulator, iteratee(value), key, object); | ||
}); | ||
return accumulator; | ||
} | ||
/** | ||
* The base implementation of `_.invoke` without support for individual | * The base implementation of `_.invoke` without support for individual | |
* method arguments. | * method arguments. | |
* | * | |
* | ||
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @param {Array|string} path The path of the method to invoke. | * @param {Array|string} path The path of the method to invoke. | |
* @param {Array} args The arguments to invoke the method with. | * @param {Array} args The arguments to invoke the method with. | |
* @returns {*} Returns the result of the invoked method. | * @returns {*} Returns the result of the invoked method. | |
*/ | */ | |
function baseInvoke(object, path, args) { | function baseInvoke(object, path, args) { | |
if (!isKey(path, object)) { | path = castPath(path, object); | |
path = baseToPath(path); | object = parent(object, path); | |
object = parent(object, path); | var func = object == null ? object : object[toKey(last(path))]; | |
path = last(path); | ||
} | ||
var func = object == null ? object : object[path]; | ||
return func == null ? undefined : apply(func, object, args); | return func == null ? undefined : apply(func, object, args); | |
} | } | |
/** | /** | |
* The base implementation of `_.isArguments`. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an `arguments` object, | ||
*/ | ||
function baseIsArguments(value) { | ||
return isObjectLike(value) && baseGetTag(value) == argsTag; | ||
} | ||
/** | ||
* The base implementation of `_.isArrayBuffer` without Node.js optimization | ||
s. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an array buffer, else `fa | ||
lse`. | ||
*/ | ||
function baseIsArrayBuffer(value) { | ||
return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; | ||
} | ||
/** | ||
* The base implementation of `_.isDate` without Node.js optimizations. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a date object, else `fals | ||
e`. | ||
*/ | ||
function baseIsDate(value) { | ||
return isObjectLike(value) && baseGetTag(value) == dateTag; | ||
} | ||
/** | ||
* The base implementation of `_.isEqual` which supports partial comparisons | * The base implementation of `_.isEqual` which supports partial comparisons | |
* and tracks traversed objects. | * and tracks traversed objects. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to compare. | * @param {*} value The value to compare. | |
* @param {*} other The other value to compare. | * @param {*} other The other value to compare. | |
* @param {boolean} bitmask The bitmask flags. | ||
* 1 - Unordered comparison | ||
* 2 - Partial comparison | ||
* @param {Function} [customizer] The function to customize comparisons. | * @param {Function} [customizer] The function to customize comparisons. | |
* @param {boolean} [bitmask] The bitmask of comparison flags. | ||
* The bitmask may be composed of the following flags: | ||
* 1 - Unordered comparison | ||
* 2 - Partial comparison | ||
* @param {Object} [stack] Tracks traversed `value` and `other` objects. | * @param {Object} [stack] Tracks traversed `value` and `other` objects. | |
* @returns {boolean} Returns `true` if the values are equivalent, else `fal se`. | * @returns {boolean} Returns `true` if the values are equivalent, else `fal se`. | |
*/ | */ | |
function baseIsEqual(value, other, customizer, bitmask, stack) { | function baseIsEqual(value, other, bitmask, customizer, stack) { | |
if (value === other) { | if (value === other) { | |
return true; | return true; | |
} | } | |
if (value == null || other == null || (!isObject(value) && !isObjectLike(o ther))) { | if (value == null || other == null || (!isObjectLike(value) && !isObjectLi ke(other))) { | |
return value !== value && other !== other; | return value !== value && other !== other; | |
} | } | |
return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, sta ck); | return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, sta ck); | |
} | } | |
/** | /** | |
* A specialized version of `baseIsEqual` for arrays and objects which perfo rms | * A specialized version of `baseIsEqual` for arrays and objects which perfo rms | |
* deep comparisons and tracks traversed objects enabling objects with circu lar | * deep comparisons and tracks traversed objects enabling objects with circu lar | |
* references to be compared. | * references to be compared. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to compare. | * @param {Object} object The object to compare. | |
* @param {Object} other The other object to compare. | * @param {Object} other The other object to compare. | |
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more det | ||
ails. | ||
* @param {Function} customizer The function to customize comparisons. | ||
* @param {Function} equalFunc The function to determine equivalents of valu es. | * @param {Function} equalFunc The function to determine equivalents of valu es. | |
* @param {Function} [customizer] The function to customize comparisons. | ||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqu | ||
al` for more details. | ||
* @param {Object} [stack] Tracks traversed `object` and `other` objects. | * @param {Object} [stack] Tracks traversed `object` and `other` objects. | |
* @returns {boolean} Returns `true` if the objects are equivalent, else `fa lse`. | * @returns {boolean} Returns `true` if the objects are equivalent, else `fa lse`. | |
*/ | */ | |
function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stac k) { | function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stac k) { | |
var objIsArr = isArray(object), | var objIsArr = isArray(object), | |
othIsArr = isArray(other), | othIsArr = isArray(other), | |
objTag = arrayTag, | objTag = objIsArr ? arrayTag : getTag(object), | |
othTag = arrayTag; | othTag = othIsArr ? arrayTag : getTag(other); | |
if (!objIsArr) { | objTag = objTag == argsTag ? objectTag : objTag; | |
objTag = getTag(object); | othTag = othTag == argsTag ? objectTag : othTag; | |
if (objTag == argsTag) { | ||
objTag = objectTag; | var objIsObj = objTag == objectTag, | |
} else if (objTag != objectTag) { | othIsObj = othTag == objectTag, | |
objIsArr = isTypedArray(object); | ||
} | ||
} | ||
if (!othIsArr) { | ||
othTag = getTag(other); | ||
if (othTag == argsTag) { | ||
othTag = objectTag; | ||
} else if (othTag != objectTag) { | ||
othIsArr = isTypedArray(other); | ||
} | ||
} | ||
var objIsObj = objTag == objectTag && !isHostObject(object), | ||
othIsObj = othTag == objectTag && !isHostObject(other), | ||
isSameTag = objTag == othTag; | isSameTag = objTag == othTag; | |
if (isSameTag && !(objIsArr || objIsObj)) { | if (isSameTag && isBuffer(object)) { | |
return equalByTag(object, other, objTag, equalFunc, customizer, bitmask) | if (!isBuffer(other)) { | |
; | return false; | |
} | ||
objIsArr = true; | ||
objIsObj = false; | ||
} | } | |
var isPartial = bitmask & PARTIAL_COMPARE_FLAG; | if (isSameTag && !objIsObj) { | |
if (!isPartial) { | stack || (stack = new Stack); | |
return (objIsArr || isTypedArray(object)) | ||
? equalArrays(object, other, bitmask, customizer, equalFunc, stack) | ||
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, st | ||
ack); | ||
} | ||
if (!(bitmask & COMPARE_PARTIAL_FLAG)) { | ||
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__' ), | var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__' ), | |
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__') ; | othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__') ; | |
if (objIsWrapped || othIsWrapped) { | if (objIsWrapped || othIsWrapped) { | |
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped | var objUnwrapped = objIsWrapped ? object.value() : object, | |
? other.value() : other, customizer, bitmask, stack); | othUnwrapped = othIsWrapped ? other.value() : other; | |
stack || (stack = new Stack); | ||
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stac | ||
k); | ||
} | } | |
} | } | |
if (!isSameTag) { | if (!isSameTag) { | |
return false; | return false; | |
} | } | |
stack || (stack = new Stack); | stack || (stack = new Stack); | |
return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, c | return equalObjects(object, other, bitmask, customizer, equalFunc, stack); | |
ustomizer, bitmask, stack); | } | |
/** | ||
* The base implementation of `_.isMap` without Node.js optimizations. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a map, else `false`. | ||
*/ | ||
function baseIsMap(value) { | ||
return isObjectLike(value) && getTag(value) == mapTag; | ||
} | } | |
/** | /** | |
* The base implementation of `_.isMatch` without support for iteratee short hands. | * The base implementation of `_.isMatch` without support for iteratee short hands. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to inspect. | * @param {Object} object The object to inspect. | |
* @param {Object} source The object of property values to match. | * @param {Object} source The object of property values to match. | |
* @param {Array} matchData The property names, values, and compare flags to match. | * @param {Array} matchData The property names, values, and compare flags to match. | |
* @param {Function} [customizer] The function to customize comparisons. | * @param {Function} [customizer] The function to customize comparisons. | |
skipping to change at line 2810 | skipping to change at line 3428 | |
data = matchData[index]; | data = matchData[index]; | |
var key = data[0], | var key = data[0], | |
objValue = object[key], | objValue = object[key], | |
srcValue = data[1]; | srcValue = data[1]; | |
if (noCustomizer && data[2]) { | if (noCustomizer && data[2]) { | |
if (objValue === undefined && !(key in object)) { | if (objValue === undefined && !(key in object)) { | |
return false; | return false; | |
} | } | |
} else { | } else { | |
var stack = new Stack, | var stack = new Stack; | |
result = customizer ? customizer(objValue, srcValue, key, object, | if (customizer) { | |
source, stack) : undefined; | var result = customizer(objValue, srcValue, key, object, source, sta | |
ck); | ||
if (!(result === undefined ? baseIsEqual(srcValue, objValue, customize | } | |
r, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) { | if (!(result === undefined | |
? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE | ||
_UNORDERED_FLAG, customizer, stack) | ||
: result | ||
)) { | ||
return false; | return false; | |
} | } | |
} | } | |
} | } | |
return true; | return true; | |
} | } | |
/** | /** | |
* The base implementation of `_.isNative` without bad shim checks. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a native function, | ||
* else `false`. | ||
*/ | ||
function baseIsNative(value) { | ||
if (!isObject(value) || isMasked(value)) { | ||
return false; | ||
} | ||
var pattern = isFunction(value) ? reIsNative : reIsHostCtor; | ||
return pattern.test(toSource(value)); | ||
} | ||
/** | ||
* The base implementation of `_.isRegExp` without Node.js optimizations. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`. | ||
*/ | ||
function baseIsRegExp(value) { | ||
return isObjectLike(value) && baseGetTag(value) == regexpTag; | ||
} | ||
/** | ||
* The base implementation of `_.isSet` without Node.js optimizations. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a set, else `false`. | ||
*/ | ||
function baseIsSet(value) { | ||
return isObjectLike(value) && getTag(value) == setTag; | ||
} | ||
/** | ||
* The base implementation of `_.isTypedArray` without Node.js optimizations | ||
. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a typed array, else `fals | ||
e`. | ||
*/ | ||
function baseIsTypedArray(value) { | ||
return isObjectLike(value) && | ||
isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; | ||
} | ||
/** | ||
* The base implementation of `_.iteratee`. | * The base implementation of `_.iteratee`. | |
* | * | |
* @private | * @private | |
* @param {*} [value=_.identity] The value to convert to an iteratee. | * @param {*} [value=_.identity] The value to convert to an iteratee. | |
* @returns {Function} Returns the iteratee. | * @returns {Function} Returns the iteratee. | |
*/ | */ | |
function baseIteratee(value) { | function baseIteratee(value) { | |
var type = typeof value; | // Don't store the `typeof` result in a variable to avoid a JIT bug in Saf | |
if (type == 'function') { | ari 9. | |
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. | ||
if (typeof value == 'function') { | ||
return value; | return value; | |
} | } | |
if (value == null) { | if (value == null) { | |
return identity; | return identity; | |
} | } | |
if (type == 'object') { | if (typeof value == 'object') { | |
return isArray(value) | return isArray(value) | |
? baseMatchesProperty(value[0], value[1]) | ? baseMatchesProperty(value[0], value[1]) | |
: baseMatches(value); | : baseMatches(value); | |
} | } | |
return property(value); | return property(value); | |
} | } | |
/** | /** | |
* The base implementation of `_.keys` which doesn't skip the constructor | * The base implementation of `_.keys` which doesn't treat sparse arrays as | |
* property of prototypes or treat sparse arrays as dense. | dense. | |
* | * | |
* @private | * @private | |
* @type Function | ||
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @returns {Array} Returns the array of property names. | * @returns {Array} Returns the array of property names. | |
*/ | */ | |
function baseKeys(object) { | function baseKeys(object) { | |
return nativeKeys(Object(object)); | if (!isPrototype(object)) { | |
return nativeKeys(object); | ||
} | ||
var result = []; | ||
for (var key in Object(object)) { | ||
if (hasOwnProperty.call(object, key) && key != 'constructor') { | ||
result.push(key); | ||
} | ||
} | ||
return result; | ||
} | } | |
/** | /** | |
* The base implementation of `_.keysIn` which doesn't skip the constructor | * The base implementation of `_.keysIn` which doesn't treat sparse arrays a | |
* property of prototypes or treat sparse arrays as dense. | s dense. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @returns {Array} Returns the array of property names. | * @returns {Array} Returns the array of property names. | |
*/ | */ | |
function baseKeysIn(object) { | function baseKeysIn(object) { | |
object = object == null ? object : Object(object); | if (!isObject(object)) { | |
return nativeKeysIn(object); | ||
} | ||
var isProto = isPrototype(object), | ||
result = []; | ||
var result = []; | ||
for (var key in object) { | for (var key in object) { | |
result.push(key); | if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, k | |
ey)))) { | ||
result.push(key); | ||
} | ||
} | } | |
return result; | return result; | |
} | } | |
// Fallback for IE < 9 with es6-shim. | /** | |
if (enumerate && !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf')) { | * The base implementation of `_.lt` which doesn't coerce arguments. | |
baseKeysIn = function(object) { | * | |
return iteratorToArray(enumerate(object)); | * @private | |
}; | * @param {*} value The value to compare. | |
* @param {*} other The other value to compare. | ||
* @returns {boolean} Returns `true` if `value` is less than `other`, | ||
* else `false`. | ||
*/ | ||
function baseLt(value, other) { | ||
return value < other; | ||
} | } | |
/** | /** | |
* The base implementation of `_.map` without support for iteratee shorthand s. | * The base implementation of `_.map` without support for iteratee shorthand s. | |
* | * | |
* @private | * @private | |
* @param {Array|Object} collection The collection to iterate over. | * @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | * @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array} Returns the new mapped array. | * @returns {Array} Returns the new mapped array. | |
*/ | */ | |
skipping to change at line 2905 | skipping to change at line 3595 | |
result[++index] = iteratee(value, key, collection); | result[++index] = iteratee(value, key, collection); | |
}); | }); | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.matches` which doesn't clone `source`. | * The base implementation of `_.matches` which doesn't clone `source`. | |
* | * | |
* @private | * @private | |
* @param {Object} source The object of property values to match. | * @param {Object} source The object of property values to match. | |
* @returns {Function} Returns the new function. | * @returns {Function} Returns the new spec function. | |
*/ | */ | |
function baseMatches(source) { | function baseMatches(source) { | |
var matchData = getMatchData(source); | var matchData = getMatchData(source); | |
if (matchData.length == 1 && matchData[0][2]) { | if (matchData.length == 1 && matchData[0][2]) { | |
var key = matchData[0][0], | return matchesStrictComparable(matchData[0][0], matchData[0][1]); | |
value = matchData[0][1]; | ||
return function(object) { | ||
if (object == null) { | ||
return false; | ||
} | ||
return object[key] === value && | ||
(value !== undefined || (key in Object(object))); | ||
}; | ||
} | } | |
return function(object) { | return function(object) { | |
return object === source || baseIsMatch(object, source, matchData); | return object === source || baseIsMatch(object, source, matchData); | |
}; | }; | |
} | } | |
/** | /** | |
* The base implementation of `_.matchesProperty` which doesn't clone `srcVa lue`. | * The base implementation of `_.matchesProperty` which doesn't clone `srcVa lue`. | |
* | * | |
* @private | * @private | |
* @param {string} path The path of the property to get. | * @param {string} path The path of the property to get. | |
* @param {*} srcValue The value to match. | * @param {*} srcValue The value to match. | |
* @returns {Function} Returns the new function. | * @returns {Function} Returns the new spec function. | |
*/ | */ | |
function baseMatchesProperty(path, srcValue) { | function baseMatchesProperty(path, srcValue) { | |
if (isKey(path) && isStrictComparable(srcValue)) { | ||
return matchesStrictComparable(toKey(path), srcValue); | ||
} | ||
return function(object) { | return function(object) { | |
var objValue = get(object, path); | var objValue = get(object, path); | |
return (objValue === undefined && objValue === srcValue) | return (objValue === undefined && objValue === srcValue) | |
? hasIn(object, path) | ? hasIn(object, path) | |
: baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG); | : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORD ERED_FLAG); | |
}; | }; | |
} | } | |
/** | /** | |
* The base implementation of `_.merge` without support for multiple sources . | * The base implementation of `_.merge` without support for multiple sources . | |
* | * | |
* @private | * @private | |
* @param {Object} object The destination object. | * @param {Object} object The destination object. | |
* @param {Object} source The source object. | * @param {Object} source The source object. | |
* @param {number} srcIndex The index of `source`. | ||
* @param {Function} [customizer] The function to customize merged values. | * @param {Function} [customizer] The function to customize merged values. | |
* @param {Object} [stack] Tracks traversed source values and their merged c | * @param {Object} [stack] Tracks traversed source values and their merged | |
ounterparts. | * counterparts. | |
*/ | */ | |
function baseMerge(object, source, customizer, stack) { | function baseMerge(object, source, srcIndex, customizer, stack) { | |
if (object === source) { | if (object === source) { | |
return; | return; | |
} | } | |
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn | baseFor(source, function(srcValue, key) { | |
(source); | stack || (stack = new Stack); | |
arrayEach(props || source, function(srcValue, key) { | ||
if (props) { | ||
key = srcValue; | ||
srcValue = source[key]; | ||
} | ||
if (isObject(srcValue)) { | if (isObject(srcValue)) { | |
stack || (stack = new Stack); | baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, st | |
baseMergeDeep(object, source, key, baseMerge, customizer, stack); | ack); | |
} | } | |
else { | else { | |
var newValue = customizer ? customizer(object[key], srcValue, (key + ' | var newValue = customizer | |
'), object, source, stack) : undefined; | ? customizer(safeGet(object, key), srcValue, (key + ''), object, sou | |
rce, stack) | ||
: undefined; | ||
if (newValue === undefined) { | if (newValue === undefined) { | |
newValue = srcValue; | newValue = srcValue; | |
} | } | |
assignMergeValue(object, key, newValue); | assignMergeValue(object, key, newValue); | |
} | } | |
}); | }, keysIn); | |
} | } | |
/** | /** | |
* A specialized version of `baseMerge` for arrays and objects which perform s | * A specialized version of `baseMerge` for arrays and objects which perform s | |
* deep merges and tracks traversed objects enabling objects with circular | * deep merges and tracks traversed objects enabling objects with circular | |
* references to be merged. | * references to be merged. | |
* | * | |
* @private | * @private | |
* @param {Object} object The destination object. | * @param {Object} object The destination object. | |
* @param {Object} source The source object. | * @param {Object} source The source object. | |
* @param {string} key The key of the value to merge. | * @param {string} key The key of the value to merge. | |
* @param {number} srcIndex The index of `source`. | ||
* @param {Function} mergeFunc The function to merge values. | * @param {Function} mergeFunc The function to merge values. | |
* @param {Function} [customizer] The function to customize assigned values. | * @param {Function} [customizer] The function to customize assigned values. | |
* @param {Object} [stack] Tracks traversed source values and their merged c | * @param {Object} [stack] Tracks traversed source values and their merged | |
ounterparts. | * counterparts. | |
*/ | */ | |
function baseMergeDeep(object, source, key, mergeFunc, customizer, stack) { | function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, | |
var objValue = object[key], | stack) { | |
srcValue = source[key], | var objValue = safeGet(object, key), | |
stacked = stack.get(srcValue) || stack.get(objValue); | srcValue = safeGet(source, key), | |
stacked = stack.get(srcValue); | ||
if (stacked) { | if (stacked) { | |
assignMergeValue(object, key, stacked); | assignMergeValue(object, key, stacked); | |
return; | return; | |
} | } | |
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), obj | var newValue = customizer | |
ect, source, stack) : undefined, | ? customizer(objValue, srcValue, (key + ''), object, source, stack) | |
isCommon = newValue === undefined; | : undefined; | |
var isCommon = newValue === undefined; | ||
if (isCommon) { | if (isCommon) { | |
var isArr = isArray(srcValue), | ||
isBuff = !isArr && isBuffer(srcValue), | ||
isTyped = !isArr && !isBuff && isTypedArray(srcValue); | ||
newValue = srcValue; | newValue = srcValue; | |
if (isArray(srcValue) || isTypedArray(srcValue)) { | if (isArr || isBuff || isTyped) { | |
newValue = isArray(objValue) | if (isArray(objValue)) { | |
? objValue | newValue = objValue; | |
: ((isArrayLikeObject(objValue)) ? copyArray(objValue) : baseClone(s | } | |
rcValue)); | else if (isArrayLikeObject(objValue)) { | |
newValue = copyArray(objValue); | ||
} | ||
else if (isBuff) { | ||
isCommon = false; | ||
newValue = cloneBuffer(srcValue, true); | ||
} | ||
else if (isTyped) { | ||
isCommon = false; | ||
newValue = cloneTypedArray(srcValue, true); | ||
} | ||
else { | ||
newValue = []; | ||
} | ||
} | } | |
else if (isPlainObject(srcValue) || isArguments(srcValue)) { | else if (isPlainObject(srcValue) || isArguments(srcValue)) { | |
newValue = isArguments(objValue) | newValue = objValue; | |
? toPlainObject(objValue) | if (isArguments(objValue)) { | |
: (isObject(objValue) ? objValue : baseClone(srcValue)); | newValue = toPlainObject(objValue); | |
} | ||
else if (!isObject(objValue) || isFunction(objValue)) { | ||
newValue = initCloneObject(srcValue); | ||
} | ||
} | } | |
else { | else { | |
isCommon = isFunction(srcValue); | isCommon = false; | |
} | } | |
} | } | |
stack.set(srcValue, newValue); | ||
if (isCommon) { | if (isCommon) { | |
// Recursively merge objects and arrays (susceptible to call stack limit s). | // Recursively merge objects and arrays (susceptible to call stack limit s). | |
mergeFunc(newValue, srcValue, customizer, stack); | stack.set(srcValue, newValue); | |
mergeFunc(newValue, srcValue, srcIndex, customizer, stack); | ||
stack['delete'](srcValue); | ||
} | } | |
assignMergeValue(object, key, newValue); | assignMergeValue(object, key, newValue); | |
} | } | |
/** | /** | |
* The base implementation of `_.nth` which doesn't coerce arguments. | ||
* | ||
* @private | ||
* @param {Array} array The array to query. | ||
* @param {number} n The index of the element to return. | ||
* @returns {*} Returns the nth element of `array`. | ||
*/ | ||
function baseNth(array, n) { | ||
var length = array.length; | ||
if (!length) { | ||
return; | ||
} | ||
n += n < 0 ? length : 0; | ||
return isIndex(n, length) ? array[n] : undefined; | ||
} | ||
/** | ||
* The base implementation of `_.orderBy` without param guards. | * The base implementation of `_.orderBy` without param guards. | |
* | * | |
* @private | * @private | |
* @param {Array|Object} collection The collection to iterate over. | * @param {Array|Object} collection The collection to iterate over. | |
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. | * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. | |
* @param {string[]} orders The sort orders of `iteratees`. | * @param {string[]} orders The sort orders of `iteratees`. | |
* @returns {Array} Returns the new sorted array. | * @returns {Array} Returns the new sorted array. | |
*/ | */ | |
function baseOrderBy(collection, iteratees, orders) { | function baseOrderBy(collection, iteratees, orders) { | |
var index = -1, | if (iteratees.length) { | |
toIteratee = getIteratee(); | iteratees = arrayMap(iteratees, function(iteratee) { | |
if (isArray(iteratee)) { | ||
return function(value) { | ||
return baseGet(value, iteratee.length === 1 ? iteratee[0] : iterat | ||
ee); | ||
} | ||
} | ||
return iteratee; | ||
}); | ||
} else { | ||
iteratees = [identity]; | ||
} | ||
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(ite | var index = -1; | |
ratee) { | iteratees = arrayMap(iteratees, baseUnary(getIteratee())); | |
return toIteratee(iteratee); | ||
}); | ||
var result = baseMap(collection, function(value, key, collection) { | var result = baseMap(collection, function(value, key, collection) { | |
var criteria = arrayMap(iteratees, function(iteratee) { | var criteria = arrayMap(iteratees, function(iteratee) { | |
return iteratee(value); | return iteratee(value); | |
}); | }); | |
return { 'criteria': criteria, 'index': ++index, 'value': value }; | return { 'criteria': criteria, 'index': ++index, 'value': value }; | |
}); | }); | |
return baseSortBy(result, function(object, other) { | return baseSortBy(result, function(object, other) { | |
return compareMultiple(object, other, orders); | return compareMultiple(object, other, orders); | |
}); | }); | |
} | } | |
/** | /** | |
* The base implementation of `_.pick` without support for individual | * The base implementation of `_.pick` without support for individual | |
* property names. | * property identifiers. | |
* | * | |
* @private | * @private | |
* @param {Object} object The source object. | * @param {Object} object The source object. | |
* @param {string[]} props The property names to pick. | * @param {string[]} paths The property paths to pick. | |
* @returns {Object} Returns the new object. | * @returns {Object} Returns the new object. | |
*/ | */ | |
function basePick(object, props) { | function basePick(object, paths) { | |
object = Object(object); | return basePickBy(object, paths, function(value, path) { | |
return arrayReduce(props, function(result, key) { | return hasIn(object, path); | |
if (key in object) { | }); | |
result[key] = object[key]; | ||
} | ||
return result; | ||
}, {}); | ||
} | } | |
/** | /** | |
* The base implementation of `_.pickBy` without support for iteratee short hands. | * The base implementation of `_.pickBy` without support for iteratee short hands. | |
* | * | |
* @private | * @private | |
* @param {Object} object The source object. | * @param {Object} object The source object. | |
* @param {string[]} paths The property paths to pick. | ||
* @param {Function} predicate The function invoked per property. | * @param {Function} predicate The function invoked per property. | |
* @returns {Object} Returns the new object. | * @returns {Object} Returns the new object. | |
*/ | */ | |
function basePickBy(object, predicate) { | function basePickBy(object, paths, predicate) { | |
var result = {}; | var index = -1, | |
baseForIn(object, function(value, key) { | length = paths.length, | |
if (predicate(value)) { | result = {}; | |
result[key] = value; | ||
while (++index < length) { | ||
var path = paths[index], | ||
value = baseGet(object, path); | ||
if (predicate(value, path)) { | ||
baseSet(result, castPath(path, object), value); | ||
} | } | |
}); | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.property` without support for deep paths. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function baseProperty(key) { | ||
return function(object) { | ||
return object == null ? undefined : object[key]; | ||
}; | ||
} | ||
/** | ||
* A specialized version of `baseProperty` which supports deep paths. | * A specialized version of `baseProperty` which supports deep paths. | |
* | * | |
* @private | * @private | |
* @param {Array|string} path The path of the property to get. | * @param {Array|string} path The path of the property to get. | |
* @returns {Function} Returns the new function. | * @returns {Function} Returns the new accessor function. | |
*/ | */ | |
function basePropertyDeep(path) { | function basePropertyDeep(path) { | |
return function(object) { | return function(object) { | |
return baseGet(object, path); | return baseGet(object, path); | |
}; | }; | |
} | } | |
/** | /** | |
* The base implementation of `_.pullAll`. | ||
* | ||
* @private | ||
* @param {Array} array The array to modify. | ||
* @param {Array} values The values to remove. | ||
* @returns {Array} Returns `array`. | ||
*/ | ||
function basePullAll(array, values) { | ||
return basePullAllBy(array, values); | ||
} | ||
/** | ||
* The base implementation of `_.pullAllBy` without support for iteratee | * The base implementation of `_.pullAllBy` without support for iteratee | |
* shorthands. | * shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to modify. | * @param {Array} array The array to modify. | |
* @param {Array} values The values to remove. | * @param {Array} values The values to remove. | |
* @param {Function} [iteratee] The iteratee invoked per element. | * @param {Function} [iteratee] The iteratee invoked per element. | |
* @param {Function} [comparator] The comparator invoked per element. | ||
* @returns {Array} Returns `array`. | * @returns {Array} Returns `array`. | |
*/ | */ | |
function basePullAllBy(array, values, iteratee) { | function basePullAll(array, values, iteratee, comparator) { | |
var index = -1, | var indexOf = comparator ? baseIndexOfWith : baseIndexOf, | |
index = -1, | ||
length = values.length, | length = values.length, | |
seen = array; | seen = array; | |
if (array === values) { | ||
values = copyArray(values); | ||
} | ||
if (iteratee) { | if (iteratee) { | |
seen = arrayMap(array, function(value) { return iteratee(value); }); | seen = arrayMap(array, baseUnary(iteratee)); | |
} | } | |
while (++index < length) { | while (++index < length) { | |
var fromIndex = 0, | var fromIndex = 0, | |
value = values[index], | value = values[index], | |
computed = iteratee ? iteratee(value) : value; | computed = iteratee ? iteratee(value) : value; | |
while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) { | while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1 ) { | |
if (seen !== array) { | if (seen !== array) { | |
splice.call(seen, fromIndex, 1); | splice.call(seen, fromIndex, 1); | |
} | } | |
splice.call(array, fromIndex, 1); | splice.call(array, fromIndex, 1); | |
} | } | |
} | } | |
return array; | return array; | |
} | } | |
/** | /** | |
skipping to change at line 3178 | skipping to change at line 3898 | |
* @param {Array} array The array to modify. | * @param {Array} array The array to modify. | |
* @param {number[]} indexes The indexes of elements to remove. | * @param {number[]} indexes The indexes of elements to remove. | |
* @returns {Array} Returns `array`. | * @returns {Array} Returns `array`. | |
*/ | */ | |
function basePullAt(array, indexes) { | function basePullAt(array, indexes) { | |
var length = array ? indexes.length : 0, | var length = array ? indexes.length : 0, | |
lastIndex = length - 1; | lastIndex = length - 1; | |
while (length--) { | while (length--) { | |
var index = indexes[length]; | var index = indexes[length]; | |
if (lastIndex == length || index != previous) { | if (length == lastIndex || index !== previous) { | |
var previous = index; | var previous = index; | |
if (isIndex(index)) { | if (isIndex(index)) { | |
splice.call(array, index, 1); | splice.call(array, index, 1); | |
} | } else { | |
else if (!isKey(index, array)) { | baseUnset(array, index); | |
var path = baseToPath(index), | ||
object = parent(array, path); | ||
if (object != null) { | ||
delete object[last(path)]; | ||
} | ||
} | ||
else { | ||
delete array[index]; | ||
} | } | |
} | } | |
} | } | |
return array; | return array; | |
} | } | |
/** | /** | |
* The base implementation of `_.random` without support for returning | * The base implementation of `_.random` without support for returning | |
* floating-point numbers. | * floating-point numbers. | |
* | * | |
skipping to change at line 3214 | skipping to change at line 3925 | |
* @param {number} lower The lower bound. | * @param {number} lower The lower bound. | |
* @param {number} upper The upper bound. | * @param {number} upper The upper bound. | |
* @returns {number} Returns the random number. | * @returns {number} Returns the random number. | |
*/ | */ | |
function baseRandom(lower, upper) { | function baseRandom(lower, upper) { | |
return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); | return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); | |
} | } | |
/** | /** | |
* The base implementation of `_.range` and `_.rangeRight` which doesn't | * The base implementation of `_.range` and `_.rangeRight` which doesn't | |
* coerce arguments to numbers. | * coerce arguments. | |
* | * | |
* @private | * @private | |
* @param {number} start The start of the range. | * @param {number} start The start of the range. | |
* @param {number} end The end of the range. | * @param {number} end The end of the range. | |
* @param {number} step The value to increment or decrement by. | * @param {number} step The value to increment or decrement by. | |
* @param {boolean} [fromRight] Specify iterating from right to left. | * @param {boolean} [fromRight] Specify iterating from right to left. | |
* @returns {Array} Returns the new array of numbers. | * @returns {Array} Returns the range of numbers. | |
*/ | */ | |
function baseRange(start, end, step, fromRight) { | function baseRange(start, end, step, fromRight) { | |
var index = -1, | var index = -1, | |
length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), | length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), | |
result = Array(length); | result = Array(length); | |
while (length--) { | while (length--) { | |
result[fromRight ? length : ++index] = start; | result[fromRight ? length : ++index] = start; | |
start += step; | start += step; | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.repeat` which doesn't coerce arguments. | ||
* | ||
* @private | ||
* @param {string} string The string to repeat. | ||
* @param {number} n The number of times to repeat the string. | ||
* @returns {string} Returns the repeated string. | ||
*/ | ||
function baseRepeat(string, n) { | ||
var result = ''; | ||
if (!string || n < 1 || n > MAX_SAFE_INTEGER) { | ||
return result; | ||
} | ||
// Leverage the exponentiation by squaring algorithm for a faster repeat. | ||
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more d | ||
etails. | ||
do { | ||
if (n % 2) { | ||
result += string; | ||
} | ||
n = nativeFloor(n / 2); | ||
if (n) { | ||
string += string; | ||
} | ||
} while (n); | ||
return result; | ||
} | ||
/** | ||
* The base implementation of `_.rest` which doesn't validate or coerce argu | ||
ments. | ||
* | ||
* @private | ||
* @param {Function} func The function to apply a rest parameter to. | ||
* @param {number} [start=func.length-1] The start position of the rest para | ||
meter. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function baseRest(func, start) { | ||
return setToString(overRest(func, start, identity), func + ''); | ||
} | ||
/** | ||
* The base implementation of `_.sample`. | ||
* | ||
* @private | ||
* @param {Array|Object} collection The collection to sample. | ||
* @returns {*} Returns the random element. | ||
*/ | ||
function baseSample(collection) { | ||
return arraySample(values(collection)); | ||
} | ||
/** | ||
* The base implementation of `_.sampleSize` without param guards. | ||
* | ||
* @private | ||
* @param {Array|Object} collection The collection to sample. | ||
* @param {number} n The number of elements to sample. | ||
* @returns {Array} Returns the random elements. | ||
*/ | ||
function baseSampleSize(collection, n) { | ||
var array = values(collection); | ||
return shuffleSelf(array, baseClamp(n, 0, array.length)); | ||
} | ||
/** | ||
* The base implementation of `_.set`. | * The base implementation of `_.set`. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to modify. | |
* @param {Array|string} path The path of the property to set. | * @param {Array|string} path The path of the property to set. | |
* @param {*} value The value to set. | * @param {*} value The value to set. | |
* @param {Function} [customizer] The function to customize path creation. | * @param {Function} [customizer] The function to customize path creation. | |
* @returns {Object} Returns `object`. | * @returns {Object} Returns `object`. | |
*/ | */ | |
function baseSet(object, path, value, customizer) { | function baseSet(object, path, value, customizer) { | |
path = isKey(path, object) ? [path + ''] : baseToPath(path); | if (!isObject(object)) { | |
return object; | ||
} | ||
path = castPath(path, object); | ||
var index = -1, | var index = -1, | |
length = path.length, | length = path.length, | |
lastIndex = length - 1, | lastIndex = length - 1, | |
nested = object; | nested = object; | |
while (nested != null && ++index < length) { | while (nested != null && ++index < length) { | |
var key = path[index]; | var key = toKey(path[index]), | |
if (isObject(nested)) { | newValue = value; | |
var newValue = value; | ||
if (index != lastIndex) { | if (key === '__proto__' || key === 'constructor' || key === 'prototype') | |
var objValue = nested[key]; | { | |
newValue = customizer ? customizer(objValue, key, nested) : undefine | return object; | |
d; | } | |
if (newValue === undefined) { | ||
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) | if (index != lastIndex) { | |
: objValue; | var objValue = nested[key]; | |
} | newValue = customizer ? customizer(objValue, key, nested) : undefined; | |
if (newValue === undefined) { | ||
newValue = isObject(objValue) | ||
? objValue | ||
: (isIndex(path[index + 1]) ? [] : {}); | ||
} | } | |
assignValue(nested, key, newValue); | ||
} | } | |
assignValue(nested, key, newValue); | ||
nested = nested[key]; | nested = nested[key]; | |
} | } | |
return object; | return object; | |
} | } | |
/** | /** | |
* The base implementation of `setData` without support for hot loop detecti on. | * The base implementation of `setData` without support for hot loop shortin g. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to associate metadata with. | * @param {Function} func The function to associate metadata with. | |
* @param {*} data The metadata. | * @param {*} data The metadata. | |
* @returns {Function} Returns `func`. | * @returns {Function} Returns `func`. | |
*/ | */ | |
var baseSetData = !metaMap ? identity : function(func, data) { | var baseSetData = !metaMap ? identity : function(func, data) { | |
metaMap.set(func, data); | metaMap.set(func, data); | |
return func; | return func; | |
}; | }; | |
/** | /** | |
* The base implementation of `setToString` without support for hot loop sho | ||
rting. | ||
* | ||
* @private | ||
* @param {Function} func The function to modify. | ||
* @param {Function} string The `toString` result. | ||
* @returns {Function} Returns `func`. | ||
*/ | ||
var baseSetToString = !defineProperty ? identity : function(func, string) { | ||
return defineProperty(func, 'toString', { | ||
'configurable': true, | ||
'enumerable': false, | ||
'value': constant(string), | ||
'writable': true | ||
}); | ||
}; | ||
/** | ||
* The base implementation of `_.shuffle`. | ||
* | ||
* @private | ||
* @param {Array|Object} collection The collection to shuffle. | ||
* @returns {Array} Returns the new shuffled array. | ||
*/ | ||
function baseShuffle(collection) { | ||
return shuffleSelf(values(collection)); | ||
} | ||
/** | ||
* The base implementation of `_.slice` without an iteratee call guard. | * The base implementation of `_.slice` without an iteratee call guard. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to slice. | * @param {Array} array The array to slice. | |
* @param {number} [start=0] The start position. | * @param {number} [start=0] The start position. | |
* @param {number} [end=array.length] The end position. | * @param {number} [end=array.length] The end position. | |
* @returns {Array} Returns the slice of `array`. | * @returns {Array} Returns the slice of `array`. | |
*/ | */ | |
function baseSlice(array, start, end) { | function baseSlice(array, start, end) { | |
var index = -1, | var index = -1, | |
skipping to change at line 3320 | skipping to change at line 4131 | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.some` without support for iteratee shorthan ds. | * The base implementation of `_.some` without support for iteratee shorthan ds. | |
* | * | |
* @private | * @private | |
* @param {Array|Object} collection The collection to iterate over. | * @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | * @param {Function} predicate The function invoked per iteration. | |
* @returns {boolean} Returns `true` if any element passes the predicate che | * @returns {boolean} Returns `true` if any element passes the predicate che | |
ck, else `false`. | ck, | |
* else `false`. | ||
*/ | */ | |
function baseSome(collection, predicate) { | function baseSome(collection, predicate) { | |
var result; | var result; | |
baseEach(collection, function(value, index, collection) { | baseEach(collection, function(value, index, collection) { | |
result = predicate(value, index, collection); | result = predicate(value, index, collection); | |
return !result; | return !result; | |
}); | }); | |
return !!result; | return !!result; | |
} | } | |
skipping to change at line 3346 | skipping to change at line 4158 | |
* | * | |
* @private | * @private | |
* @param {Array} array The sorted array to inspect. | * @param {Array} array The sorted array to inspect. | |
* @param {*} value The value to evaluate. | * @param {*} value The value to evaluate. | |
* @param {boolean} [retHighest] Specify returning the highest qualified ind ex. | * @param {boolean} [retHighest] Specify returning the highest qualified ind ex. | |
* @returns {number} Returns the index at which `value` should be inserted | * @returns {number} Returns the index at which `value` should be inserted | |
* into `array`. | * into `array`. | |
*/ | */ | |
function baseSortedIndex(array, value, retHighest) { | function baseSortedIndex(array, value, retHighest) { | |
var low = 0, | var low = 0, | |
high = array ? array.length : low; | high = array == null ? low : array.length; | |
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_ LENGTH) { | if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_ LENGTH) { | |
while (low < high) { | while (low < high) { | |
var mid = (low + high) >>> 1, | var mid = (low + high) >>> 1, | |
computed = array[mid]; | computed = array[mid]; | |
if ((retHighest ? (computed <= value) : (computed < value)) && compute | if (computed !== null && !isSymbol(computed) && | |
d !== null) { | (retHighest ? (computed <= value) : (computed < value))) { | |
low = mid + 1; | low = mid + 1; | |
} else { | } else { | |
high = mid; | high = mid; | |
} | } | |
} | } | |
return high; | return high; | |
} | } | |
return baseSortedIndexBy(array, value, identity, retHighest); | return baseSortedIndexBy(array, value, identity, retHighest); | |
} | } | |
/** | /** | |
* The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` | * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` | |
* which invokes `iteratee` for `value` and each element of `array` to compu te | * which invokes `iteratee` for `value` and each element of `array` to compu te | |
* their sort ranking. The iteratee is invoked with one argument; (value). | * their sort ranking. The iteratee is invoked with one argument; (value). | |
* | * | |
* @private | * @private | |
* @param {Array} array The sorted array to inspect. | * @param {Array} array The sorted array to inspect. | |
* @param {*} value The value to evaluate. | * @param {*} value The value to evaluate. | |
* @param {Function} iteratee The iteratee invoked per element. | * @param {Function} iteratee The iteratee invoked per element. | |
* @param {boolean} [retHighest] Specify returning the highest qualified ind ex. | * @param {boolean} [retHighest] Specify returning the highest qualified ind ex. | |
* @returns {number} Returns the index at which `value` should be inserted i | * @returns {number} Returns the index at which `value` should be inserted | |
nto `array`. | * into `array`. | |
*/ | */ | |
function baseSortedIndexBy(array, value, iteratee, retHighest) { | function baseSortedIndexBy(array, value, iteratee, retHighest) { | |
value = iteratee(value); | ||
var low = 0, | var low = 0, | |
high = array ? array.length : 0, | high = array == null ? 0 : array.length; | |
valIsNaN = value !== value, | if (high === 0) { | |
return 0; | ||
} | ||
value = iteratee(value); | ||
var valIsNaN = value !== value, | ||
valIsNull = value === null, | valIsNull = value === null, | |
valIsUndef = value === undefined; | valIsSymbol = isSymbol(value), | |
valIsUndefined = value === undefined; | ||
while (low < high) { | while (low < high) { | |
var mid = nativeFloor((low + high) / 2), | var mid = nativeFloor((low + high) / 2), | |
computed = iteratee(array[mid]), | computed = iteratee(array[mid]), | |
isDef = computed !== undefined, | othIsDefined = computed !== undefined, | |
isReflexive = computed === computed; | othIsNull = computed === null, | |
othIsReflexive = computed === computed, | ||
othIsSymbol = isSymbol(computed); | ||
if (valIsNaN) { | if (valIsNaN) { | |
var setLow = isReflexive || retHighest; | var setLow = retHighest || othIsReflexive; | |
} else if (valIsUndefined) { | ||
setLow = othIsReflexive && (retHighest || othIsDefined); | ||
} else if (valIsNull) { | } else if (valIsNull) { | |
setLow = isReflexive && isDef && (retHighest || computed != null); | setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); | |
} else if (valIsUndef) { | } else if (valIsSymbol) { | |
setLow = isReflexive && (retHighest || isDef); | setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest | | |
} else if (computed == null) { | | !othIsSymbol); | |
} else if (othIsNull || othIsSymbol) { | ||
setLow = false; | setLow = false; | |
} else { | } else { | |
setLow = retHighest ? (computed <= value) : (computed < value); | setLow = retHighest ? (computed <= value) : (computed < value); | |
} | } | |
if (setLow) { | if (setLow) { | |
low = mid + 1; | low = mid + 1; | |
} else { | } else { | |
high = mid; | high = mid; | |
} | } | |
} | } | |
return nativeMin(high, MAX_ARRAY_INDEX); | return nativeMin(high, MAX_ARRAY_INDEX); | |
} | } | |
/** | /** | |
* The base implementation of `_.sortedUniq`. | * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without | |
* | * support for iteratee shorthands. | |
* @private | ||
* @param {Array} array The array to inspect. | ||
* @returns {Array} Returns the new duplicate free array. | ||
*/ | ||
function baseSortedUniq(array) { | ||
return baseSortedUniqBy(array); | ||
} | ||
/** | ||
* The base implementation of `_.sortedUniqBy` without support for iteratee | ||
* shorthands. | ||
* | * | |
* @private | * @private | |
* @param {Array} array The array to inspect. | * @param {Array} array The array to inspect. | |
* @param {Function} [iteratee] The iteratee invoked per element. | * @param {Function} [iteratee] The iteratee invoked per element. | |
* @returns {Array} Returns the new duplicate free array. | * @returns {Array} Returns the new duplicate free array. | |
*/ | */ | |
function baseSortedUniqBy(array, iteratee) { | function baseSortedUniq(array, iteratee) { | |
var index = 0, | var index = -1, | |
length = array.length, | length = array.length, | |
value = array[0], | ||
computed = iteratee ? iteratee(value) : value, | ||
seen = computed, | ||
resIndex = 0, | resIndex = 0, | |
result = [value]; | result = []; | |
while (++index < length) { | while (++index < length) { | |
value = array[index], | var value = array[index], | |
computed = iteratee ? iteratee(value) : value; | computed = iteratee ? iteratee(value) : value; | |
if (!eq(computed, seen)) { | if (!index || !eq(computed, seen)) { | |
seen = computed; | var seen = computed; | |
result[++resIndex] = value; | result[resIndex++] = value === 0 ? 0 : value; | |
} | } | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.toPath` which only converts `value` to a | * The base implementation of `_.toNumber` which doesn't ensure correct | |
* path if it's not one. | * conversions of binary, hexadecimal, or octal string values. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to process. | * @param {*} value The value to process. | |
* @returns {Array} Returns the property path array. | * @returns {number} Returns the number. | |
*/ | */ | |
function baseToPath(value) { | function baseToNumber(value) { | |
return isArray(value) ? value : stringToPath(value); | if (typeof value == 'number') { | |
return value; | ||
} | ||
if (isSymbol(value)) { | ||
return NAN; | ||
} | ||
return +value; | ||
} | ||
/** | ||
* The base implementation of `_.toString` which doesn't convert nullish | ||
* values to empty strings. | ||
* | ||
* @private | ||
* @param {*} value The value to process. | ||
* @returns {string} Returns the string. | ||
*/ | ||
function baseToString(value) { | ||
// Exit early for strings to avoid a performance hit in some environments. | ||
if (typeof value == 'string') { | ||
return value; | ||
} | ||
if (isArray(value)) { | ||
// Recursively convert values (susceptible to call stack limits). | ||
return arrayMap(value, baseToString) + ''; | ||
} | ||
if (isSymbol(value)) { | ||
return symbolToString ? symbolToString.call(value) : ''; | ||
} | ||
var result = (value + ''); | ||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; | ||
} | } | |
/** | /** | |
* The base implementation of `_.uniqBy` without support for iteratee shorth ands. | * The base implementation of `_.uniqBy` without support for iteratee shorth ands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to inspect. | * @param {Array} array The array to inspect. | |
* @param {Function} [iteratee] The iteratee invoked per element. | * @param {Function} [iteratee] The iteratee invoked per element. | |
* @param {Function} [comparator] The comparator invoked per element. | * @param {Function} [comparator] The comparator invoked per element. | |
* @returns {Array} Returns the new duplicate free array. | * @returns {Array} Returns the new duplicate free array. | |
skipping to change at line 3502 | skipping to change at line 4340 | |
seen = new SetCache; | seen = new SetCache; | |
} | } | |
else { | else { | |
seen = iteratee ? [] : result; | seen = iteratee ? [] : result; | |
} | } | |
outer: | outer: | |
while (++index < length) { | while (++index < length) { | |
var value = array[index], | var value = array[index], | |
computed = iteratee ? iteratee(value) : value; | computed = iteratee ? iteratee(value) : value; | |
value = (comparator || value !== 0) ? value : 0; | ||
if (isCommon && computed === computed) { | if (isCommon && computed === computed) { | |
var seenIndex = seen.length; | var seenIndex = seen.length; | |
while (seenIndex--) { | while (seenIndex--) { | |
if (seen[seenIndex] === computed) { | if (seen[seenIndex] === computed) { | |
continue outer; | continue outer; | |
} | } | |
} | } | |
if (iteratee) { | if (iteratee) { | |
seen.push(computed); | seen.push(computed); | |
} | } | |
skipping to change at line 3529 | skipping to change at line 4368 | |
} | } | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* The base implementation of `_.unset`. | * The base implementation of `_.unset`. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to modify. | * @param {Object} object The object to modify. | |
* @param {Array|string} path The path of the property to unset. | * @param {Array|string} path The property path to unset. | |
* @returns {boolean} Returns `true` if the property is deleted, else `false `. | * @returns {boolean} Returns `true` if the property is deleted, else `false `. | |
*/ | */ | |
function baseUnset(object, path) { | function baseUnset(object, path) { | |
path = isKey(path, object) ? [path + ''] : baseToPath(path); | path = castPath(path, object); | |
object = parent(object, path); | object = parent(object, path); | |
var key = last(path); | return object == null || delete object[toKey(last(path))]; | |
return (object != null && has(object, key)) ? delete object[key] : true; | } | |
/** | ||
* The base implementation of `_.update`. | ||
* | ||
* @private | ||
* @param {Object} object The object to modify. | ||
* @param {Array|string} path The path of the property to update. | ||
* @param {Function} updater The function to produce the updated value. | ||
* @param {Function} [customizer] The function to customize path creation. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function baseUpdate(object, path, updater, customizer) { | ||
return baseSet(object, path, updater(baseGet(object, path)), customizer); | ||
} | } | |
/** | /** | |
* The base implementation of methods like `_.dropWhile` and `_.takeWhile` | * The base implementation of methods like `_.dropWhile` and `_.takeWhile` | |
* without support for iteratee shorthands. | * without support for iteratee shorthands. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to query. | * @param {Array} array The array to query. | |
* @param {Function} predicate The function invoked per iteration. | * @param {Function} predicate The function invoked per iteration. | |
* @param {boolean} [isDrop] Specify dropping elements instead of taking the m. | * @param {boolean} [isDrop] Specify dropping elements instead of taking the m. | |
skipping to change at line 3593 | skipping to change at line 4445 | |
* The base implementation of methods like `_.xor`, without support for | * The base implementation of methods like `_.xor`, without support for | |
* iteratee shorthands, that accepts an array of arrays to inspect. | * iteratee shorthands, that accepts an array of arrays to inspect. | |
* | * | |
* @private | * @private | |
* @param {Array} arrays The arrays to inspect. | * @param {Array} arrays The arrays to inspect. | |
* @param {Function} [iteratee] The iteratee invoked per element. | * @param {Function} [iteratee] The iteratee invoked per element. | |
* @param {Function} [comparator] The comparator invoked per element. | * @param {Function} [comparator] The comparator invoked per element. | |
* @returns {Array} Returns the new array of values. | * @returns {Array} Returns the new array of values. | |
*/ | */ | |
function baseXor(arrays, iteratee, comparator) { | function baseXor(arrays, iteratee, comparator) { | |
var length = arrays.length; | ||
if (length < 2) { | ||
return length ? baseUniq(arrays[0]) : []; | ||
} | ||
var index = -1, | var index = -1, | |
length = arrays.length; | result = Array(length); | |
while (++index < length) { | while (++index < length) { | |
var result = result | var array = arrays[index], | |
? arrayPush( | othIndex = -1; | |
baseDifference(result, arrays[index], iteratee, comparator), | ||
baseDifference(arrays[index], result, iteratee, comparator) | while (++othIndex < length) { | |
) | if (othIndex != index) { | |
: arrays[index]; | result[index] = baseDifference(result[index] || array, arrays[othInd | |
ex], iteratee, comparator); | ||
} | ||
} | ||
} | } | |
return (result && result.length) ? baseUniq(result, iteratee, comparator) : []; | return baseUniq(baseFlatten(result, 1), iteratee, comparator); | |
} | } | |
/** | /** | |
* Creates a clone of `buffer`. | * This base implementation of `_.zipObject` which assigns values using `ass ignFunc`. | |
* | * | |
* @private | * @private | |
* @param {ArrayBuffer} buffer The array buffer to clone. | * @param {Array} props The property identifiers. | |
* @returns {ArrayBuffer} Returns the cloned array buffer. | * @param {Array} values The property values. | |
* @param {Function} assignFunc The function to assign values. | ||
* @returns {Object} Returns the new object. | ||
*/ | */ | |
function cloneBuffer(buffer) { | function baseZipObject(props, values, assignFunc) { | |
var Ctor = buffer.constructor, | var index = -1, | |
result = new Ctor(buffer.byteLength), | length = props.length, | |
view = new Uint8Array(result); | valsLength = values.length, | |
result = {}; | ||
view.set(new Uint8Array(buffer)); | while (++index < length) { | |
var value = index < valsLength ? values[index] : undefined; | ||
assignFunc(result, props[index], value); | ||
} | ||
return result; | return result; | |
} | } | |
/** | /** | |
* Creates a clone of `map`. | * Casts `value` to an empty array if it's not an array like object. | |
* | * | |
* @private | * @private | |
* @param {Object} map The map to clone. | * @param {*} value The value to inspect. | |
* @returns {Object} Returns the cloned map. | * @returns {Array|Object} Returns the cast array-like object. | |
*/ | */ | |
function cloneMap(map) { | function castArrayLikeObject(value) { | |
var Ctor = map.constructor; | return isArrayLikeObject(value) ? value : []; | |
return arrayReduce(mapToArray(map), addMapEntry, new Ctor); | ||
} | } | |
/** | /** | |
* Creates a clone of `regexp`. | * Casts `value` to `identity` if it's not a function. | |
* | * | |
* @private | * @private | |
* @param {Object} regexp The regexp to clone. | * @param {*} value The value to inspect. | |
* @returns {Object} Returns the cloned regexp. | * @returns {Function} Returns cast function. | |
*/ | */ | |
function cloneRegExp(regexp) { | function castFunction(value) { | |
var Ctor = regexp.constructor, | return typeof value == 'function' ? value : identity; | |
result = new Ctor(regexp.source, reFlags.exec(regexp)); | } | |
result.lastIndex = regexp.lastIndex; | /** | |
* Casts `value` to a path array if it's not one. | ||
* | ||
* @private | ||
* @param {*} value The value to inspect. | ||
* @param {Object} [object] The object to query keys on. | ||
* @returns {Array} Returns the cast property path array. | ||
*/ | ||
function castPath(value, object) { | ||
if (isArray(value)) { | ||
return value; | ||
} | ||
return isKey(value, object) ? [value] : stringToPath(toString(value)); | ||
} | ||
/** | ||
* A `baseRest` alias which can be replaced with `identity` by module | ||
* replacement plugins. | ||
* | ||
* @private | ||
* @type {Function} | ||
* @param {Function} func The function to apply a rest parameter to. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
var castRest = baseRest; | ||
/** | ||
* Casts `array` to a slice if it's needed. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {number} start The start position. | ||
* @param {number} [end=array.length] The end position. | ||
* @returns {Array} Returns the cast slice. | ||
*/ | ||
function castSlice(array, start, end) { | ||
var length = array.length; | ||
end = end === undefined ? length : end; | ||
return (!start && end >= length) ? array : baseSlice(array, start, end); | ||
} | ||
/** | ||
* A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearT | ||
imeout). | ||
* | ||
* @private | ||
* @param {number|Object} id The timer id or timeout object of the timer to | ||
clear. | ||
*/ | ||
var clearTimeout = ctxClearTimeout || function(id) { | ||
return root.clearTimeout(id); | ||
}; | ||
/** | ||
* Creates a clone of `buffer`. | ||
* | ||
* @private | ||
* @param {Buffer} buffer The buffer to clone. | ||
* @param {boolean} [isDeep] Specify a deep clone. | ||
* @returns {Buffer} Returns the cloned buffer. | ||
*/ | ||
function cloneBuffer(buffer, isDeep) { | ||
if (isDeep) { | ||
return buffer.slice(); | ||
} | ||
var length = buffer.length, | ||
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(le | ||
ngth); | ||
buffer.copy(result); | ||
return result; | ||
} | ||
/** | ||
* Creates a clone of `arrayBuffer`. | ||
* | ||
* @private | ||
* @param {ArrayBuffer} arrayBuffer The array buffer to clone. | ||
* @returns {ArrayBuffer} Returns the cloned array buffer. | ||
*/ | ||
function cloneArrayBuffer(arrayBuffer) { | ||
var result = new arrayBuffer.constructor(arrayBuffer.byteLength); | ||
new Uint8Array(result).set(new Uint8Array(arrayBuffer)); | ||
return result; | return result; | |
} | } | |
/** | /** | |
* Creates a clone of `set`. | * Creates a clone of `dataView`. | |
* | * | |
* @private | * @private | |
* @param {Object} set The set to clone. | * @param {Object} dataView The data view to clone. | |
* @returns {Object} Returns the cloned set. | * @param {boolean} [isDeep] Specify a deep clone. | |
* @returns {Object} Returns the cloned data view. | ||
*/ | */ | |
function cloneSet(set) { | function cloneDataView(dataView, isDeep) { | |
var Ctor = set.constructor; | var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; | |
return arrayReduce(setToArray(set), addSetEntry, new Ctor); | return new dataView.constructor(buffer, dataView.byteOffset, dataView.byte | |
Length); | ||
} | ||
/** | ||
* Creates a clone of `regexp`. | ||
* | ||
* @private | ||
* @param {Object} regexp The regexp to clone. | ||
* @returns {Object} Returns the cloned regexp. | ||
*/ | ||
function cloneRegExp(regexp) { | ||
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); | ||
result.lastIndex = regexp.lastIndex; | ||
return result; | ||
} | } | |
/** | /** | |
* Creates a clone of the `symbol` object. | * Creates a clone of the `symbol` object. | |
* | * | |
* @private | * @private | |
* @param {Object} symbol The symbol object to clone. | * @param {Object} symbol The symbol object to clone. | |
* @returns {Object} Returns the cloned symbol object. | * @returns {Object} Returns the cloned symbol object. | |
*/ | */ | |
function cloneSymbol(symbol) { | function cloneSymbol(symbol) { | |
return _Symbol ? Object(symbolValueOf.call(symbol)) : {}; | return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; | |
} | } | |
/** | /** | |
* Creates a clone of `typedArray`. | * Creates a clone of `typedArray`. | |
* | * | |
* @private | * @private | |
* @param {Object} typedArray The typed array to clone. | * @param {Object} typedArray The typed array to clone. | |
* @param {boolean} [isDeep] Specify a deep clone. | * @param {boolean} [isDeep] Specify a deep clone. | |
* @returns {Object} Returns the cloned typed array. | * @returns {Object} Returns the cloned typed array. | |
*/ | */ | |
function cloneTypedArray(typedArray, isDeep) { | function cloneTypedArray(typedArray, isDeep) { | |
var buffer = typedArray.buffer, | var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buf | |
Ctor = typedArray.constructor; | fer; | |
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArra | ||
y.length); | ||
} | ||
/** | ||
* Compares values to sort them in ascending order. | ||
* | ||
* @private | ||
* @param {*} value The value to compare. | ||
* @param {*} other The other value to compare. | ||
* @returns {number} Returns the sort order indicator for `value`. | ||
*/ | ||
function compareAscending(value, other) { | ||
if (value !== other) { | ||
var valIsDefined = value !== undefined, | ||
valIsNull = value === null, | ||
valIsReflexive = value === value, | ||
valIsSymbol = isSymbol(value); | ||
return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, typedArray.byteOffs | var othIsDefined = other !== undefined, | |
et, typedArray.length); | othIsNull = other === null, | |
othIsReflexive = other === other, | ||
othIsSymbol = isSymbol(other); | ||
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || | ||
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !oth | ||
IsSymbol) || | ||
(valIsNull && othIsDefined && othIsReflexive) || | ||
(!valIsDefined && othIsReflexive) || | ||
!valIsReflexive) { | ||
return 1; | ||
} | ||
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || | ||
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !val | ||
IsSymbol) || | ||
(othIsNull && valIsDefined && valIsReflexive) || | ||
(!othIsDefined && valIsReflexive) || | ||
!othIsReflexive) { | ||
return -1; | ||
} | ||
} | ||
return 0; | ||
} | ||
/** | ||
* Used by `_.orderBy` to compare multiple properties of a value to another | ||
* and stable sort them. | ||
* | ||
* If `orders` is unspecified, all values are sorted in ascending order. Oth | ||
erwise, | ||
* specify an order of "desc" for descending or "asc" for ascending sort ord | ||
er | ||
* of corresponding values. | ||
* | ||
* @private | ||
* @param {Object} object The object to compare. | ||
* @param {Object} other The other object to compare. | ||
* @param {boolean[]|string[]} orders The order to sort by for each property | ||
. | ||
* @returns {number} Returns the sort order indicator for `object`. | ||
*/ | ||
function compareMultiple(object, other, orders) { | ||
var index = -1, | ||
objCriteria = object.criteria, | ||
othCriteria = other.criteria, | ||
length = objCriteria.length, | ||
ordersLength = orders.length; | ||
while (++index < length) { | ||
var result = compareAscending(objCriteria[index], othCriteria[index]); | ||
if (result) { | ||
if (index >= ordersLength) { | ||
return result; | ||
} | ||
var order = orders[index]; | ||
return result * (order == 'desc' ? -1 : 1); | ||
} | ||
} | ||
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applicatio | ||
ns | ||
// that causes it, under certain circumstances, to provide the same value | ||
for | ||
// `object` and `other`. See https://github.com/jashkenas/underscore/pull/ | ||
1247 | ||
// for more details. | ||
// | ||
// This also ensures a stable sort in V8 and other engines. | ||
// See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details | ||
. | ||
return object.index - other.index; | ||
} | } | |
/** | /** | |
* Creates an array that is the composition of partially applied arguments, | * Creates an array that is the composition of partially applied arguments, | |
* placeholders, and provided arguments into a single array of arguments. | * placeholders, and provided arguments into a single array of arguments. | |
* | * | |
* @private | * @private | |
* @param {Array|Object} args The provided arguments. | * @param {Array} args The provided arguments. | |
* @param {Array} partials The arguments to prepend to those provided. | * @param {Array} partials The arguments to prepend to those provided. | |
* @param {Array} holders The `partials` placeholder indexes. | * @param {Array} holders The `partials` placeholder indexes. | |
* @params {boolean} [isCurried] Specify composing for a curried function. | ||
* @returns {Array} Returns the new array of composed arguments. | * @returns {Array} Returns the new array of composed arguments. | |
*/ | */ | |
function composeArgs(args, partials, holders) { | function composeArgs(args, partials, holders, isCurried) { | |
var holdersLength = holders.length, | var argsIndex = -1, | |
argsIndex = -1, | argsLength = args.length, | |
argsLength = nativeMax(args.length - holdersLength, 0), | holdersLength = holders.length, | |
leftIndex = -1, | leftIndex = -1, | |
leftLength = partials.length, | leftLength = partials.length, | |
result = Array(leftLength + argsLength); | rangeLength = nativeMax(argsLength - holdersLength, 0), | |
result = Array(leftLength + rangeLength), | ||
isUncurried = !isCurried; | ||
while (++leftIndex < leftLength) { | while (++leftIndex < leftLength) { | |
result[leftIndex] = partials[leftIndex]; | result[leftIndex] = partials[leftIndex]; | |
} | } | |
while (++argsIndex < holdersLength) { | while (++argsIndex < holdersLength) { | |
result[holders[argsIndex]] = args[argsIndex]; | if (isUncurried || argsIndex < argsLength) { | |
result[holders[argsIndex]] = args[argsIndex]; | ||
} | ||
} | } | |
while (argsLength--) { | while (rangeLength--) { | |
result[leftIndex++] = args[argsIndex++]; | result[leftIndex++] = args[argsIndex++]; | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* This function is like `composeArgs` except that the arguments composition | * This function is like `composeArgs` except that the arguments composition | |
* is tailored for `_.partialRight`. | * is tailored for `_.partialRight`. | |
* | * | |
* @private | * @private | |
* @param {Array|Object} args The provided arguments. | * @param {Array} args The provided arguments. | |
* @param {Array} partials The arguments to append to those provided. | * @param {Array} partials The arguments to append to those provided. | |
* @param {Array} holders The `partials` placeholder indexes. | * @param {Array} holders The `partials` placeholder indexes. | |
* @params {boolean} [isCurried] Specify composing for a curried function. | ||
* @returns {Array} Returns the new array of composed arguments. | * @returns {Array} Returns the new array of composed arguments. | |
*/ | */ | |
function composeArgsRight(args, partials, holders) { | function composeArgsRight(args, partials, holders, isCurried) { | |
var holdersIndex = -1, | var argsIndex = -1, | |
argsLength = args.length, | ||
holdersIndex = -1, | ||
holdersLength = holders.length, | holdersLength = holders.length, | |
argsIndex = -1, | ||
argsLength = nativeMax(args.length - holdersLength, 0), | ||
rightIndex = -1, | rightIndex = -1, | |
rightLength = partials.length, | rightLength = partials.length, | |
result = Array(argsLength + rightLength); | rangeLength = nativeMax(argsLength - holdersLength, 0), | |
result = Array(rangeLength + rightLength), | ||
isUncurried = !isCurried; | ||
while (++argsIndex < argsLength) { | while (++argsIndex < rangeLength) { | |
result[argsIndex] = args[argsIndex]; | result[argsIndex] = args[argsIndex]; | |
} | } | |
var offset = argsIndex; | var offset = argsIndex; | |
while (++rightIndex < rightLength) { | while (++rightIndex < rightLength) { | |
result[offset + rightIndex] = partials[rightIndex]; | result[offset + rightIndex] = partials[rightIndex]; | |
} | } | |
while (++holdersIndex < holdersLength) { | while (++holdersIndex < holdersLength) { | |
result[offset + holders[holdersIndex]] = args[argsIndex++]; | if (isUncurried || argsIndex < argsLength) { | |
result[offset + holders[holdersIndex]] = args[argsIndex++]; | ||
} | ||
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* Copies the values of `source` to `array`. | * Copies the values of `source` to `array`. | |
* | * | |
* @private | * @private | |
* @param {Array} source The array to copy values from. | * @param {Array} source The array to copy values from. | |
* @param {Array} [array=[]] The array to copy values to. | * @param {Array} [array=[]] The array to copy values to. | |
skipping to change at line 3774 | skipping to change at line 4817 | |
array[index] = source[index]; | array[index] = source[index]; | |
} | } | |
return array; | return array; | |
} | } | |
/** | /** | |
* Copies properties of `source` to `object`. | * Copies properties of `source` to `object`. | |
* | * | |
* @private | * @private | |
* @param {Object} source The object to copy properties from. | * @param {Object} source The object to copy properties from. | |
* @param {Array} props The property names to copy. | * @param {Array} props The property identifiers to copy. | |
* @param {Object} [object={}] The object to copy properties to. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function copyObject(source, props, object) { | ||
return copyObjectWith(source, props, object); | ||
} | ||
/** | ||
* This function is like `copyObject` except that it accepts a function to | ||
* customize copied values. | ||
* | ||
* @private | ||
* @param {Object} source The object to copy properties from. | ||
* @param {Array} props The property names to copy. | ||
* @param {Object} [object={}] The object to copy properties to. | * @param {Object} [object={}] The object to copy properties to. | |
* @param {Function} [customizer] The function to customize copied values. | * @param {Function} [customizer] The function to customize copied values. | |
* @returns {Object} Returns `object`. | * @returns {Object} Returns `object`. | |
*/ | */ | |
function copyObjectWith(source, props, object, customizer) { | function copyObject(source, props, object, customizer) { | |
var isNew = !object; | ||
object || (object = {}); | object || (object = {}); | |
var index = -1, | var index = -1, | |
length = props.length; | length = props.length; | |
while (++index < length) { | while (++index < length) { | |
var key = props[index], | var key = props[index]; | |
newValue = customizer ? customizer(object[key], source[key], key, ob | ||
ject, source) : source[key]; | var newValue = customizer | |
? customizer(object[key], source[key], key, object, source) | ||
: undefined; | ||
assignValue(object, key, newValue); | if (newValue === undefined) { | |
newValue = source[key]; | ||
} | ||
if (isNew) { | ||
baseAssignValue(object, key, newValue); | ||
} else { | ||
assignValue(object, key, newValue); | ||
} | ||
} | } | |
return object; | return object; | |
} | } | |
/** | /** | |
* Copies own symbol properties of `source` to `object`. | * Copies own symbols of `source` to `object`. | |
* | * | |
* @private | * @private | |
* @param {Object} source The object to copy symbols from. | * @param {Object} source The object to copy symbols from. | |
* @param {Object} [object={}] The object to copy symbols to. | * @param {Object} [object={}] The object to copy symbols to. | |
* @returns {Object} Returns `object`. | * @returns {Object} Returns `object`. | |
*/ | */ | |
function copySymbols(source, object) { | function copySymbols(source, object) { | |
return copyObject(source, getSymbols(source), object); | return copyObject(source, getSymbols(source), object); | |
} | } | |
/** | /** | |
* Copies own and inherited symbols of `source` to `object`. | ||
* | ||
* @private | ||
* @param {Object} source The object to copy symbols from. | ||
* @param {Object} [object={}] The object to copy symbols to. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function copySymbolsIn(source, object) { | ||
return copyObject(source, getSymbolsIn(source), object); | ||
} | ||
/** | ||
* Creates a function like `_.groupBy`. | * Creates a function like `_.groupBy`. | |
* | * | |
* @private | * @private | |
* @param {Function} setter The function to set keys and values of the accum | * @param {Function} setter The function to set accumulator values. | |
ulator object. | * @param {Function} [initializer] The accumulator object initializer. | |
* @param {Function} [initializer] The function to initialize the accumulato | ||
r object. | ||
* @returns {Function} Returns the new aggregator function. | * @returns {Function} Returns the new aggregator function. | |
*/ | */ | |
function createAggregator(setter, initializer) { | function createAggregator(setter, initializer) { | |
return function(collection, iteratee) { | return function(collection, iteratee) { | |
var result = initializer ? initializer() : {}; | var func = isArray(collection) ? arrayAggregator : baseAggregator, | |
iteratee = getIteratee(iteratee); | accumulator = initializer ? initializer() : {}; | |
if (isArray(collection)) { | ||
var index = -1, | ||
length = collection.length; | ||
while (++index < length) { | return func(collection, setter, getIteratee(iteratee, 2), accumulator); | |
var value = collection[index]; | ||
setter(result, value, iteratee(value), collection); | ||
} | ||
} else { | ||
baseEach(collection, function(value, key, collection) { | ||
setter(result, value, iteratee(value), collection); | ||
}); | ||
} | ||
return result; | ||
}; | }; | |
} | } | |
/** | /** | |
* Creates a function like `_.assign`. | * Creates a function like `_.assign`. | |
* | * | |
* @private | * @private | |
* @param {Function} assigner The function to assign values. | * @param {Function} assigner The function to assign values. | |
* @returns {Function} Returns the new assigner function. | * @returns {Function} Returns the new assigner function. | |
*/ | */ | |
function createAssigner(assigner) { | function createAssigner(assigner) { | |
return rest(function(object, sources) { | return baseRest(function(object, sources) { | |
var index = -1, | var index = -1, | |
length = sources.length, | length = sources.length, | |
customizer = length > 1 ? sources[length - 1] : undefined, | customizer = length > 1 ? sources[length - 1] : undefined, | |
guard = length > 2 ? sources[2] : undefined; | guard = length > 2 ? sources[2] : undefined; | |
customizer = typeof customizer == 'function' ? (length--, customizer) : | customizer = (assigner.length > 3 && typeof customizer == 'function') | |
undefined; | ? (length--, customizer) | |
: undefined; | ||
if (guard && isIterateeCall(sources[0], sources[1], guard)) { | if (guard && isIterateeCall(sources[0], sources[1], guard)) { | |
customizer = length < 3 ? undefined : customizer; | customizer = length < 3 ? undefined : customizer; | |
length = 1; | length = 1; | |
} | } | |
object = Object(object); | object = Object(object); | |
while (++index < length) { | while (++index < length) { | |
var source = sources[index]; | var source = sources[index]; | |
if (source) { | if (source) { | |
assigner(object, source, customizer); | assigner(object, source, index, customizer); | |
} | } | |
} | } | |
return object; | return object; | |
}); | }); | |
} | } | |
/** | /** | |
* Creates a `baseEach` or `baseEachRight` function. | * Creates a `baseEach` or `baseEachRight` function. | |
* | * | |
* @private | * @private | |
skipping to change at line 3910 | skipping to change at line 4952 | |
while ((fromRight ? index-- : ++index < length)) { | while ((fromRight ? index-- : ++index < length)) { | |
if (iteratee(iterable[index], index, iterable) === false) { | if (iteratee(iterable[index], index, iterable) === false) { | |
break; | break; | |
} | } | |
} | } | |
return collection; | return collection; | |
}; | }; | |
} | } | |
/** | /** | |
* Creates a base function for methods like `_.forIn`. | * Creates a base function for methods like `_.forIn` and `_.forOwn`. | |
* | * | |
* @private | * @private | |
* @param {boolean} [fromRight] Specify iterating from right to left. | * @param {boolean} [fromRight] Specify iterating from right to left. | |
* @returns {Function} Returns the new base function. | * @returns {Function} Returns the new base function. | |
*/ | */ | |
function createBaseFor(fromRight) { | function createBaseFor(fromRight) { | |
return function(object, iteratee, keysFunc) { | return function(object, iteratee, keysFunc) { | |
var index = -1, | var index = -1, | |
iterable = Object(object), | iterable = Object(object), | |
props = keysFunc(object), | props = keysFunc(object), | |
skipping to change at line 3939 | skipping to change at line 4981 | |
return object; | return object; | |
}; | }; | |
} | } | |
/** | /** | |
* Creates a function that wraps `func` to invoke it with the optional `this ` | * Creates a function that wraps `func` to invoke it with the optional `this ` | |
* binding of `thisArg`. | * binding of `thisArg`. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to wrap. | * @param {Function} func The function to wrap. | |
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. | * @param {number} bitmask The bitmask flags. See `createWrap` for more deta ils. | |
* @param {*} [thisArg] The `this` binding of `func`. | * @param {*} [thisArg] The `this` binding of `func`. | |
* @returns {Function} Returns the new wrapped function. | * @returns {Function} Returns the new wrapped function. | |
*/ | */ | |
function createBaseWrapper(func, bitmask, thisArg) { | function createBind(func, bitmask, thisArg) { | |
var isBind = bitmask & BIND_FLAG, | var isBind = bitmask & WRAP_BIND_FLAG, | |
Ctor = createCtorWrapper(func); | Ctor = createCtor(func); | |
function wrapper() { | function wrapper() { | |
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : fun c; | var fn = (this && this !== root && this instanceof wrapper) ? Ctor : fun c; | |
return fn.apply(isBind ? thisArg : this, arguments); | return fn.apply(isBind ? thisArg : this, arguments); | |
} | } | |
return wrapper; | return wrapper; | |
} | } | |
/** | /** | |
* Creates a function like `_.lowerFirst`. | * Creates a function like `_.lowerFirst`. | |
* | * | |
* @private | * @private | |
* @param {string} methodName The name of the `String` case method to use. | * @param {string} methodName The name of the `String` case method to use. | |
* @returns {Function} Returns the new function. | * @returns {Function} Returns the new case function. | |
*/ | */ | |
function createCaseFirst(methodName) { | function createCaseFirst(methodName) { | |
return function(string) { | return function(string) { | |
string = toString(string); | string = toString(string); | |
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) | var strSymbols = hasUnicode(string) | |
: undefined, | ? stringToArray(string) | |
chr = strSymbols ? strSymbols[0] : string.charAt(0), | : undefined; | |
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice( | ||
1); | var chr = strSymbols | |
? strSymbols[0] | ||
: string.charAt(0); | ||
var trailing = strSymbols | ||
? castSlice(strSymbols, 1).join('') | ||
: string.slice(1); | ||
return chr[methodName]() + trailing; | return chr[methodName]() + trailing; | |
}; | }; | |
} | } | |
/** | /** | |
* Creates a function like `_.camelCase`. | * Creates a function like `_.camelCase`. | |
* | * | |
* @private | * @private | |
* @param {Function} callback The function to combine each word. | * @param {Function} callback The function to combine each word. | |
* @returns {Function} Returns the new compounder function. | * @returns {Function} Returns the new compounder function. | |
*/ | */ | |
function createCompounder(callback) { | function createCompounder(callback) { | |
return function(string) { | return function(string) { | |
return arrayReduce(words(deburr(string)), callback, ''); | return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); | |
}; | }; | |
} | } | |
/** | /** | |
* Creates a function that produces an instance of `Ctor` regardless of | * Creates a function that produces an instance of `Ctor` regardless of | |
* whether it was invoked as part of a `new` expression or by `call` or `app ly`. | * whether it was invoked as part of a `new` expression or by `call` or `app ly`. | |
* | * | |
* @private | * @private | |
* @param {Function} Ctor The constructor to wrap. | * @param {Function} Ctor The constructor to wrap. | |
* @returns {Function} Returns the new wrapped function. | * @returns {Function} Returns the new wrapped function. | |
*/ | */ | |
function createCtorWrapper(Ctor) { | function createCtor(Ctor) { | |
return function() { | return function() { | |
// Use a `switch` statement to work with class constructors. | // Use a `switch` statement to work with class constructors. See | |
// See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-functi | // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-o | |
on-objects-call-thisargument-argumentslist | bjects-call-thisargument-argumentslist | |
// for more details. | // for more details. | |
var args = arguments; | var args = arguments; | |
switch (args.length) { | switch (args.length) { | |
case 0: return new Ctor; | case 0: return new Ctor; | |
case 1: return new Ctor(args[0]); | case 1: return new Ctor(args[0]); | |
case 2: return new Ctor(args[0], args[1]); | case 2: return new Ctor(args[0], args[1]); | |
case 3: return new Ctor(args[0], args[1], args[2]); | case 3: return new Ctor(args[0], args[1], args[2]); | |
case 4: return new Ctor(args[0], args[1], args[2], args[3]); | case 4: return new Ctor(args[0], args[1], args[2], args[3]); | |
case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); | case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); | |
case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], a rgs[5]); | case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], a rgs[5]); | |
skipping to change at line 4024 | skipping to change at line 5074 | |
// See https://es5.github.io/#x13.2.2 for more details. | // See https://es5.github.io/#x13.2.2 for more details. | |
return isObject(result) ? result : thisBinding; | return isObject(result) ? result : thisBinding; | |
}; | }; | |
} | } | |
/** | /** | |
* Creates a function that wraps `func` to enable currying. | * Creates a function that wraps `func` to enable currying. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to wrap. | * @param {Function} func The function to wrap. | |
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. | * @param {number} bitmask The bitmask flags. See `createWrap` for more deta ils. | |
* @param {number} arity The arity of `func`. | * @param {number} arity The arity of `func`. | |
* @returns {Function} Returns the new wrapped function. | * @returns {Function} Returns the new wrapped function. | |
*/ | */ | |
function createCurryWrapper(func, bitmask, arity) { | function createCurry(func, bitmask, arity) { | |
var Ctor = createCtorWrapper(func); | var Ctor = createCtor(func); | |
function wrapper() { | function wrapper() { | |
var length = arguments.length, | var length = arguments.length, | |
index = length, | ||
args = Array(length), | args = Array(length), | |
fn = (this && this !== root && this instanceof wrapper) ? Ctor : fun | index = length, | |
c, | placeholder = getHolder(wrapper); | |
placeholder = wrapper.placeholder; | ||
while (index--) { | while (index--) { | |
args[index] = arguments[index]; | args[index] = arguments[index]; | |
} | } | |
var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) | var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) | |
? [] | ? [] | |
: replaceHolders(args, placeholder); | : replaceHolders(args, placeholder); | |
length -= holders.length; | length -= holders.length; | |
return length < arity | if (length < arity) { | |
? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder | return createRecurry( | |
, undefined, args, holders, undefined, undefined, arity - length) | func, bitmask, createHybrid, wrapper.placeholder, undefined, | |
: apply(fn, this, args); | args, holders, undefined, undefined, arity - length); | |
} | ||
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : fun | ||
c; | ||
return apply(fn, this, args); | ||
} | } | |
return wrapper; | return wrapper; | |
} | } | |
/** | /** | |
* Creates a `_.find` or `_.findLast` function. | ||
* | ||
* @private | ||
* @param {Function} findIndexFunc The function to find the collection index | ||
. | ||
* @returns {Function} Returns the new find function. | ||
*/ | ||
function createFind(findIndexFunc) { | ||
return function(collection, predicate, fromIndex) { | ||
var iterable = Object(collection); | ||
if (!isArrayLike(collection)) { | ||
var iteratee = getIteratee(predicate, 3); | ||
collection = keys(collection); | ||
predicate = function(key) { return iteratee(iterable[key], key, iterab | ||
le); }; | ||
} | ||
var index = findIndexFunc(collection, predicate, fromIndex); | ||
return index > -1 ? iterable[iteratee ? collection[index] : index] : und | ||
efined; | ||
}; | ||
} | ||
/** | ||
* Creates a `_.flow` or `_.flowRight` function. | * Creates a `_.flow` or `_.flowRight` function. | |
* | * | |
* @private | * @private | |
* @param {boolean} [fromRight] Specify iterating from right to left. | * @param {boolean} [fromRight] Specify iterating from right to left. | |
* @returns {Function} Returns the new flow function. | * @returns {Function} Returns the new flow function. | |
*/ | */ | |
function createFlow(fromRight) { | function createFlow(fromRight) { | |
return rest(function(funcs) { | return flatRest(function(funcs) { | |
funcs = baseFlatten(funcs); | ||
var length = funcs.length, | var length = funcs.length, | |
index = length, | index = length, | |
prereq = LodashWrapper.prototype.thru; | prereq = LodashWrapper.prototype.thru; | |
if (fromRight) { | if (fromRight) { | |
funcs.reverse(); | funcs.reverse(); | |
} | } | |
while (index--) { | while (index--) { | |
var func = funcs[index]; | var func = funcs[index]; | |
if (typeof func != 'function') { | if (typeof func != 'function') { | |
skipping to change at line 4087 | skipping to change at line 5158 | |
var wrapper = new LodashWrapper([], true); | var wrapper = new LodashWrapper([], true); | |
} | } | |
} | } | |
index = wrapper ? index : length; | index = wrapper ? index : length; | |
while (++index < length) { | while (++index < length) { | |
func = funcs[index]; | func = funcs[index]; | |
var funcName = getFuncName(func), | var funcName = getFuncName(func), | |
data = funcName == 'wrapper' ? getData(func) : undefined; | data = funcName == 'wrapper' ? getData(func) : undefined; | |
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | | if (data && isLaziable(data[0]) && | |
PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { | data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | |
| WRAP_REARG_FLAG) && | ||
!data[4].length && data[9] == 1 | ||
) { | ||
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); | wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); | |
} else { | } else { | |
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName] | wrapper = (func.length == 1 && isLaziable(func)) | |
() : wrapper.thru(func); | ? wrapper[funcName]() | |
: wrapper.thru(func); | ||
} | } | |
} | } | |
return function() { | return function() { | |
var args = arguments, | var args = arguments, | |
value = args[0]; | value = args[0]; | |
if (wrapper && args.length == 1 && isArray(value) && value.length >= L ARGE_ARRAY_SIZE) { | if (wrapper && args.length == 1 && isArray(value)) { | |
return wrapper.plant(value).value(); | return wrapper.plant(value).value(); | |
} | } | |
var index = 0, | var index = 0, | |
result = length ? funcs[index].apply(this, args) : value; | result = length ? funcs[index].apply(this, args) : value; | |
while (++index < length) { | while (++index < length) { | |
result = funcs[index].call(this, result); | result = funcs[index].call(this, result); | |
} | } | |
return result; | return result; | |
}; | }; | |
}); | }); | |
} | } | |
/** | /** | |
* Creates a function that wraps `func` to invoke it with optional `this` | * Creates a function that wraps `func` to invoke it with optional `this` | |
* binding of `thisArg`, partial application, and currying. | * binding of `thisArg`, partial application, and currying. | |
* | * | |
* @private | * @private | |
* @param {Function|string} func The function or method name to wrap. | * @param {Function|string} func The function or method name to wrap. | |
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. | * @param {number} bitmask The bitmask flags. See `createWrap` for more deta ils. | |
* @param {*} [thisArg] The `this` binding of `func`. | * @param {*} [thisArg] The `this` binding of `func`. | |
* @param {Array} [partials] The arguments to prepend to those provided to t | * @param {Array} [partials] The arguments to prepend to those provided to | |
he new function. | * the new function. | |
* @param {Array} [holders] The `partials` placeholder indexes. | * @param {Array} [holders] The `partials` placeholder indexes. | |
* @param {Array} [partialsRight] The arguments to append to those provided | * @param {Array} [partialsRight] The arguments to append to those provided | |
to the new function. | * to the new function. | |
* @param {Array} [holdersRight] The `partialsRight` placeholder indexes. | * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. | |
* @param {Array} [argPos] The argument positions of the new function. | * @param {Array} [argPos] The argument positions of the new function. | |
* @param {number} [ary] The arity cap of `func`. | * @param {number} [ary] The arity cap of `func`. | |
* @param {number} [arity] The arity of `func`. | * @param {number} [arity] The arity of `func`. | |
* @returns {Function} Returns the new wrapped function. | * @returns {Function} Returns the new wrapped function. | |
*/ | */ | |
function createHybridWrapper(func, bitmask, thisArg, partials, holders, part | function createHybrid(func, bitmask, thisArg, partials, holders, partialsRig | |
ialsRight, holdersRight, argPos, ary, arity) { | ht, holdersRight, argPos, ary, arity) { | |
var isAry = bitmask & ARY_FLAG, | var isAry = bitmask & WRAP_ARY_FLAG, | |
isBind = bitmask & BIND_FLAG, | isBind = bitmask & WRAP_BIND_FLAG, | |
isBindKey = bitmask & BIND_KEY_FLAG, | isBindKey = bitmask & WRAP_BIND_KEY_FLAG, | |
isCurry = bitmask & CURRY_FLAG, | isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), | |
isCurryRight = bitmask & CURRY_RIGHT_FLAG, | isFlip = bitmask & WRAP_FLIP_FLAG, | |
isFlip = bitmask & FLIP_FLAG, | Ctor = isBindKey ? undefined : createCtor(func); | |
Ctor = isBindKey ? undefined : createCtorWrapper(func); | ||
function wrapper() { | function wrapper() { | |
var length = arguments.length, | var length = arguments.length, | |
index = length, | args = Array(length), | |
args = Array(length); | index = length; | |
while (index--) { | while (index--) { | |
args[index] = arguments[index]; | args[index] = arguments[index]; | |
} | } | |
if (isCurried) { | ||
var placeholder = getHolder(wrapper), | ||
holdersCount = countHolders(args, placeholder); | ||
} | ||
if (partials) { | if (partials) { | |
args = composeArgs(args, partials, holders); | args = composeArgs(args, partials, holders, isCurried); | |
} | } | |
if (partialsRight) { | if (partialsRight) { | |
args = composeArgsRight(args, partialsRight, holdersRight); | args = composeArgsRight(args, partialsRight, holdersRight, isCurried); | |
} | } | |
if (isCurry || isCurryRight) { | length -= holdersCount; | |
var placeholder = wrapper.placeholder, | if (isCurried && length < arity) { | |
argsHolders = replaceHolders(args, placeholder); | var newHolders = replaceHolders(args, placeholder); | |
return createRecurry( | ||
length -= argsHolders.length; | func, bitmask, createHybrid, wrapper.placeholder, thisArg, | |
if (length < arity) { | args, newHolders, argPos, ary, arity - length | |
return createRecurryWrapper(func, bitmask, createHybridWrapper, plac | ); | |
eholder, thisArg, args, argsHolders, argPos, ary, arity - length); | ||
} | ||
} | } | |
var thisBinding = isBind ? thisArg : this, | var thisBinding = isBind ? thisArg : this, | |
fn = isBindKey ? thisBinding[func] : func; | fn = isBindKey ? thisBinding[func] : func; | |
length = args.length; | ||
if (argPos) { | if (argPos) { | |
args = reorder(args, argPos); | args = reorder(args, argPos); | |
} else if (isFlip && args.length > 1) { | } else if (isFlip && length > 1) { | |
args.reverse(); | args.reverse(); | |
} | } | |
if (isAry && ary < args.length) { | if (isAry && ary < length) { | |
args.length = ary; | args.length = ary; | |
} | } | |
if (this && this !== root && this instanceof wrapper) { | if (this && this !== root && this instanceof wrapper) { | |
fn = Ctor || createCtorWrapper(fn); | fn = Ctor || createCtor(fn); | |
} | } | |
return fn.apply(thisBinding, args); | return fn.apply(thisBinding, args); | |
} | } | |
return wrapper; | return wrapper; | |
} | } | |
/** | /** | |
* Creates a function like `_.invertBy`. | ||
* | ||
* @private | ||
* @param {Function} setter The function to set accumulator values. | ||
* @param {Function} toIteratee The function to resolve iteratees. | ||
* @returns {Function} Returns the new inverter function. | ||
*/ | ||
function createInverter(setter, toIteratee) { | ||
return function(object, iteratee) { | ||
return baseInverter(object, setter, toIteratee(iteratee), {}); | ||
}; | ||
} | ||
/** | ||
* Creates a function that performs a mathematical operation on two values. | ||
* | ||
* @private | ||
* @param {Function} operator The function to perform the operation. | ||
* @param {number} [defaultValue] The value used for `undefined` arguments. | ||
* @returns {Function} Returns the new mathematical operation function. | ||
*/ | ||
function createMathOperation(operator, defaultValue) { | ||
return function(value, other) { | ||
var result; | ||
if (value === undefined && other === undefined) { | ||
return defaultValue; | ||
} | ||
if (value !== undefined) { | ||
result = value; | ||
} | ||
if (other !== undefined) { | ||
if (result === undefined) { | ||
return other; | ||
} | ||
if (typeof value == 'string' || typeof other == 'string') { | ||
value = baseToString(value); | ||
other = baseToString(other); | ||
} else { | ||
value = baseToNumber(value); | ||
other = baseToNumber(other); | ||
} | ||
result = operator(value, other); | ||
} | ||
return result; | ||
}; | ||
} | ||
/** | ||
* Creates a function like `_.over`. | * Creates a function like `_.over`. | |
* | * | |
* @private | * @private | |
* @param {Function} arrayFunc The function to iterate over iteratees. | * @param {Function} arrayFunc The function to iterate over iteratees. | |
* @returns {Function} Returns the new invoker function. | * @returns {Function} Returns the new over function. | |
*/ | */ | |
function createOver(arrayFunc) { | function createOver(arrayFunc) { | |
return rest(function(iteratees) { | return flatRest(function(iteratees) { | |
iteratees = arrayMap(baseFlatten(iteratees), getIteratee()); | iteratees = arrayMap(iteratees, baseUnary(getIteratee())); | |
return rest(function(args) { | return baseRest(function(args) { | |
var thisArg = this; | var thisArg = this; | |
return arrayFunc(iteratees, function(iteratee) { | return arrayFunc(iteratees, function(iteratee) { | |
return apply(iteratee, thisArg, args); | return apply(iteratee, thisArg, args); | |
}); | }); | |
}); | }); | |
}); | }); | |
} | } | |
/** | /** | |
* Creates the padding for `string` based on `length`. The `chars` string | * Creates the padding for `string` based on `length`. The `chars` string | |
* is truncated if the number of characters exceeds `length`. | * is truncated if the number of characters exceeds `length`. | |
* | * | |
* @private | * @private | |
* @param {string} string The string to create padding for. | * @param {number} length The padding length. | |
* @param {number} [length=0] The padding length. | ||
* @param {string} [chars=' '] The string used as padding. | * @param {string} [chars=' '] The string used as padding. | |
* @returns {string} Returns the padding for `string`. | * @returns {string} Returns the padding for `string`. | |
*/ | */ | |
function createPadding(string, length, chars) { | function createPadding(length, chars) { | |
length = toInteger(length); | chars = chars === undefined ? ' ' : baseToString(chars); | |
var strLength = stringSize(string); | var charsLength = chars.length; | |
if (!length || strLength >= length) { | if (charsLength < 2) { | |
return ''; | return charsLength ? baseRepeat(chars, length) : chars; | |
} | } | |
var padLength = length - strLength; | var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); | |
chars = chars === undefined ? ' ' : (chars + ''); | return hasUnicode(chars) | |
? castSlice(stringToArray(result), 0, length).join('') | ||
var result = repeat(chars, nativeCeil(padLength / stringSize(chars))); | : result.slice(0, length); | |
return reHasComplexSymbol.test(chars) | ||
? stringToArray(result).slice(0, padLength).join('') | ||
: result.slice(0, padLength); | ||
} | } | |
/** | /** | |
* Creates a function that wraps `func` to invoke it with the optional `this | * Creates a function that wraps `func` to invoke it with the `this` binding | |
` | * of `thisArg` and `partials` prepended to the arguments it receives. | |
* binding of `thisArg` and the `partials` prepended to those provided to | ||
* the wrapper. | ||
* | * | |
* @private | * @private | |
* @param {Function} func The function to wrap. | * @param {Function} func The function to wrap. | |
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. | * @param {number} bitmask The bitmask flags. See `createWrap` for more deta ils. | |
* @param {*} thisArg The `this` binding of `func`. | * @param {*} thisArg The `this` binding of `func`. | |
* @param {Array} partials The arguments to prepend to those provided to the | * @param {Array} partials The arguments to prepend to those provided to | |
new function. | * the new function. | |
* @returns {Function} Returns the new wrapped function. | * @returns {Function} Returns the new wrapped function. | |
*/ | */ | |
function createPartialWrapper(func, bitmask, thisArg, partials) { | function createPartial(func, bitmask, thisArg, partials) { | |
var isBind = bitmask & BIND_FLAG, | var isBind = bitmask & WRAP_BIND_FLAG, | |
Ctor = createCtorWrapper(func); | Ctor = createCtor(func); | |
function wrapper() { | function wrapper() { | |
var argsIndex = -1, | var argsIndex = -1, | |
argsLength = arguments.length, | argsLength = arguments.length, | |
leftIndex = -1, | leftIndex = -1, | |
leftLength = partials.length, | leftLength = partials.length, | |
args = Array(leftLength + argsLength), | args = Array(leftLength + argsLength), | |
fn = (this && this !== root && this instanceof wrapper) ? Ctor : fun c; | fn = (this && this !== root && this instanceof wrapper) ? Ctor : fun c; | |
while (++leftIndex < leftLength) { | while (++leftIndex < leftLength) { | |
skipping to change at line 4272 | skipping to change at line 5397 | |
* @private | * @private | |
* @param {boolean} [fromRight] Specify iterating from right to left. | * @param {boolean} [fromRight] Specify iterating from right to left. | |
* @returns {Function} Returns the new range function. | * @returns {Function} Returns the new range function. | |
*/ | */ | |
function createRange(fromRight) { | function createRange(fromRight) { | |
return function(start, end, step) { | return function(start, end, step) { | |
if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { | if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { | |
end = step = undefined; | end = step = undefined; | |
} | } | |
// Ensure the sign of `-0` is preserved. | // Ensure the sign of `-0` is preserved. | |
start = toNumber(start); | start = toFinite(start); | |
start = start === start ? start : 0; | ||
if (end === undefined) { | if (end === undefined) { | |
end = start; | end = start; | |
start = 0; | start = 0; | |
} else { | } else { | |
end = toNumber(end) || 0; | end = toFinite(end); | |
} | } | |
step = step === undefined ? (start < end ? 1 : -1) : (toNumber(step) || 0); | step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); | |
return baseRange(start, end, step, fromRight); | return baseRange(start, end, step, fromRight); | |
}; | }; | |
} | } | |
/** | /** | |
* Creates a function that performs a relational operation on two values. | ||
* | ||
* @private | ||
* @param {Function} operator The function to perform the operation. | ||
* @returns {Function} Returns the new relational operation function. | ||
*/ | ||
function createRelationalOperation(operator) { | ||
return function(value, other) { | ||
if (!(typeof value == 'string' && typeof other == 'string')) { | ||
value = toNumber(value); | ||
other = toNumber(other); | ||
} | ||
return operator(value, other); | ||
}; | ||
} | ||
/** | ||
* Creates a function that wraps `func` to continue currying. | * Creates a function that wraps `func` to continue currying. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to wrap. | * @param {Function} func The function to wrap. | |
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. | * @param {number} bitmask The bitmask flags. See `createWrap` for more deta ils. | |
* @param {Function} wrapFunc The function to create the `func` wrapper. | * @param {Function} wrapFunc The function to create the `func` wrapper. | |
* @param {*} placeholder The placeholder to replace. | * @param {*} placeholder The placeholder value. | |
* @param {*} [thisArg] The `this` binding of `func`. | * @param {*} [thisArg] The `this` binding of `func`. | |
* @param {Array} [partials] The arguments to prepend to those provided to t | * @param {Array} [partials] The arguments to prepend to those provided to | |
he new function. | * the new function. | |
* @param {Array} [holders] The `partials` placeholder indexes. | * @param {Array} [holders] The `partials` placeholder indexes. | |
* @param {Array} [argPos] The argument positions of the new function. | * @param {Array} [argPos] The argument positions of the new function. | |
* @param {number} [ary] The arity cap of `func`. | * @param {number} [ary] The arity cap of `func`. | |
* @param {number} [arity] The arity of `func`. | * @param {number} [arity] The arity of `func`. | |
* @returns {Function} Returns the new wrapped function. | * @returns {Function} Returns the new wrapped function. | |
*/ | */ | |
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, | function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partia | |
partials, holders, argPos, ary, arity) { | ls, holders, argPos, ary, arity) { | |
var isCurry = bitmask & CURRY_FLAG, | var isCurry = bitmask & WRAP_CURRY_FLAG, | |
newArgPos = argPos ? copyArray(argPos) : undefined, | newHolders = isCurry ? holders : undefined, | |
newsHolders = isCurry ? holders : undefined, | ||
newHoldersRight = isCurry ? undefined : holders, | newHoldersRight = isCurry ? undefined : holders, | |
newPartials = isCurry ? partials : undefined, | newPartials = isCurry ? partials : undefined, | |
newPartialsRight = isCurry ? undefined : partials; | newPartialsRight = isCurry ? undefined : partials; | |
bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); | bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); | |
bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); | bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); | |
if (!(bitmask & CURRY_BOUND_FLAG)) { | if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { | |
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); | bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); | |
} | } | |
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartia | var newData = [ | |
lsRight, newHoldersRight, newArgPos, ary, arity], | func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, | |
result = wrapFunc.apply(undefined, newData); | newHoldersRight, argPos, ary, arity | |
]; | ||
var result = wrapFunc.apply(undefined, newData); | ||
if (isLaziable(func)) { | if (isLaziable(func)) { | |
setData(result, newData); | setData(result, newData); | |
} | } | |
result.placeholder = placeholder; | result.placeholder = placeholder; | |
return result; | return setWrapToString(result, func, bitmask); | |
} | } | |
/** | /** | |
* Creates a function like `_.round`. | * Creates a function like `_.round`. | |
* | * | |
* @private | * @private | |
* @param {string} methodName The name of the `Math` method to use when roun ding. | * @param {string} methodName The name of the `Math` method to use when roun ding. | |
* @returns {Function} Returns the new round function. | * @returns {Function} Returns the new round function. | |
*/ | */ | |
function createRound(methodName) { | function createRound(methodName) { | |
var func = Math[methodName]; | var func = Math[methodName]; | |
return function(number, precision) { | return function(number, precision) { | |
number = toNumber(number); | number = toNumber(number); | |
precision = toInteger(precision); | precision = precision == null ? 0 : nativeMin(toInteger(precision), 292) | |
if (precision) { | ; | |
if (precision && nativeIsFinite(number)) { | ||
// Shift with exponential notation to avoid floating-point issues. | // Shift with exponential notation to avoid floating-point issues. | |
// See [MDN](https://mdn.io/round#Examples) for more details. | // See [MDN](https://mdn.io/round#Examples) for more details. | |
var pair = (toString(number) + 'e').split('e'), | var pair = (toString(number) + 'e').split('e'), | |
value = func(pair[0] + 'e' + (+pair[1] + precision)); | value = func(pair[0] + 'e' + (+pair[1] + precision)); | |
pair = (toString(value) + 'e').split('e'); | pair = (toString(value) + 'e').split('e'); | |
return +(pair[0] + 'e' + (+pair[1] - precision)); | return +(pair[0] + 'e' + (+pair[1] - precision)); | |
} | } | |
return func(number); | return func(number); | |
}; | }; | |
} | } | |
/** | /** | |
* Creates a set of `values`. | * Creates a set object of `values`. | |
* | * | |
* @private | * @private | |
* @param {Array} values The values to add to the set. | * @param {Array} values The values to add to the set. | |
* @returns {Object} Returns the new set. | * @returns {Object} Returns the new set. | |
*/ | */ | |
var createSet = !(Set && new Set([1, 2]).size === 2) ? noop : function(value s) { | var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { | |
return new Set(values); | return new Set(values); | |
}; | }; | |
/** | /** | |
* Creates a `_.toPairs` or `_.toPairsIn` function. | ||
* | ||
* @private | ||
* @param {Function} keysFunc The function to get the keys of a given object | ||
. | ||
* @returns {Function} Returns the new pairs function. | ||
*/ | ||
function createToPairs(keysFunc) { | ||
return function(object) { | ||
var tag = getTag(object); | ||
if (tag == mapTag) { | ||
return mapToArray(object); | ||
} | ||
if (tag == setTag) { | ||
return setToPairs(object); | ||
} | ||
return baseToPairs(object, keysFunc(object)); | ||
}; | ||
} | ||
/** | ||
* Creates a function that either curries or invokes `func` with optional | * Creates a function that either curries or invokes `func` with optional | |
* `this` binding and partially applied arguments. | * `this` binding and partially applied arguments. | |
* | * | |
* @private | * @private | |
* @param {Function|string} func The function or method name to wrap. | * @param {Function|string} func The function or method name to wrap. | |
* @param {number} bitmask The bitmask of wrapper flags. | * @param {number} bitmask The bitmask flags. | |
* The bitmask may be composed of the following flags: | * 1 - `_.bind` | |
* 1 - `_.bind` | * 2 - `_.bindKey` | |
* 2 - `_.bindKey` | * 4 - `_.curry` or `_.curryRight` of a bound function | |
* 4 - `_.curry` or `_.curryRight` of a bound function | * 8 - `_.curry` | |
* 8 - `_.curry` | * 16 - `_.curryRight` | |
* 16 - `_.curryRight` | * 32 - `_.partial` | |
* 32 - `_.partial` | * 64 - `_.partialRight` | |
* 64 - `_.partialRight` | * 128 - `_.rearg` | |
* 128 - `_.rearg` | * 256 - `_.ary` | |
* 256 - `_.ary` | * 512 - `_.flip` | |
* @param {*} [thisArg] The `this` binding of `func`. | * @param {*} [thisArg] The `this` binding of `func`. | |
* @param {Array} [partials] The arguments to be partially applied. | * @param {Array} [partials] The arguments to be partially applied. | |
* @param {Array} [holders] The `partials` placeholder indexes. | * @param {Array} [holders] The `partials` placeholder indexes. | |
* @param {Array} [argPos] The argument positions of the new function. | * @param {Array} [argPos] The argument positions of the new function. | |
* @param {number} [ary] The arity cap of `func`. | * @param {number} [ary] The arity cap of `func`. | |
* @param {number} [arity] The arity of `func`. | * @param {number} [arity] The arity of `func`. | |
* @returns {Function} Returns the new wrapped function. | * @returns {Function} Returns the new wrapped function. | |
*/ | */ | |
function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ar | function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, | |
y, arity) { | arity) { | |
var isBindKey = bitmask & BIND_KEY_FLAG; | var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; | |
if (!isBindKey && typeof func != 'function') { | if (!isBindKey && typeof func != 'function') { | |
throw new TypeError(FUNC_ERROR_TEXT); | throw new TypeError(FUNC_ERROR_TEXT); | |
} | } | |
var length = partials ? partials.length : 0; | var length = partials ? partials.length : 0; | |
if (!length) { | if (!length) { | |
bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); | bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); | |
partials = holders = undefined; | partials = holders = undefined; | |
} | } | |
ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); | ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); | |
arity = arity === undefined ? arity : toInteger(arity); | arity = arity === undefined ? arity : toInteger(arity); | |
length -= holders ? holders.length : 0; | length -= holders ? holders.length : 0; | |
if (bitmask & PARTIAL_RIGHT_FLAG) { | if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { | |
var partialsRight = partials, | var partialsRight = partials, | |
holdersRight = holders; | holdersRight = holders; | |
partials = holders = undefined; | partials = holders = undefined; | |
} | } | |
var data = isBindKey ? undefined : getData(func), | var data = isBindKey ? undefined : getData(func); | |
newData = [func, bitmask, thisArg, partials, holders, partialsRight, h | ||
oldersRight, argPos, ary, arity]; | var newData = [ | |
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, | ||
argPos, ary, arity | ||
]; | ||
if (data) { | if (data) { | |
mergeData(newData, data); | mergeData(newData, data); | |
} | } | |
func = newData[0]; | func = newData[0]; | |
bitmask = newData[1]; | bitmask = newData[1]; | |
thisArg = newData[2]; | thisArg = newData[2]; | |
partials = newData[3]; | partials = newData[3]; | |
holders = newData[4]; | holders = newData[4]; | |
arity = newData[9] = newData[9] == null | arity = newData[9] = newData[9] === undefined | |
? (isBindKey ? 0 : func.length) | ? (isBindKey ? 0 : func.length) | |
: nativeMax(newData[9] - length, 0); | : nativeMax(newData[9] - length, 0); | |
if (!arity && bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG)) { | if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { | |
bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG); | bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); | |
} | } | |
if (!bitmask || bitmask == BIND_FLAG) { | if (!bitmask || bitmask == WRAP_BIND_FLAG) { | |
var result = createBaseWrapper(func, bitmask, thisArg); | var result = createBind(func, bitmask, thisArg); | |
} else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) { | } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) | |
result = createCurryWrapper(func, bitmask, arity); | { | |
} else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLA | result = createCurry(func, bitmask, arity); | |
G)) && !holders.length) { | } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | W | |
result = createPartialWrapper(func, bitmask, thisArg, partials); | RAP_PARTIAL_FLAG)) && !holders.length) { | |
result = createPartial(func, bitmask, thisArg, partials); | ||
} else { | } else { | |
result = createHybridWrapper.apply(undefined, newData); | result = createHybrid.apply(undefined, newData); | |
} | } | |
var setter = data ? baseSetData : setData; | var setter = data ? baseSetData : setData; | |
return setter(result, newData); | return setWrapToString(setter(result, newData), func, bitmask); | |
} | ||
/** | ||
* Used by `_.defaults` to customize its `_.assignIn` use to assign properti | ||
es | ||
* of source objects to the destination object for all destination propertie | ||
s | ||
* that resolve to `undefined`. | ||
* | ||
* @private | ||
* @param {*} objValue The destination value. | ||
* @param {*} srcValue The source value. | ||
* @param {string} key The key of the property to assign. | ||
* @param {Object} object The parent object of `objValue`. | ||
* @returns {*} Returns the value to assign. | ||
*/ | ||
function customDefaultsAssignIn(objValue, srcValue, key, object) { | ||
if (objValue === undefined || | ||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) | ||
{ | ||
return srcValue; | ||
} | ||
return objValue; | ||
} | ||
/** | ||
* Used by `_.defaultsDeep` to customize its `_.merge` use to merge source | ||
* objects into destination objects that are passed thru. | ||
* | ||
* @private | ||
* @param {*} objValue The destination value. | ||
* @param {*} srcValue The source value. | ||
* @param {string} key The key of the property to merge. | ||
* @param {Object} object The parent object of `objValue`. | ||
* @param {Object} source The parent object of `srcValue`. | ||
* @param {Object} [stack] Tracks traversed source values and their merged | ||
* counterparts. | ||
* @returns {*} Returns the value to assign. | ||
*/ | ||
function customDefaultsMerge(objValue, srcValue, key, object, source, stack) | ||
{ | ||
if (isObject(objValue) && isObject(srcValue)) { | ||
// Recursively merge objects and arrays (susceptible to call stack limit | ||
s). | ||
stack.set(srcValue, objValue); | ||
baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); | ||
stack['delete'](srcValue); | ||
} | ||
return objValue; | ||
} | ||
/** | ||
* Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain | ||
* objects. | ||
* | ||
* @private | ||
* @param {*} value The value to inspect. | ||
* @param {string} key The key of the property to inspect. | ||
* @returns {*} Returns the uncloned value or `undefined` to defer cloning t | ||
o `_.cloneDeep`. | ||
*/ | ||
function customOmitClone(value) { | ||
return isPlainObject(value) ? undefined : value; | ||
} | } | |
/** | /** | |
* A specialized version of `baseIsEqualDeep` for arrays with support for | * A specialized version of `baseIsEqualDeep` for arrays with support for | |
* partial deep comparisons. | * partial deep comparisons. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to compare. | * @param {Array} array The array to compare. | |
* @param {Array} other The other array to compare. | * @param {Array} other The other array to compare. | |
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more det | ||
ails. | ||
* @param {Function} customizer The function to customize comparisons. | ||
* @param {Function} equalFunc The function to determine equivalents of valu es. | * @param {Function} equalFunc The function to determine equivalents of valu es. | |
* @param {Function} [customizer] The function to customize comparisons. | * @param {Object} stack Tracks traversed `array` and `other` objects. | |
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqu | ||
al` for more details. | ||
* @param {Object} [stack] Tracks traversed `array` and `other` objects. | ||
* @returns {boolean} Returns `true` if the arrays are equivalent, else `fal se`. | * @returns {boolean} Returns `true` if the arrays are equivalent, else `fal se`. | |
*/ | */ | |
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { | function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { | |
var index = -1, | var isPartial = bitmask & COMPARE_PARTIAL_FLAG, | |
isPartial = bitmask & PARTIAL_COMPARE_FLAG, | ||
isUnordered = bitmask & UNORDERED_COMPARE_FLAG, | ||
arrLength = array.length, | arrLength = array.length, | |
othLength = other.length; | othLength = other.length; | |
if (arrLength != othLength && !(isPartial && othLength > arrLength)) { | if (arrLength != othLength && !(isPartial && othLength > arrLength)) { | |
return false; | return false; | |
} | } | |
// Assume cyclic values are equal. | // Check that cyclic values are equal. | |
var stacked = stack.get(array); | var arrStacked = stack.get(array); | |
if (stacked) { | var othStacked = stack.get(other); | |
return stacked == other; | if (arrStacked && othStacked) { | |
return arrStacked == other && othStacked == array; | ||
} | } | |
var result = true; | var index = -1, | |
result = true, | ||
seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; | ||
stack.set(array, other); | stack.set(array, other); | |
stack.set(other, array); | ||
// Ignore non-index properties. | // Ignore non-index properties. | |
while (++index < arrLength) { | while (++index < arrLength) { | |
var arrValue = array[index], | var arrValue = array[index], | |
othValue = other[index]; | othValue = other[index]; | |
if (customizer) { | if (customizer) { | |
var compared = isPartial | var compared = isPartial | |
? customizer(othValue, arrValue, index, other, array, stack) | ? customizer(othValue, arrValue, index, other, array, stack) | |
: customizer(arrValue, othValue, index, array, other, stack); | : customizer(arrValue, othValue, index, array, other, stack); | |
} | } | |
if (compared !== undefined) { | if (compared !== undefined) { | |
if (compared) { | if (compared) { | |
continue; | continue; | |
} | } | |
result = false; | result = false; | |
break; | break; | |
} | } | |
// Recursively compare arrays (susceptible to call stack limits). | // Recursively compare arrays (susceptible to call stack limits). | |
if (isUnordered) { | if (seen) { | |
if (!arraySome(other, function(othValue) { | if (!arraySome(other, function(othValue, othIndex) { | |
return arrValue === othValue || equalFunc(arrValue, othValue, cu | if (!cacheHas(seen, othIndex) && | |
stomizer, bitmask, stack); | (arrValue === othValue || equalFunc(arrValue, othValue, bitm | |
ask, customizer, stack))) { | ||
return seen.push(othIndex); | ||
} | ||
})) { | })) { | |
result = false; | result = false; | |
break; | break; | |
} | } | |
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, cust | } else if (!( | |
omizer, bitmask, stack))) { | arrValue === othValue || | |
equalFunc(arrValue, othValue, bitmask, customizer, stack) | ||
)) { | ||
result = false; | result = false; | |
break; | break; | |
} | } | |
} | } | |
stack['delete'](array); | stack['delete'](array); | |
stack['delete'](other); | ||
return result; | return result; | |
} | } | |
/** | /** | |
* A specialized version of `baseIsEqualDeep` for comparing objects of | * A specialized version of `baseIsEqualDeep` for comparing objects of | |
* the same `toStringTag`. | * the same `toStringTag`. | |
* | * | |
* **Note:** This function only supports comparing values with tags of | * **Note:** This function only supports comparing values with tags of | |
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. | * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to compare. | * @param {Object} object The object to compare. | |
* @param {Object} other The other object to compare. | * @param {Object} other The other object to compare. | |
* @param {string} tag The `toStringTag` of the objects to compare. | * @param {string} tag The `toStringTag` of the objects to compare. | |
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more det | ||
ails. | ||
* @param {Function} customizer The function to customize comparisons. | ||
* @param {Function} equalFunc The function to determine equivalents of valu es. | * @param {Function} equalFunc The function to determine equivalents of valu es. | |
* @param {Function} [customizer] The function to customize comparisons. | * @param {Object} stack Tracks traversed `object` and `other` objects. | |
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqu | ||
al` for more details. | ||
* @returns {boolean} Returns `true` if the objects are equivalent, else `fa lse`. | * @returns {boolean} Returns `true` if the objects are equivalent, else `fa lse`. | |
*/ | */ | |
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) { | function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stac k) { | |
switch (tag) { | switch (tag) { | |
case dataViewTag: | ||
if ((object.byteLength != other.byteLength) || | ||
(object.byteOffset != other.byteOffset)) { | ||
return false; | ||
} | ||
object = object.buffer; | ||
other = other.buffer; | ||
case arrayBufferTag: | case arrayBufferTag: | |
if ((object.byteLength != other.byteLength) || | if ((object.byteLength != other.byteLength) || | |
!equalFunc(new Uint8Array(object), new Uint8Array(other))) { | !equalFunc(new Uint8Array(object), new Uint8Array(other))) { | |
return false; | return false; | |
} | } | |
return true; | return true; | |
case boolTag: | case boolTag: | |
case dateTag: | case dateTag: | |
// Coerce dates and booleans to numbers, dates to milliseconds and boo | case numberTag: | |
leans | // Coerce booleans to `1` or `0` and dates to milliseconds. | |
// to `1` or `0` treating invalid dates coerced to `NaN` as not equal. | // Invalid dates are coerced to `NaN`. | |
return +object == +other; | return eq(+object, +other); | |
case errorTag: | case errorTag: | |
return object.name == other.name && object.message == other.message; | return object.name == other.name && object.message == other.message; | |
case numberTag: | ||
// Treat `NaN` vs. `NaN` as equal. | ||
return (object != +object) ? other != +other : object == +other; | ||
case regexpTag: | case regexpTag: | |
case stringTag: | case stringTag: | |
// Coerce regexes to strings and treat strings primitives and string | // Coerce regexes to strings and treat strings, primitives and objects | |
// objects as equal. See https://es5.github.io/#x15.10.6.4 for more de | , | |
tails. | // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-r | |
egexp.prototype.tostring | ||
// for more details. | ||
return object == (other + ''); | return object == (other + ''); | |
case mapTag: | case mapTag: | |
var convert = mapToArray; | var convert = mapToArray; | |
case setTag: | case setTag: | |
var isPartial = bitmask & PARTIAL_COMPARE_FLAG; | var isPartial = bitmask & COMPARE_PARTIAL_FLAG; | |
convert || (convert = setToArray); | convert || (convert = setToArray); | |
if (object.size != other.size && !isPartial) { | ||
return false; | ||
} | ||
// Assume cyclic values are equal. | ||
var stacked = stack.get(object); | ||
if (stacked) { | ||
return stacked == other; | ||
} | ||
bitmask |= COMPARE_UNORDERED_FLAG; | ||
// Recursively compare objects (susceptible to call stack limits). | // Recursively compare objects (susceptible to call stack limits). | |
return (isPartial || object.size == other.size) && | stack.set(object, other); | |
equalFunc(convert(object), convert(other), customizer, bitmask | UNO | var result = equalArrays(convert(object), convert(other), bitmask, cus | |
RDERED_COMPARE_FLAG); | tomizer, equalFunc, stack); | |
stack['delete'](object); | ||
return result; | ||
case symbolTag: | case symbolTag: | |
return !!_Symbol && (symbolValueOf.call(object) == symbolValueOf.call( | if (symbolValueOf) { | |
other)); | return symbolValueOf.call(object) == symbolValueOf.call(other); | |
} | ||
} | } | |
return false; | return false; | |
} | } | |
/** | /** | |
* A specialized version of `baseIsEqualDeep` for objects with support for | * A specialized version of `baseIsEqualDeep` for objects with support for | |
* partial deep comparisons. | * partial deep comparisons. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to compare. | * @param {Object} object The object to compare. | |
* @param {Object} other The other object to compare. | * @param {Object} other The other object to compare. | |
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more det | ||
ails. | ||
* @param {Function} customizer The function to customize comparisons. | ||
* @param {Function} equalFunc The function to determine equivalents of valu es. | * @param {Function} equalFunc The function to determine equivalents of valu es. | |
* @param {Function} [customizer] The function to customize comparisons. | * @param {Object} stack Tracks traversed `object` and `other` objects. | |
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqu | ||
al` for more details. | ||
* @param {Object} [stack] Tracks traversed `object` and `other` objects. | ||
* @returns {boolean} Returns `true` if the objects are equivalent, else `fa lse`. | * @returns {boolean} Returns `true` if the objects are equivalent, else `fa lse`. | |
*/ | */ | |
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) | function equalObjects(object, other, bitmask, customizer, equalFunc, stack) | |
{ | { | |
var isPartial = bitmask & PARTIAL_COMPARE_FLAG, | var isPartial = bitmask & COMPARE_PARTIAL_FLAG, | |
isUnordered = bitmask & UNORDERED_COMPARE_FLAG, | objProps = getAllKeys(object), | |
objProps = keys(object), | ||
objLength = objProps.length, | objLength = objProps.length, | |
othProps = keys(other), | othProps = getAllKeys(other), | |
othLength = othProps.length; | othLength = othProps.length; | |
if (objLength != othLength && !isPartial) { | if (objLength != othLength && !isPartial) { | |
return false; | return false; | |
} | } | |
var index = objLength; | var index = objLength; | |
while (index--) { | while (index--) { | |
var key = objProps[index]; | var key = objProps[index]; | |
if (!(isPartial ? key in other : baseHas(other, key)) || | if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { | |
!(isUnordered || key == othProps[index])) { | ||
return false; | return false; | |
} | } | |
} | } | |
// Assume cyclic values are equal. | // Check that cyclic values are equal. | |
var stacked = stack.get(object); | var objStacked = stack.get(object); | |
if (stacked) { | var othStacked = stack.get(other); | |
return stacked == other; | if (objStacked && othStacked) { | |
return objStacked == other && othStacked == object; | ||
} | } | |
var result = true; | var result = true; | |
stack.set(object, other); | stack.set(object, other); | |
stack.set(other, object); | ||
var skipCtor = isPartial; | var skipCtor = isPartial; | |
while (++index < objLength) { | while (++index < objLength) { | |
key = objProps[index]; | key = objProps[index]; | |
var objValue = object[key], | var objValue = object[key], | |
othValue = other[key]; | othValue = other[key]; | |
if (customizer) { | if (customizer) { | |
var compared = isPartial | var compared = isPartial | |
? customizer(othValue, objValue, key, other, object, stack) | ? customizer(othValue, objValue, key, other, object, stack) | |
: customizer(objValue, othValue, key, object, other, stack); | : customizer(objValue, othValue, key, object, other, stack); | |
} | } | |
// Recursively compare objects (susceptible to call stack limits). | // Recursively compare objects (susceptible to call stack limits). | |
if (!(compared === undefined | if (!(compared === undefined | |
? (objValue === othValue || equalFunc(objValue, othValue, customiz er, bitmask, stack)) | ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) | |
: compared | : compared | |
)) { | )) { | |
result = false; | result = false; | |
break; | break; | |
} | } | |
skipCtor || (skipCtor = key == 'constructor'); | skipCtor || (skipCtor = key == 'constructor'); | |
} | } | |
if (result && !skipCtor) { | if (result && !skipCtor) { | |
var objCtor = object.constructor, | var objCtor = object.constructor, | |
othCtor = other.constructor; | othCtor = other.constructor; | |
// Non `Object` object instances with different constructors are not equ al. | // Non `Object` object instances with different constructors are not equ al. | |
if (objCtor != othCtor && | if (objCtor != othCtor && | |
('constructor' in object && 'constructor' in other) && | ('constructor' in object && 'constructor' in other) && | |
!(typeof objCtor == 'function' && objCtor instanceof objCtor && | !(typeof objCtor == 'function' && objCtor instanceof objCtor && | |
typeof othCtor == 'function' && othCtor instanceof othCtor)) { | typeof othCtor == 'function' && othCtor instanceof othCtor)) { | |
result = false; | result = false; | |
} | } | |
} | } | |
stack['delete'](object); | stack['delete'](object); | |
stack['delete'](other); | ||
return result; | return result; | |
} | } | |
/** | /** | |
* A specialized version of `baseRest` which flattens the rest array. | ||
* | ||
* @private | ||
* @param {Function} func The function to apply a rest parameter to. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function flatRest(func) { | ||
return setToString(overRest(func, undefined, flatten), func + ''); | ||
} | ||
/** | ||
* Creates an array of own enumerable property names and symbols of `object` | ||
. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of property names and symbols. | ||
*/ | ||
function getAllKeys(object) { | ||
return baseGetAllKeys(object, keys, getSymbols); | ||
} | ||
/** | ||
* Creates an array of own and inherited enumerable property names and | ||
* symbols of `object`. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of property names and symbols. | ||
*/ | ||
function getAllKeysIn(object) { | ||
return baseGetAllKeys(object, keysIn, getSymbolsIn); | ||
} | ||
/** | ||
* Gets metadata for `func`. | * Gets metadata for `func`. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to query. | * @param {Function} func The function to query. | |
* @returns {*} Returns the metadata for `func`. | * @returns {*} Returns the metadata for `func`. | |
*/ | */ | |
var getData = !metaMap ? noop : function(func) { | var getData = !metaMap ? noop : function(func) { | |
return metaMap.get(func); | return metaMap.get(func); | |
}; | }; | |
/** | /** | |
* Gets the name of `func`. | * Gets the name of `func`. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to query. | * @param {Function} func The function to query. | |
* @returns {string} Returns the function name. | * @returns {string} Returns the function name. | |
*/ | */ | |
function getFuncName(func) { | function getFuncName(func) { | |
var result = (func.name + ''), | var result = (func.name + ''), | |
array = realNames[result], | array = realNames[result], | |
length = array ? array.length : 0; | length = hasOwnProperty.call(realNames, result) ? array.length : 0; | |
while (length--) { | while (length--) { | |
var data = array[length], | var data = array[length], | |
otherFunc = data.func; | otherFunc = data.func; | |
if (otherFunc == null || otherFunc == func) { | if (otherFunc == null || otherFunc == func) { | |
return data.name; | return data.name; | |
} | } | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* Gets the appropriate "iteratee" function. If the `_.iteratee` method is | * Gets the argument placeholder value for `func`. | |
* customized this function returns the custom method, otherwise it returns | * | |
* `baseIteratee`. If arguments are provided the chosen function is invoked | * @private | |
* with them and its result is returned. | * @param {Function} func The function to inspect. | |
* @returns {*} Returns the placeholder value. | ||
*/ | ||
function getHolder(func) { | ||
var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; | ||
return object.placeholder; | ||
} | ||
/** | ||
* Gets the appropriate "iteratee" function. If `_.iteratee` is customized, | ||
* this function returns the custom method, otherwise it returns `baseIterat | ||
ee`. | ||
* If arguments are provided, the chosen function is invoked with them and | ||
* its result is returned. | ||
* | * | |
* @private | * @private | |
* @param {*} [value] The value to convert to an iteratee. | * @param {*} [value] The value to convert to an iteratee. | |
* @param {number} [arity] The arity of the created iteratee. | * @param {number} [arity] The arity of the created iteratee. | |
* @returns {Function} Returns the chosen function or its result. | * @returns {Function} Returns the chosen function or its result. | |
*/ | */ | |
function getIteratee() { | function getIteratee() { | |
var result = lodash.iteratee || iteratee; | var result = lodash.iteratee || iteratee; | |
result = result === iteratee ? baseIteratee : result; | result = result === iteratee ? baseIteratee : result; | |
return arguments.length ? result(arguments[0], arguments[1]) : result; | return arguments.length ? result(arguments[0], arguments[1]) : result; | |
} | } | |
/** | /** | |
* Gets the "length" property value of `object`. | * Gets the data for `map`. | |
* | ||
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit. | ||
org/show_bug.cgi?id=142792) | ||
* that affects Safari on at least iOS 8.1-8.3 ARM64. | ||
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} map The map to query. | |
* @returns {*} Returns the "length" value. | * @param {string} key The reference key. | |
*/ | * @returns {*} Returns the map data. | |
var getLength = baseProperty('length'); | */ | |
function getMapData(map, key) { | ||
var data = map.__data__; | ||
return isKeyable(key) | ||
? data[typeof key == 'string' ? 'string' : 'hash'] | ||
: data.map; | ||
} | ||
/** | /** | |
* Gets the property names, values, and compare flags of `object`. | * Gets the property names, values, and compare flags of `object`. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @returns {Array} Returns the match data of `object`. | * @returns {Array} Returns the match data of `object`. | |
*/ | */ | |
function getMatchData(object) { | function getMatchData(object) { | |
var result = toPairs(object), | var result = keys(object), | |
length = result.length; | length = result.length; | |
while (length--) { | while (length--) { | |
result[length][2] = isStrictComparable(result[length][1]); | var key = result[length], | |
value = object[key]; | ||
result[length] = [key, value, isStrictComparable(value)]; | ||
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* Gets the native function at `key` of `object`. | * Gets the native function at `key` of `object`. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @param {string} key The key of the method to get. | * @param {string} key The key of the method to get. | |
* @returns {*} Returns the function if it's native, else `undefined`. | * @returns {*} Returns the function if it's native, else `undefined`. | |
*/ | */ | |
function getNative(object, key) { | function getNative(object, key) { | |
var value = object == null ? undefined : object[key]; | var value = getValue(object, key); | |
return isNative(value) ? value : undefined; | return baseIsNative(value) ? value : undefined; | |
} | } | |
/** | /** | |
* Creates an array of the own symbol properties of `object`. | * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` | |
values. | ||
* | ||
* @private | ||
* @param {*} value The value to query. | ||
* @returns {string} Returns the raw `toStringTag`. | ||
*/ | ||
function getRawTag(value) { | ||
var isOwn = hasOwnProperty.call(value, symToStringTag), | ||
tag = value[symToStringTag]; | ||
try { | ||
value[symToStringTag] = undefined; | ||
var unmasked = true; | ||
} catch (e) {} | ||
var result = nativeObjectToString.call(value); | ||
if (unmasked) { | ||
if (isOwn) { | ||
value[symToStringTag] = tag; | ||
} else { | ||
delete value[symToStringTag]; | ||
} | ||
} | ||
return result; | ||
} | ||
/** | ||
* Creates an array of the own enumerable symbols of `object`. | ||
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @returns {Array} Returns the array of symbols. | * @returns {Array} Returns the array of symbols. | |
*/ | */ | |
var getSymbols = getOwnPropertySymbols || function() { | var getSymbols = !nativeGetSymbols ? stubArray : function(object) { | |
return []; | if (object == null) { | |
return []; | ||
} | ||
object = Object(object); | ||
return arrayFilter(nativeGetSymbols(object), function(symbol) { | ||
return propertyIsEnumerable.call(object, symbol); | ||
}); | ||
}; | ||
/** | ||
* Creates an array of the own and inherited enumerable symbols of `object`. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of symbols. | ||
*/ | ||
var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { | ||
var result = []; | ||
while (object) { | ||
arrayPush(result, getSymbols(object)); | ||
object = getPrototype(object); | ||
} | ||
return result; | ||
}; | }; | |
/** | /** | |
* Gets the `toStringTag` of `value`. | * Gets the `toStringTag` of `value`. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to query. | * @param {*} value The value to query. | |
* @returns {string} Returns the `toStringTag`. | * @returns {string} Returns the `toStringTag`. | |
*/ | */ | |
function getTag(value) { | var getTag = baseGetTag; | |
return objectToString.call(value); | ||
} | ||
// Fallback for IE 11 providing `toStringTag` values for maps and sets. | // Fallback for data views, maps, sets, and weak maps in IE 11 and promises | |
if ((Map && getTag(new Map) != mapTag) || (Set && getTag(new Set) != setTag) | in Node.js < 6. | |
) { | if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || | |
(Map && getTag(new Map) != mapTag) || | ||
(Promise && getTag(Promise.resolve()) != promiseTag) || | ||
(Set && getTag(new Set) != setTag) || | ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) { | ||
getTag = function(value) { | getTag = function(value) { | |
var result = objectToString.call(value), | var result = baseGetTag(value), | |
Ctor = result == objectTag ? value.constructor : null, | Ctor = result == objectTag ? value.constructor : undefined, | |
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : ' | ctorString = Ctor ? toSource(Ctor) : ''; | |
'; | ||
if (ctorString) { | if (ctorString) { | |
if (ctorString == mapCtorString) { | switch (ctorString) { | |
return mapTag; | case dataViewCtorString: return dataViewTag; | |
} | case mapCtorString: return mapTag; | |
if (ctorString == setCtorString) { | case promiseCtorString: return promiseTag; | |
return setTag; | case setCtorString: return setTag; | |
case weakMapCtorString: return weakMapTag; | ||
} | } | |
} | } | |
return result; | return result; | |
}; | }; | |
} | } | |
/** | /** | |
* Gets the view, applying any `transforms` to the `start` and `end` positio ns. | * Gets the view, applying any `transforms` to the `start` and `end` positio ns. | |
* | * | |
* @private | * @private | |
skipping to change at line 4802 | skipping to change at line 6163 | |
case 'drop': start += size; break; | case 'drop': start += size; break; | |
case 'dropRight': end -= size; break; | case 'dropRight': end -= size; break; | |
case 'take': end = nativeMin(end, start + size); break; | case 'take': end = nativeMin(end, start + size); break; | |
case 'takeRight': start = nativeMax(start, end - size); break; | case 'takeRight': start = nativeMax(start, end - size); break; | |
} | } | |
} | } | |
return { 'start': start, 'end': end }; | return { 'start': start, 'end': end }; | |
} | } | |
/** | /** | |
* Extracts wrapper details from the `source` body comment. | ||
* | ||
* @private | ||
* @param {string} source The source to inspect. | ||
* @returns {Array} Returns the wrapper details. | ||
*/ | ||
function getWrapDetails(source) { | ||
var match = source.match(reWrapDetails); | ||
return match ? match[1].split(reSplitDetails) : []; | ||
} | ||
/** | ||
* Checks if `path` exists on `object`. | * Checks if `path` exists on `object`. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @param {Array|string} path The path to check. | * @param {Array|string} path The path to check. | |
* @param {Function} hasFunc The function to check properties. | * @param {Function} hasFunc The function to check properties. | |
* @returns {boolean} Returns `true` if `path` exists, else `false`. | * @returns {boolean} Returns `true` if `path` exists, else `false`. | |
*/ | */ | |
function hasPath(object, path, hasFunc) { | function hasPath(object, path, hasFunc) { | |
if (object == null) { | path = castPath(path, object); | |
return false; | ||
} | var index = -1, | |
var result = hasFunc(object, path); | length = path.length, | |
if (!result && !isKey(path)) { | result = false; | |
path = baseToPath(path); | ||
object = parent(object, path); | while (++index < length) { | |
if (object != null) { | var key = toKey(path[index]); | |
path = last(path); | if (!(result = object != null && hasFunc(object, key))) { | |
result = hasFunc(object, path); | break; | |
} | } | |
object = object[key]; | ||
} | } | |
return result || (isLength(object && object.length) && isIndex(path, objec | if (result || ++index != length) { | |
t.length) && | return result; | |
(isArray(object) || isString(object) || isArguments(object))); | } | |
length = object == null ? 0 : object.length; | ||
return !!length && isLength(length) && isIndex(key, length) && | ||
(isArray(object) || isArguments(object)); | ||
} | } | |
/** | /** | |
* Initializes an array clone. | * Initializes an array clone. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to clone. | * @param {Array} array The array to clone. | |
* @returns {Array} Returns the initialized clone. | * @returns {Array} Returns the initialized clone. | |
*/ | */ | |
function initCloneArray(array) { | function initCloneArray(array) { | |
var length = array.length, | var length = array.length, | |
result = array.constructor(length); | result = new array.constructor(length); | |
// Add properties assigned by `RegExp#exec`. | // Add properties assigned by `RegExp#exec`. | |
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'i ndex')) { | if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'i ndex')) { | |
result.index = array.index; | result.index = array.index; | |
result.input = array.input; | result.input = array.input; | |
} | } | |
return result; | return result; | |
} | } | |
/** | /** | |
* Initializes an object clone. | * Initializes an object clone. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to clone. | * @param {Object} object The object to clone. | |
* @returns {Object} Returns the initialized clone. | * @returns {Object} Returns the initialized clone. | |
*/ | */ | |
function initCloneObject(object) { | function initCloneObject(object) { | |
var Ctor = object.constructor; | return (typeof object.constructor == 'function' && !isPrototype(object)) | |
return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); | ? baseCreate(getPrototype(object)) | |
: {}; | ||
} | } | |
/** | /** | |
* Initializes an object clone based on its `toStringTag`. | * Initializes an object clone based on its `toStringTag`. | |
* | * | |
* **Note:** This function only supports cloning values with tags of | * **Note:** This function only supports cloning values with tags of | |
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. | * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String` . | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to clone. | * @param {Object} object The object to clone. | |
* @param {string} tag The `toStringTag` of the object to clone. | * @param {string} tag The `toStringTag` of the object to clone. | |
* @param {boolean} [isDeep] Specify a deep clone. | * @param {boolean} [isDeep] Specify a deep clone. | |
* @returns {Object} Returns the initialized clone. | * @returns {Object} Returns the initialized clone. | |
*/ | */ | |
function initCloneByTag(object, tag, isDeep) { | function initCloneByTag(object, tag, isDeep) { | |
var Ctor = object.constructor; | var Ctor = object.constructor; | |
switch (tag) { | switch (tag) { | |
case arrayBufferTag: | case arrayBufferTag: | |
return cloneBuffer(object); | return cloneArrayBuffer(object); | |
case boolTag: | case boolTag: | |
case dateTag: | case dateTag: | |
return new Ctor(+object); | return new Ctor(+object); | |
case dataViewTag: | ||
return cloneDataView(object, isDeep); | ||
case float32Tag: case float64Tag: | case float32Tag: case float64Tag: | |
case int8Tag: case int16Tag: case int32Tag: | case int8Tag: case int16Tag: case int32Tag: | |
case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: | case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: | |
return cloneTypedArray(object, isDeep); | return cloneTypedArray(object, isDeep); | |
case mapTag: | case mapTag: | |
return cloneMap(object); | return new Ctor; | |
case numberTag: | case numberTag: | |
case stringTag: | case stringTag: | |
return new Ctor(object); | return new Ctor(object); | |
case regexpTag: | case regexpTag: | |
return cloneRegExp(object); | return cloneRegExp(object); | |
case setTag: | case setTag: | |
return cloneSet(object); | return new Ctor; | |
case symbolTag: | case symbolTag: | |
return cloneSymbol(object); | return cloneSymbol(object); | |
} | } | |
} | } | |
/** | /** | |
* Creates an array of index keys for `object` values of arrays, | * Inserts wrapper `details` in a comment at the top of the `source` body. | |
* `arguments` objects, and strings, otherwise `null` is returned. | ||
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {string} source The source to modify. | |
* @returns {Array|null} Returns index keys, else `null`. | * @returns {Array} details The details to insert. | |
* @returns {string} Returns the modified source. | ||
*/ | */ | |
function indexKeys(object) { | function insertWrapDetails(source, details) { | |
var length = object ? object.length : undefined; | var length = details.length; | |
return (isLength(length) && (isArray(object) || isString(object) || isArgu | if (!length) { | |
ments(object))) | return source; | |
? baseTimes(length, String) | } | |
: null; | var lastIndex = length - 1; | |
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; | ||
details = details.join(length > 2 ? ', ' : ' '); | ||
return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] | ||
*/\n'); | ||
} | } | |
/** | /** | |
* Checks if the provided arguments are from an iteratee call. | * Checks if `value` is a flattenable `arguments` object or array. | |
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is flattenable, else `false` | ||
. | ||
*/ | ||
function isFlattenable(value) { | ||
return isArray(value) || isArguments(value) || | ||
!!(spreadableSymbol && value && value[spreadableSymbol]); | ||
} | ||
/** | ||
* Checks if `value` is a valid array-like index. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid ind | ||
ex. | ||
* @returns {boolean} Returns `true` if `value` is a valid index, else `fals | ||
e`. | ||
*/ | ||
function isIndex(value, length) { | ||
var type = typeof value; | ||
length = length == null ? MAX_SAFE_INTEGER : length; | ||
return !!length && | ||
(type == 'number' || | ||
(type != 'symbol' && reIsUint.test(value))) && | ||
(value > -1 && value % 1 == 0 && value < length); | ||
} | ||
/** | ||
* Checks if the given arguments are from an iteratee call. | ||
* | * | |
* @private | * @private | |
* @param {*} value The potential iteratee value argument. | * @param {*} value The potential iteratee value argument. | |
* @param {*} index The potential iteratee index or key argument. | * @param {*} index The potential iteratee index or key argument. | |
* @param {*} object The potential iteratee object argument. | * @param {*} object The potential iteratee object argument. | |
* @returns {boolean} Returns `true` if the arguments are from an iteratee c | * @returns {boolean} Returns `true` if the arguments are from an iteratee c | |
all, else `false`. | all, | |
* else `false`. | ||
*/ | */ | |
function isIterateeCall(value, index, object) { | function isIterateeCall(value, index, object) { | |
if (!isObject(object)) { | if (!isObject(object)) { | |
return false; | return false; | |
} | } | |
var type = typeof index; | var type = typeof index; | |
if (type == 'number' | if (type == 'number' | |
? (isArrayLike(object) && isIndex(index, object.length)) | ? (isArrayLike(object) && isIndex(index, object.length)) | |
: (type == 'string' && index in object)) { | : (type == 'string' && index in object) | |
) { | ||
return eq(object[index], value); | return eq(object[index], value); | |
} | } | |
return false; | return false; | |
} | } | |
/** | /** | |
* Checks if `value` is a property name and not a property path. | * Checks if `value` is a property name and not a property path. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to check. | * @param {*} value The value to check. | |
* @param {Object} [object] The object to query keys on. | * @param {Object} [object] The object to query keys on. | |
* @returns {boolean} Returns `true` if `value` is a property name, else `fa lse`. | * @returns {boolean} Returns `true` if `value` is a property name, else `fa lse`. | |
*/ | */ | |
function isKey(value, object) { | function isKey(value, object) { | |
if (typeof value == 'number') { | if (isArray(value)) { | |
return false; | ||
} | ||
var type = typeof value; | ||
if (type == 'number' || type == 'symbol' || type == 'boolean' || | ||
value == null || isSymbol(value)) { | ||
return true; | return true; | |
} | } | |
return !isArray(value) && | return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || | |
(reIsPlainProp.test(value) || !reIsDeepProp.test(value) || | (object != null && value in Object(object)); | |
(object != null && value in Object(object))); | ||
} | } | |
/** | /** | |
* Checks if `value` is suitable for use as unique object key. | * Checks if `value` is suitable for use as unique object key. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to check. | * @param {*} value The value to check. | |
* @returns {boolean} Returns `true` if `value` is suitable, else `false`. | * @returns {boolean} Returns `true` if `value` is suitable, else `false`. | |
*/ | */ | |
function isKeyable(value) { | function isKeyable(value) { | |
var type = typeof value; | var type = typeof value; | |
return type == 'number' || type == 'boolean' || | return (type == 'string' || type == 'number' || type == 'symbol' || type = | |
(type == 'string' && value !== '__proto__') || value == null; | = 'boolean') | |
? (value !== '__proto__') | ||
: (value === null); | ||
} | } | |
/** | /** | |
* Checks if `func` has a lazy counterpart. | * Checks if `func` has a lazy counterpart. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to check. | * @param {Function} func The function to check. | |
* @returns {boolean} Returns `true` if `func` has a lazy counterpart, else | * @returns {boolean} Returns `true` if `func` has a lazy counterpart, | |
`false`. | * else `false`. | |
*/ | */ | |
function isLaziable(func) { | function isLaziable(func) { | |
var funcName = getFuncName(func), | var funcName = getFuncName(func), | |
other = lodash[funcName]; | other = lodash[funcName]; | |
if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { | if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { | |
return false; | return false; | |
} | } | |
if (func === other) { | if (func === other) { | |
return true; | return true; | |
} | } | |
var data = getData(other); | var data = getData(other); | |
return !!data && func === data[0]; | return !!data && func === data[0]; | |
} | } | |
/** | /** | |
* Checks if `func` has its source masked. | ||
* | ||
* @private | ||
* @param {Function} func The function to check. | ||
* @returns {boolean} Returns `true` if `func` is masked, else `false`. | ||
*/ | ||
function isMasked(func) { | ||
return !!maskSrcKey && (maskSrcKey in func); | ||
} | ||
/** | ||
* Checks if `func` is capable of being masked. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `func` is maskable, else `false`. | ||
*/ | ||
var isMaskable = coreJsData ? isFunction : stubFalse; | ||
/** | ||
* Checks if `value` is likely a prototype object. | * Checks if `value` is likely a prototype object. | |
* | * | |
* @private | * @private | |
* @param {*} value The value to check. | * @param {*} value The value to check. | |
* @returns {boolean} Returns `true` if `value` is a prototype, else `false` . | * @returns {boolean} Returns `true` if `value` is a prototype, else `false` . | |
*/ | */ | |
function isPrototype(value) { | function isPrototype(value) { | |
var Ctor = value && value.constructor, | var Ctor = value && value.constructor, | |
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; | proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; | |
skipping to change at line 5018 | skipping to change at line 6462 | |
* @private | * @private | |
* @param {*} value The value to check. | * @param {*} value The value to check. | |
* @returns {boolean} Returns `true` if `value` if suitable for strict | * @returns {boolean} Returns `true` if `value` if suitable for strict | |
* equality comparisons, else `false`. | * equality comparisons, else `false`. | |
*/ | */ | |
function isStrictComparable(value) { | function isStrictComparable(value) { | |
return value === value && !isObject(value); | return value === value && !isObject(value); | |
} | } | |
/** | /** | |
* A specialized version of `matchesProperty` for source values suitable | ||
* for strict equality comparisons, i.e. `===`. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @param {*} srcValue The value to match. | ||
* @returns {Function} Returns the new spec function. | ||
*/ | ||
function matchesStrictComparable(key, srcValue) { | ||
return function(object) { | ||
if (object == null) { | ||
return false; | ||
} | ||
return object[key] === srcValue && | ||
(srcValue !== undefined || (key in Object(object))); | ||
}; | ||
} | ||
/** | ||
* A specialized version of `_.memoize` which clears the memoized function's | ||
* cache when it exceeds `MAX_MEMOIZE_SIZE`. | ||
* | ||
* @private | ||
* @param {Function} func The function to have its output memoized. | ||
* @returns {Function} Returns the new memoized function. | ||
*/ | ||
function memoizeCapped(func) { | ||
var result = memoize(func, function(key) { | ||
if (cache.size === MAX_MEMOIZE_SIZE) { | ||
cache.clear(); | ||
} | ||
return key; | ||
}); | ||
var cache = result.cache; | ||
return result; | ||
} | ||
/** | ||
* Merges the function metadata of `source` into `data`. | * Merges the function metadata of `source` into `data`. | |
* | * | |
* Merging metadata reduces the number of wrappers used to invoke a function . | * Merging metadata reduces the number of wrappers used to invoke a function . | |
* This is possible because methods like `_.bind`, `_.curry`, and `_.partial ` | * This is possible because methods like `_.bind`, `_.curry`, and `_.partial ` | |
* may be applied regardless of execution order. Methods like `_.ary` and `_ | * may be applied regardless of execution order. Methods like `_.ary` and | |
.rearg` | * `_.rearg` modify function arguments, making the order in which they are | |
* modify function arguments, making the order in which they are executed im | * executed important, preventing the merging of metadata. However, we make | |
portant, | * an exception for a safe combined case where curried functions have `_.ary | |
* preventing the merging of metadata. However, we make an exception for a s | ` | |
afe | * and or `_.rearg` applied. | |
* combined case where curried functions have `_.ary` and or `_.rearg` appli | ||
ed. | ||
* | * | |
* @private | * @private | |
* @param {Array} data The destination metadata. | * @param {Array} data The destination metadata. | |
* @param {Array} source The source metadata. | * @param {Array} source The source metadata. | |
* @returns {Array} Returns `data`. | * @returns {Array} Returns `data`. | |
*/ | */ | |
function mergeData(data, source) { | function mergeData(data, source) { | |
var bitmask = data[1], | var bitmask = data[1], | |
srcBitmask = source[1], | srcBitmask = source[1], | |
newBitmask = bitmask | srcBitmask, | newBitmask = bitmask | srcBitmask, | |
isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG); | isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_AR Y_FLAG); | |
var isCombo = | var isCombo = | |
(srcBitmask == ARY_FLAG && (bitmask == CURRY_FLAG)) || | ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || | |
(srcBitmask == ARY_FLAG && (bitmask == REARG_FLAG) && (data[7].length <= | ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[ | |
source[8])) || | 7].length <= source[8])) || | |
(srcBitmask == (ARY_FLAG | REARG_FLAG) && (source[7].length <= source[8] | ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length | |
) && (bitmask == CURRY_FLAG)); | <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); | |
// Exit early if metadata can't be merged. | // Exit early if metadata can't be merged. | |
if (!(isCommon || isCombo)) { | if (!(isCommon || isCombo)) { | |
return data; | return data; | |
} | } | |
// Use source `thisArg` if available. | // Use source `thisArg` if available. | |
if (srcBitmask & BIND_FLAG) { | if (srcBitmask & WRAP_BIND_FLAG) { | |
data[2] = source[2]; | data[2] = source[2]; | |
// Set when currying a bound function. | // Set when currying a bound function. | |
newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG; | newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; | |
} | } | |
// Compose partial arguments. | // Compose partial arguments. | |
var value = source[3]; | var value = source[3]; | |
if (value) { | if (value) { | |
var partials = data[3]; | var partials = data[3]; | |
data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray | data[3] = partials ? composeArgs(partials, value, source[4]) : value; | |
(value); | data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; | |
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(so | ||
urce[4]); | ||
} | } | |
// Compose partial right arguments. | // Compose partial right arguments. | |
value = source[5]; | value = source[5]; | |
if (value) { | if (value) { | |
partials = data[5]; | partials = data[5]; | |
data[5] = partials ? composeArgsRight(partials, value, source[6]) : copy | data[5] = partials ? composeArgsRight(partials, value, source[6]) : valu | |
Array(value); | e; | |
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(so | data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; | |
urce[6]); | ||
} | } | |
// Use source `argPos` if available. | // Use source `argPos` if available. | |
value = source[7]; | value = source[7]; | |
if (value) { | if (value) { | |
data[7] = copyArray(value); | data[7] = value; | |
} | } | |
// Use source `ary` if it's smaller. | // Use source `ary` if it's smaller. | |
if (srcBitmask & ARY_FLAG) { | if (srcBitmask & WRAP_ARY_FLAG) { | |
data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); | data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); | |
} | } | |
// Use source `arity` if one is not provided. | // Use source `arity` if one is not provided. | |
if (data[9] == null) { | if (data[9] == null) { | |
data[9] = source[9]; | data[9] = source[9]; | |
} | } | |
// Use source `func` and merge bitmasks. | // Use source `func` and merge bitmasks. | |
data[0] = source[0]; | data[0] = source[0]; | |
data[1] = newBitmask; | data[1] = newBitmask; | |
return data; | return data; | |
} | } | |
/** | /** | |
* Used by `_.defaultsDeep` to customize its `_.merge` use. | * This function is like | |
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.ke | ||
ys) | ||
* except that it includes inherited enumerable properties. | ||
* | * | |
* @private | * @private | |
* @param {*} objValue The destination value. | * @param {Object} object The object to query. | |
* @param {*} srcValue The source value. | * @returns {Array} Returns the array of property names. | |
* @param {string} key The key of the property to merge. | ||
* @param {Object} object The parent object of `objValue`. | ||
* @param {Object} source The parent object of `srcValue`. | ||
* @param {Object} [stack] Tracks traversed source values and their merged c | ||
ounterparts. | ||
* @returns {*} Returns the value to assign. | ||
*/ | */ | |
function mergeDefaults(objValue, srcValue, key, object, source, stack) { | function nativeKeysIn(object) { | |
if (isObject(objValue) && isObject(srcValue)) { | var result = []; | |
stack.set(srcValue, objValue); | if (object != null) { | |
baseMerge(objValue, srcValue, mergeDefaults, stack); | for (var key in Object(object)) { | |
result.push(key); | ||
} | ||
} | } | |
return objValue === undefined ? baseClone(srcValue) : objValue; | return result; | |
} | ||
/** | ||
* Converts `value` to a string using `Object.prototype.toString`. | ||
* | ||
* @private | ||
* @param {*} value The value to convert. | ||
* @returns {string} Returns the converted string. | ||
*/ | ||
function objectToString(value) { | ||
return nativeObjectToString.call(value); | ||
} | ||
/** | ||
* A specialized version of `baseRest` which transforms the rest array. | ||
* | ||
* @private | ||
* @param {Function} func The function to apply a rest parameter to. | ||
* @param {number} [start=func.length-1] The start position of the rest para | ||
meter. | ||
* @param {Function} transform The rest array transform. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function overRest(func, start, transform) { | ||
start = nativeMax(start === undefined ? (func.length - 1) : start, 0); | ||
return function() { | ||
var args = arguments, | ||
index = -1, | ||
length = nativeMax(args.length - start, 0), | ||
array = Array(length); | ||
while (++index < length) { | ||
array[index] = args[start + index]; | ||
} | ||
index = -1; | ||
var otherArgs = Array(start + 1); | ||
while (++index < start) { | ||
otherArgs[index] = args[index]; | ||
} | ||
otherArgs[start] = transform(array); | ||
return apply(func, this, otherArgs); | ||
}; | ||
} | } | |
/** | /** | |
* Gets the parent value at `path` of `object`. | * Gets the parent value at `path` of `object`. | |
* | * | |
* @private | * @private | |
* @param {Object} object The object to query. | * @param {Object} object The object to query. | |
* @param {Array} path The path to get the parent value of. | * @param {Array} path The path to get the parent value of. | |
* @returns {*} Returns the parent value. | * @returns {*} Returns the parent value. | |
*/ | */ | |
function parent(object, path) { | function parent(object, path) { | |
return path.length == 1 ? object : get(object, baseSlice(path, 0, -1)); | return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); | |
} | } | |
/** | /** | |
* Reorder `array` according to the specified indexes where the element at | * Reorder `array` according to the specified indexes where the element at | |
* the first index is assigned as the first element, the element at | * the first index is assigned as the first element, the element at | |
* the second index is assigned as the second element, and so on. | * the second index is assigned as the second element, and so on. | |
* | * | |
* @private | * @private | |
* @param {Array} array The array to reorder. | * @param {Array} array The array to reorder. | |
* @param {Array} indexes The arranged array indexes. | * @param {Array} indexes The arranged array indexes. | |
skipping to change at line 5142 | skipping to change at line 6666 | |
oldArray = copyArray(array); | oldArray = copyArray(array); | |
while (length--) { | while (length--) { | |
var index = indexes[length]; | var index = indexes[length]; | |
array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; | array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; | |
} | } | |
return array; | return array; | |
} | } | |
/** | /** | |
* Gets the value at `key`, unless `key` is "__proto__" or "constructor". | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @param {string} key The key of the property to get. | ||
* @returns {*} Returns the property value. | ||
*/ | ||
function safeGet(object, key) { | ||
if (key === 'constructor' && typeof object[key] === 'function') { | ||
return; | ||
} | ||
if (key == '__proto__') { | ||
return; | ||
} | ||
return object[key]; | ||
} | ||
/** | ||
* Sets metadata for `func`. | * Sets metadata for `func`. | |
* | * | |
* **Note:** If this function becomes hot, i.e. is invoked a lot in a short | * **Note:** If this function becomes hot, i.e. is invoked a lot in a short | |
* period of time, it will trip its breaker and transition to an identity fu | * period of time, it will trip its breaker and transition to an identity | |
nction | * function to avoid garbage collection pauses in V8. See | |
* to avoid garbage collection pauses in V8. See [V8 issue 2070](https://cod | * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) | |
e.google.com/p/v8/issues/detail?id=2070) | ||
* for more details. | * for more details. | |
* | * | |
* @private | * @private | |
* @param {Function} func The function to associate metadata with. | * @param {Function} func The function to associate metadata with. | |
* @param {*} data The metadata. | * @param {*} data The metadata. | |
* @returns {Function} Returns `func`. | * @returns {Function} Returns `func`. | |
*/ | */ | |
var setData = (function() { | var setData = shortOut(baseS |