mask
lets you draw an area with multiple colors using just one path
.
Last active
January 16, 2020 13:54
-
-
Save 1wheel/76a07ca0d23f616d29349f7dd7857ca5 to your computer and use it in GitHub Desktop.
heat-histogram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear() | |
d3.select('html').selectAppend('div.tooltip') | |
d3.loadData('data.tsv', (err, res) => { | |
data = res[0] | |
var sel = d3.select('#graph').html('') | |
var c = d3.conventions({parentSel: sel, height: 460}) | |
c.x.domain([-6, 6]) | |
c.y.domain([0, .5]) | |
var area = d3.area() | |
.x(d => c.x(d.x)) | |
.y0(d => c.y(d.y)) | |
.y1(c.height) | |
.curve(d3.curveBasis) | |
var pathSel = c.svg.append('defs') | |
.append('mask') | |
.at({id: 'blue-mask'}) | |
.append('path') | |
.at({ | |
d: area(data.filter(d => d.year == 1951)), | |
fill: '#fff' | |
}) | |
var start = -6 | |
var colors = [ | |
{fill: '#085B84', end: -3.00}, | |
{fill: '#73ACC6', end: -0.43}, | |
{fill: '#E5E5E5', end: 0.43}, | |
{fill: '#DB90BA', end: 3.00}, | |
{fill: '#C92E92', end: 6.00}, | |
] | |
colors.forEach(d => { | |
d.start = start | |
start = d.end | |
}) | |
c.svg.appendMany(colors, 'rect') | |
.at({ | |
fill: d => d.fill, | |
x: d => c.x(d.start), | |
width: d => c.x(d.end) - c.x(d.start), | |
height: c.height, | |
mask: 'url(#blue-mask)' | |
}) | |
var yearSel = c.svg.append('text').text(1951) | |
.at({fontSize: 30, x: 600, y: 100}) | |
var years = '1951 1983 1994 2005'.split(' ') | |
var curIndex = 0 | |
if (window.histTimer) window.histTimer.stop() | |
window.histTimer = d3.interval(() => { | |
curIndex = ++curIndex % years.length | |
var curYear = years[curIndex] | |
pathSel.transition().duration(500) | |
.at({d: area(data.filter(d => d.year == curYear))}) | |
var i = d3.interpolate(yearSel.text(), curYear) | |
yearSel.transition().duration(500) | |
.attrTween('year-text', () => { | |
return t => yearSel.text(Math.round(i(t))) | |
}) | |
}, 1000) | |
}) |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @license | |
* lodash <https://lodash.com/> | |
* Copyright JS Foundation and other contributors <https://js.foundation/> | |
* Released under MIT license <https://lodash.com/license> | |
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | |
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | |
*/ | |
;(function() { | |
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ | |
var undefined; | |
/** Used as the semantic version number. */ | |
var VERSION = '4.16.6'; | |
/** Used as the size to enable large array optimizations. */ | |
var LARGE_ARRAY_SIZE = 200; | |
/** Error message constants. */ | |
var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://github.com/es-shims.', | |
FUNC_ERROR_TEXT = 'Expected a function'; | |
/** Used to stand-in for `undefined` hash values. */ | |
var HASH_UNDEFINED = '__lodash_hash_undefined__'; | |
/** Used as the maximum memoize cache size. */ | |
var MAX_MEMOIZE_SIZE = 500; | |
/** Used as the internal argument placeholder. */ | |
var PLACEHOLDER = '__lodash_placeholder__'; | |
/** Used to compose bitmasks for function metadata. */ | |
var BIND_FLAG = 1, | |
BIND_KEY_FLAG = 2, | |
CURRY_BOUND_FLAG = 4, | |
CURRY_FLAG = 8, | |
CURRY_RIGHT_FLAG = 16, | |
PARTIAL_FLAG = 32, | |
PARTIAL_RIGHT_FLAG = 64, | |
ARY_FLAG = 128, | |
REARG_FLAG = 256, | |
FLIP_FLAG = 512; | |
/** Used to compose bitmasks for comparison styles. */ | |
var UNORDERED_COMPARE_FLAG = 1, | |
PARTIAL_COMPARE_FLAG = 2; | |
/** Used as default options for `_.truncate`. */ | |
var DEFAULT_TRUNC_LENGTH = 30, | |
DEFAULT_TRUNC_OMISSION = '...'; | |
/** Used to detect hot functions by number of calls within a span of milliseconds. */ | |
var HOT_COUNT = 800, | |
HOT_SPAN = 16; | |
/** Used to indicate the type of lazy iteratees. */ | |
var LAZY_FILTER_FLAG = 1, | |
LAZY_MAP_FLAG = 2, | |
LAZY_WHILE_FLAG = 3; | |
/** Used as references for various `Number` constants. */ | |
var INFINITY = 1 / 0, | |
MAX_SAFE_INTEGER = 9007199254740991, | |
MAX_INTEGER = 1.7976931348623157e+308, | |
NAN = 0 / 0; | |
/** Used as references for the maximum length and index of an array. */ | |
var MAX_ARRAY_LENGTH = 4294967295, | |
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, | |
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; | |
/** Used to associate wrap methods with their bit flags. */ | |
var wrapFlags = [ | |
['ary', ARY_FLAG], | |
['bind', BIND_FLAG], | |
['bindKey', BIND_KEY_FLAG], | |
['curry', CURRY_FLAG], | |
['curryRight', CURRY_RIGHT_FLAG], | |
['flip', FLIP_FLAG], | |
['partial', PARTIAL_FLAG], | |
['partialRight', PARTIAL_RIGHT_FLAG], | |
['rearg', REARG_FLAG] | |
]; | |
/** `Object#toString` result references. */ | |
var argsTag = '[object Arguments]', | |
arrayTag = '[object Array]', | |
asyncTag = '[object AsyncFunction]', | |
boolTag = '[object Boolean]', | |
dateTag = '[object Date]', | |
domExcTag = '[object DOMException]', | |
errorTag = '[object Error]', | |
funcTag = '[object Function]', | |
genTag = '[object GeneratorFunction]', | |
mapTag = '[object Map]', | |
numberTag = '[object Number]', | |
nullTag = '[object Null]', | |
objectTag = '[object Object]', | |
promiseTag = '[object Promise]', | |
proxyTag = '[object Proxy]', | |
regexpTag = '[object RegExp]', | |
setTag = '[object Set]', | |
stringTag = '[object String]', | |
symbolTag = '[object Symbol]', | |
undefinedTag = '[object Undefined]', | |
weakMapTag = '[object WeakMap]', | |
weakSetTag = '[object WeakSet]'; | |
var arrayBufferTag = '[object ArrayBuffer]', | |
dataViewTag = '[object DataView]', | |
float32Tag = '[object Float32Array]', | |
float64Tag = '[object Float64Array]', | |
int8Tag = '[object Int8Array]', | |
int16Tag = '[object Int16Array]', | |
int32Tag = '[object Int32Array]', | |
uint8Tag = '[object Uint8Array]', | |
uint8ClampedTag = '[object Uint8ClampedArray]', | |
uint16Tag = '[object Uint16Array]', | |
uint32Tag = '[object Uint32Array]'; | |
/** Used to match empty string literals in compiled template source. */ | |
var reEmptyStringLeading = /\b__p \+= '';/g, | |
reEmptyStringMiddle = /\b(__p \+=) '' \+/g, | |
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; | |
/** Used to match HTML entities and HTML characters. */ | |
var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, | |
reUnescapedHtml = /[&<>"']/g, | |
reHasEscapedHtml = RegExp(reEscapedHtml.source), | |
reHasUnescapedHtml = RegExp(reUnescapedHtml.source); | |
/** Used to match template delimiters. */ | |
var reEscape = /<%-([\s\S]+?)%>/g, | |
reEvaluate = /<%([\s\S]+?)%>/g, | |
reInterpolate = /<%=([\s\S]+?)%>/g; | |
/** Used to match property names within property paths. */ | |
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, | |
reIsPlainProp = /^\w*$/, | |
reLeadingDot = /^\./, | |
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | |
/** | |
* Used to match `RegExp` | |
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). | |
*/ | |
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, | |
reHasRegExpChar = RegExp(reRegExpChar.source); | |
/** Used to match leading and trailing whitespace. */ | |
var reTrim = /^\s+|\s+$/g, | |
reTrimStart = /^\s+/, | |
reTrimEnd = /\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 match backslashes in property paths. */ | |
var reEscapeChar = /\\(\\)?/g; | |
/** | |
* Used to match | |
* [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). | |
*/ | |
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; | |
/** Used to match `RegExp` flags from their coerced string values. */ | |
var reFlags = /\w*$/; | |
/** Used to detect bad signed hexadecimal string values. */ | |
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; | |
/** Used to detect binary string values. */ | |
var reIsBinary = /^0b[01]+$/i; | |
/** Used to detect host constructors (Safari). */ | |
var reIsHostCtor = /^\[object .+?Constructor\]$/; | |
/** Used to detect octal string values. */ | |
var reIsOctal = /^0o[0-7]+$/i; | |
/** Used to detect unsigned integer values. */ | |
var reIsUint = /^(?:0|[1-9]\d*)$/; | |
/** Used to match Latin Unicode letters (excluding mathematical operators). */ | |
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; | |
/** Used to ensure capturing order of template delimiters. */ | |
var reNoMatch = /($^)/; | |
/** Used to match unescaped characters in compiled string literals. */ | |
var reUnescapedString = /['\n\r\u2028\u2029\\]/g; | |
/** Used to compose unicode character classes. */ | |
var rsAstralRange = '\\ud800-\\udfff', | |
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', | |
rsComboSymbolsRange = '\\u20d0-\\u20f0', | |
rsDingbatRange = '\\u2700-\\u27bf', | |
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', | |
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', | |
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', | |
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\\u202f\\u205f\\u3000', | |
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', | |
rsVarRange = '\\ufe0e\\ufe0f', | |
rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; | |
/** Used to compose unicode capture groups. */ | |
var rsApos = "['\u2019]", | |
rsAstral = '[' + rsAstralRange + ']', | |
rsBreak = '[' + rsBreakRange + ']', | |
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']', | |
rsDigits = '\\d+', | |
rsDingbat = '[' + rsDingbatRange + ']', | |
rsLower = '[' + rsLowerRange + ']', | |
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', | |
rsFitz = '\\ud83c[\\udffb-\\udfff]', | |
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', | |
rsNonAstral = '[^' + rsAstralRange + ']', | |
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', | |
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', | |
rsUpper = '[' + rsUpperRange + ']', | |
rsZWJ = '\\u200d'; | |
/** Used to compose unicode regexes. */ | |
var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', | |
rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', | |
rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', | |
rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', | |
reOptMod = rsModifier + '?', | |
rsOptVar = '[' + rsVarRange + ']?', | |
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', | |
rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)', | |
rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)', | |
rsSeq = rsOptVar + reOptMod + rsOptJoin, | |
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, | |
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; | |
/** Used to match apostrophes. */ | |
var reApos = RegExp(rsApos, 'g'); | |
/** | |
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and | |
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). | |
*/ | |
var reComboMark = RegExp(rsCombo, 'g'); | |
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ | |
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); | |
/** Used to match complex or compound words. */ | |
var reUnicodeWord = RegExp([ | |
rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', | |
rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', | |
rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, | |
rsUpper + '+' + rsOptContrUpper, | |
rsOrdUpper, | |
rsOrdLower, | |
rsDigits, | |
rsEmoji | |
].join('|'), 'g'); | |
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ | |
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); | |
/** Used to detect strings that need a more robust regexp to match words. */ | |
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. */ | |
var contextProps = [ | |
'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', | |
'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', | |
'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', | |
'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', | |
'_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' | |
]; | |
/** Used to make template sourceURLs easier to identify. */ | |
var templateCounter = -1; | |
/** Used to identify `toStringTag` values of typed arrays. */ | |
var typedArrayTags = {}; | |
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = | |
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = | |
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = | |
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = | |
typedArrayTags[uint32Tag] = true; | |
typedArrayTags[argsTag] = typedArrayTags[arrayTag] = | |
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = | |
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = | |
typedArrayTags[errorTag] = typedArrayTags[funcTag] = | |
typedArrayTags[mapTag] = typedArrayTags[numberTag] = | |
typedArrayTags[objectTag] = typedArrayTags[regexpTag] = | |
typedArrayTags[setTag] = typedArrayTags[stringTag] = | |
typedArrayTags[weakMapTag] = false; | |
/** Used to identify `toStringTag` values supported by `_.clone`. */ | |
var cloneableTags = {}; | |
cloneableTags[argsTag] = cloneableTags[arrayTag] = | |
cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = | |
cloneableTags[boolTag] = cloneableTags[dateTag] = | |
cloneableTags[float32Tag] = cloneableTags[float64Tag] = | |
cloneableTags[int8Tag] = cloneableTags[int16Tag] = | |
cloneableTags[int32Tag] = cloneableTags[mapTag] = | |
cloneableTags[numberTag] = cloneableTags[objectTag] = | |
cloneableTags[regexpTag] = cloneableTags[setTag] = | |
cloneableTags[stringTag] = cloneableTags[symbolTag] = | |
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = | |
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; | |
cloneableTags[errorTag] = cloneableTags[funcTag] = | |
cloneableTags[weakMapTag] = false; | |
/** Used to map Latin Unicode letters to basic Latin letters. */ | |
var deburredLetters = { | |
// Latin-1 Supplement block. | |
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', | |
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', | |
'\xc7': 'C', '\xe7': 'c', | |
'\xd0': 'D', '\xf0': 'd', | |
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', | |
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', | |
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', | |
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', | |
'\xd1': 'N', '\xf1': 'n', | |
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', | |
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', | |
'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', | |
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', | |
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y', | |
'\xc6': 'Ae', '\xe6': 'ae', | |
'\xde': 'Th', '\xfe': 'th', | |
'\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. */ | |
var htmlEscapes = { | |
'&': '&', | |
'<': '<', | |
'>': '>', | |
'"': '"', | |
"'": ''' | |
}; | |
/** Used to map HTML entities to characters. */ | |
var htmlUnescapes = { | |
'&': '&', | |
'<': '<', | |
'>': '>', | |
'"': '"', | |
''': "'" | |
}; | |
/** Used to escape characters for inclusion in compiled string literals. */ | |
var stringEscapes = { | |
'\\': '\\', | |
"'": "'", | |
'\n': 'n', | |
'\r': 'r', | |
'\u2028': 'u2028', | |
'\u2029': 'u2029' | |
}; | |
/** Built-in method references without a dependency on `root`. */ | |
var freeParseFloat = parseFloat, | |
freeParseInt = parseInt; | |
/** Detect free variable `global` from Node.js. */ | |
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; | |
/** Detect free variable `self`. */ | |
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | |
/** Used as a reference to the global object. */ | |
var root = freeGlobal || freeSelf || Function('return this')(); | |
/** Detect free variable `exports`. */ | |
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; | |
/** Detect free variable `module`. */ | |
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; | |
/** Detect the popular CommonJS extension `module.exports`. */ | |
var moduleExports = freeModule && freeModule.exports === freeExports; | |
/** Detect free variable `process` from Node.js. */ | |
var freeProcess = moduleExports && freeGlobal.process; | |
/** Used to access faster Node.js helpers. */ | |
var nodeUtil = (function() { | |
try { | |
return freeProcess && 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 the key-value `pair` to `map`. | |
* | |
* @private | |
* @param {Object} map The map to modify. | |
* @param {Array} pair The key-value pair to add. | |
* @returns {Object} Returns `map`. | |
*/ | |
function addMapEntry(map, pair) { | |
// Don't return `map.set` because it's not chainable in IE 11. | |
map.set(pair[0], pair[1]); | |
return map; | |
} | |
/** | |
* 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) { | |
// Don't return `set.add` because it's not chainable in IE 11. | |
set.add(value); | |
return set; | |
} | |
/** | |
* A faster alternative to `Function#apply`, this function invokes `func` | |
* with the `this` binding of `thisArg` and the arguments of `args`. | |
* | |
* @private | |
* @param {Function} func The function to invoke. | |
* @param {*} thisArg The `this` binding of `func`. | |
* @param {Array} args The arguments to invoke `func` with. | |
* @returns {*} Returns the result of `func`. | |
*/ | |
function apply(func, thisArg, args) { | |
switch (args.length) { | |
case 0: return func.call(thisArg); | |
case 1: return func.call(thisArg, args[0]); | |
case 2: return func.call(thisArg, args[0], args[1]); | |
case 3: return func.call(thisArg, args[0], args[1], args[2]); | |
} | |
return func.apply(thisArg, args); | |
} | |
/** | |
* A specialized version of `baseAggregator` for arrays. | |
* | |
* @private | |
* @param {Array} [array] The array 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 arrayAggregator(array, setter, iteratee, accumulator) { | |
var index = -1, | |
length = array == null ? 0 : array.length; | |
while (++index < length) { | |
var value = array[index]; | |
setter(accumulator, value, iteratee(value), array); | |
} | |
return accumulator; | |
} | |
/** | |
* A specialized version of `_.forEach` for arrays without support for | |
* iteratee shorthands. | |
* | |
* @private | |
* @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array} Returns `array`. | |
*/ | |
function arrayEach(array, iteratee) { | |
var index = -1, | |
length = array == null ? 0 : array.length; | |
while (++index < length) { | |
if (iteratee(array[index], index, array) === false) { | |
break; | |
} | |
} | |
return array; | |
} | |
/** | |
* A specialized version of `_.forEachRight` for arrays without support for | |
* iteratee shorthands. | |
* | |
* @private | |
* @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array} Returns `array`. | |
*/ | |
function arrayEachRight(array, iteratee) { | |
var length = array == null ? 0 : array.length; | |
while (length--) { | |
if (iteratee(array[length], length, array) === false) { | |
break; | |
} | |
} | |
return array; | |
} | |
/** | |
* A specialized version of `_.every` for arrays without support for | |
* iteratee shorthands. | |
* | |
* @private | |
* @param {Array} [array] The array to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | |
* @returns {boolean} Returns `true` if all elements pass the predicate check, | |
* else `false`. | |
*/ | |
function arrayEvery(array, predicate) { | |
var index = -1, | |
length = array == null ? 0 : array.length; | |
while (++index < length) { | |
if (!predicate(array[index], index, array)) { | |
return false; | |
} | |
} | |
return true; | |
} | |
/** | |
* A specialized version of `_.filter` for arrays without support for | |
* iteratee shorthands. | |
* | |
* @private | |
* @param {Array} [array] The array to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | |
* @returns {Array} Returns the new filtered array. | |
*/ | |
function arrayFilter(array, predicate) { | |
var index = -1, | |
length = array == null ? 0 : array.length, | |
resIndex = 0, | |
result = []; | |
while (++index < length) { | |
var value = array[index]; | |
if (predicate(value, index, array)) { | |
result[resIndex++] = value; | |
} | |
} | |
return result; | |
} | |
/** | |
* A specialized version of `_.includes` for arrays without support for | |
* specifying an index to search from. | |
* | |
* @private | |
* @param {Array} [array] The array to inspect. | |
* @param {*} target The value to search for. | |
* @returns {boolean} Returns `true` if `target` is found, else `false`. | |
*/ | |
function arrayIncludes(array, value) { | |
var length = array == null ? 0 : array.length; | |
return !!length && baseIndexOf(array, value, 0) > -1; | |
} | |
/** | |
* This function is like `arrayIncludes` except that it accepts a comparator. | |
* | |
* @private | |
* @param {Array} [array] The array to inspect. | |
* @param {*} target The value to search for. | |
* @param {Function} comparator The comparator invoked per element. | |
* @returns {boolean} Returns `true` if `target` is found, else `false`. | |
*/ | |
function arrayIncludesWith(array, value, comparator) { | |
var index = -1, | |
length = array == null ? 0 : array.length; | |
while (++index < length) { | |
if (comparator(value, array[index])) { | |
return true; | |
} | |
} | |
return false; | |
} | |
/** | |
* A specialized version of `_.map` for arrays without support for iteratee | |
* shorthands. | |
* | |
* @private | |
* @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array} Returns the new mapped array. | |
*/ | |
function arrayMap(array, iteratee) { | |
var index = -1, | |
length = array == null ? 0 : array.length, | |
result = Array(length); | |
while (++index < length) { | |
result[index] = iteratee(array[index], index, array); | |
} | |
return result; | |
} | |
/** | |
* Appends the elements of `values` to `array`. | |
* | |
* @private | |
* @param {Array} array The array to modify. | |
* @param {Array} values The values to append. | |
* @returns {Array} Returns `array`. | |
*/ | |
function arrayPush(array, values) { | |
var index = -1, | |
length = values.length, | |
offset = array.length; | |
while (++index < length) { | |
array[offset + index] = values[index]; | |
} | |
return array; | |
} | |
/** | |
* A specialized version of `_.reduce` for arrays without support for | |
* iteratee shorthands. | |
* | |
* @private | |
* @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @param {*} [accumulator] The initial value. | |
* @param {boolean} [initAccum] Specify using the first element of `array` as | |
* the initial value. | |
* @returns {*} Returns the accumulated value. | |
*/ | |
function arrayReduce(array, iteratee, accumulator, initAccum) { | |
var index = -1, | |
length = array == null ? 0 : array.length; | |
if (initAccum && length) { | |
accumulator = array[++index]; | |
} | |
while (++index < length) { | |
accumulator = iteratee(accumulator, array[index], index, array); | |
} | |
return accumulator; | |
} | |
/** | |
* A specialized version of `_.reduceRight` for arrays without support for | |
* iteratee shorthands. | |
* | |
* @private | |
* @param {Array} [array] The array to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @param {*} [accumulator] The initial value. | |
* @param {boolean} [initAccum] Specify using the last element of `array` as | |
* the initial value. | |
* @returns {*} Returns the accumulated value. | |
*/ | |
function arrayReduceRight(array, iteratee, accumulator, initAccum) { | |
var length = array == null ? 0 : array.length; | |
if (initAccum && length) { | |
accumulator = array[--length]; | |
} | |
while (length--) { | |
accumulator = iteratee(accumulator, array[length], length, array); | |
} | |
return accumulator; | |
} | |
/** | |
* A specialized version of `_.some` for arrays without support for iteratee | |
* shorthands. | |
* | |
* @private | |
* @param {Array} [array] The array to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | |
* @returns {boolean} Returns `true` if any element passes the predicate check, | |
* else `false`. | |
*/ | |
function arraySome(array, predicate) { | |
var index = -1, | |
length = array == null ? 0 : array.length; | |
while (++index < length) { | |
if (predicate(array[index], index, array)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
/** | |
* Gets the size of an ASCII `string`. | |
* | |
* @private | |
* @param {string} string The string inspect. | |
* @returns {number} Returns the string size. | |
*/ | |
var asciiSize = baseProperty('length'); | |
/** | |
* Converts an ASCII `string` to an array. | |
* | |
* @private | |
* @param {string} string The string to convert. | |
* @returns {Array} Returns the converted array. | |
*/ | |
function asciiToArray(string) { | |
return string.split(''); | |
} | |
/** | |
* Splits an ASCII `string` into an array of its words. | |
* | |
* @private | |
* @param {string} The string to inspect. | |
* @returns {Array} Returns the words of `string`. | |
*/ | |
function asciiWords(string) { | |
return string.match(reAsciiWord) || []; | |
} | |
/** | |
* The base implementation of methods like `_.findKey` and `_.findLastKey`, | |
* without support for iteratee shorthands, which iterates over `collection` | |
* using `eachFunc`. | |
* | |
* @private | |
* @param {Array|Object} collection The collection to inspect. | |
* @param {Function} predicate The function invoked per iteration. | |
* @param {Function} eachFunc The function to iterate over `collection`. | |
* @returns {*} Returns the found element or its key, else `undefined`. | |
*/ | |
function baseFindKey(collection, predicate, eachFunc) { | |
var result; | |
eachFunc(collection, function(value, key, collection) { | |
if (predicate(value, key, collection)) { | |
result = key; | |
return false; | |
} | |
}); | |
return result; | |
} | |
/** | |
* The base implementation of `_.findIndex` and `_.findLastIndex` without | |
* support for iteratee shorthands. | |
* | |
* @private | |
* @param {Array} array The array to inspect. | |
* @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. | |
* @returns {number} Returns the index of the matched value, else `-1`. | |
*/ | |
function baseFindIndex(array, predicate, fromIndex, fromRight) { | |
var length = array.length, | |
index = fromIndex + (fromRight ? 1 : -1); | |
while ((fromRight ? index-- : ++index < length)) { | |
if (predicate(array[index], index, array)) { | |
return index; | |
} | |
} | |
return -1; | |
} | |
/** | |
* The base implementation of `_.indexOf` without `fromIndex` bounds checks. | |
* | |
* @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 baseIndexOf(array, value, fromIndex) { | |
return value === value | |
? 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, | |
length = array.length; | |
while (++index < length) { | |
if (comparator(array[index], value)) { | |
return index; | |
} | |
} | |
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 | |
* for iteratee shorthands, which iterates over `collection` using `eachFunc`. | |
* | |
* @private | |
* @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @param {*} accumulator The initial value. | |
* @param {boolean} initAccum Specify using the first or last element of | |
* `collection` as the initial value. | |
* @param {Function} eachFunc The function to iterate over `collection`. | |
* @returns {*} Returns the accumulated value. | |
*/ | |
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { | |
eachFunc(collection, function(value, index, collection) { | |
accumulator = initAccum | |
? (initAccum = false, value) | |
: iteratee(accumulator, value, index, collection); | |
}); | |
return accumulator; | |
} | |
/** | |
* The base implementation of `_.sortBy` which uses `comparer` to define the | |
* sort order of `array` and replaces criteria objects with their corresponding | |
* values. | |
* | |
* @private | |
* @param {Array} array The array to sort. | |
* @param {Function} comparer The function to define sort order. | |
* @returns {Array} Returns `array`. | |
*/ | |
function baseSortBy(array, comparer) { | |
var length = array.length; | |
array.sort(comparer); | |
while (length--) { | |
array[length] = array[length].value; | |
} | |
return array; | |
} | |
/** | |
* The base implementation of `_.sum` and `_.sumBy` 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 sum. | |
*/ | |
function baseSum(array, iteratee) { | |
var result, | |
index = -1, | |
length = array.length; | |
while (++index < length) { | |
var current = iteratee(array[index]); | |
if (current !== undefined) { | |
result = result === undefined ? current : (result + current); | |
} | |
} | |
return result; | |
} | |
/** | |
* The base implementation of `_.times` without support for iteratee shorthands | |
* or max array length checks. | |
* | |
* @private | |
* @param {number} n The number of times to invoke `iteratee`. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array} Returns the array of results. | |
*/ | |
function baseTimes(n, iteratee) { | |
var index = -1, | |
result = Array(n); | |
while (++index < n) { | |
result[index] = iteratee(index); | |
} | |
return result; | |
} | |
/** | |
* The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array | |
* of key-value pairs for `object` corresponding to the property names of `props`. | |
* | |
* @private | |
* @param {Object} object The object to query. | |
* @param {Array} props The property names to get values for. | |
* @returns {Object} Returns the key-value pairs. | |
*/ | |
function baseToPairs(object, props) { | |
return arrayMap(props, function(key) { | |
return [key, object[key]]; | |
}); | |
} | |
/** | |
* The base implementation of `_.unary` without support for storing metadata. | |
* | |
* @private | |
* @param {Function} func The function to cap arguments for. | |
* @returns {Function} Returns the new capped function. | |
*/ | |
function baseUnary(func) { | |
return function(value) { | |
return func(value); | |
}; | |
} | |
/** | |
* The base implementation of `_.values` and `_.valuesIn` which creates an | |
* array of `object` property values corresponding to the property names | |
* of `props`. | |
* | |
* @private | |
* @param {Object} object The object to query. | |
* @param {Array} props The property names to get values for. | |
* @returns {Object} Returns the array of property values. | |
*/ | |
function baseValues(object, props) { | |
return arrayMap(props, function(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 symbol | |
* that is not found in the character symbols. | |
* | |
* @private | |
* @param {Array} strSymbols The string symbols to inspect. | |
* @param {Array} chrSymbols The character symbols to find. | |
* @returns {number} Returns the index of the first unmatched string symbol. | |
*/ | |
function charsStartIndex(strSymbols, chrSymbols) { | |
var index = -1, | |
length = strSymbols.length; | |
while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} | |
return index; | |
} | |
/** | |
* Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol | |
* that is not found in the character symbols. | |
* | |
* @private | |
* @param {Array} strSymbols The string symbols to inspect. | |
* @param {Array} chrSymbols The character symbols to find. | |
* @returns {number} Returns the index of the last unmatched string symbol. | |
*/ | |
function charsEndIndex(strSymbols, chrSymbols) { | |
var index = strSymbols.length; | |
while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} | |
return index; | |
} | |
/** | |
* Gets the number of `placeholder` occurrences in `array`. | |
* | |
* @private | |
* @param {Array} array The array to inspect. | |
* @param {*} placeholder The placeholder to search for. | |
* @returns {number} Returns the placeholder count. | |
*/ | |
function countHolders(array, placeholder) { | |
var length = array.length, | |
result = 0; | |
while (length--) { | |
if (array[length] === placeholder) { | |
++result; | |
} | |
} | |
return result; | |
} | |
/** | |
* Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A | |
* letters to basic Latin letters. | |
* | |
* @private | |
* @param {string} letter The matched letter to deburr. | |
* @returns {string} Returns the deburred letter. | |
*/ | |
var deburrLetter = basePropertyOf(deburredLetters); | |
/** | |
* Used by `_.escape` to convert characters to HTML entities. | |
* | |
* @private | |
* @param {string} chr The matched character to escape. | |
* @returns {string} Returns the escaped character. | |
*/ | |
var escapeHtmlChar = basePropertyOf(htmlEscapes); | |
/** | |
* Used by `_.template` to escape characters for inclusion in compiled string literals. | |
* | |
* @private | |
* @param {string} chr The matched character to escape. | |
* @returns {string} Returns the escaped character. | |
*/ | |
function escapeStringChar(chr) { | |
return '\\' + stringEscapes[chr]; | |
} | |
/** | |
* Gets the value at `key` of `object`. | |
* | |
* @private | |
* @param {Object} [object] The object to query. | |
* @param {string} key The key of the property to get. | |
* @returns {*} Returns the property value. | |
*/ | |
function getValue(object, key) { | |
return object == null ? undefined : object[key]; | |
} | |
/** | |
* Checks if `string` contains Unicode symbols. | |
* | |
* @private | |
* @param {string} string The string to inspect. | |
* @returns {boolean} Returns `true` if a symbol is found, else `false`. | |
*/ | |
function hasUnicode(string) { | |
return reHasUnicode.test(string); | |
} | |
/** | |
* Checks if `string` contains a word composed of Unicode symbols. | |
* | |
* @private | |
* @param {string} string The string to inspect. | |
* @returns {boolean} Returns `true` if a word is found, else `false`. | |
*/ | |
function hasUnicodeWord(string) { | |
return reHasUnicodeWord.test(string); | |
} | |
/** | |
* Converts `iterator` to an array. | |
* | |
* @private | |
* @param {Object} iterator The iterator to convert. | |
* @returns {Array} Returns the converted array. | |
*/ | |
function iteratorToArray(iterator) { | |
var data, | |
result = []; | |
while (!(data = iterator.next()).done) { | |
result.push(data.value); | |
} | |
return result; | |
} | |
/** | |
* Converts `map` to its key-value pairs. | |
* | |
* @private | |
* @param {Object} map The map to convert. | |
* @returns {Array} Returns the key-value pairs. | |
*/ | |
function mapToArray(map) { | |
var index = -1, | |
result = Array(map.size); | |
map.forEach(function(value, key) { | |
result[++index] = [key, value]; | |
}); | |
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 | |
* and returns an array of their indexes. | |
* | |
* @private | |
* @param {Array} array The array to modify. | |
* @param {*} placeholder The placeholder to replace. | |
* @returns {Array} Returns the new array of placeholder indexes. | |
*/ | |
function replaceHolders(array, placeholder) { | |
var index = -1, | |
length = array.length, | |
resIndex = 0, | |
result = []; | |
while (++index < length) { | |
var value = array[index]; | |
if (value === placeholder || value === PLACEHOLDER) { | |
array[index] = PLACEHOLDER; | |
result[resIndex++] = index; | |
} | |
} | |
return result; | |
} | |
/** | |
* Converts `set` to an array of its values. | |
* | |
* @private | |
* @param {Object} set The set to convert. | |
* @returns {Array} Returns the values. | |
*/ | |
function setToArray(set) { | |
var index = -1, | |
result = Array(set.size); | |
set.forEach(function(value) { | |
result[++index] = value; | |
}); | |
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`. | |
* | |
* @private | |
* @param {string} string The string to inspect. | |
* @returns {number} Returns the string size. | |
*/ | |
function stringSize(string) { | |
return hasUnicode(string) | |
? unicodeSize(string) | |
: asciiSize(string); | |
} | |
/** | |
* Converts `string` to an array. | |
* | |
* @private | |
* @param {string} string The string to convert. | |
* @returns {Array} Returns the converted array. | |
*/ | |
function stringToArray(string) { | |
return hasUnicode(string) | |
? unicodeToArray(string) | |
: asciiToArray(string); | |
} | |
/** | |
* Used by `_.unescape` to convert HTML entities to characters. | |
* | |
* @private | |
* @param {string} chr The matched character to unescape. | |
* @returns {string} Returns the unescaped character. | |
*/ | |
var unescapeHtmlChar = basePropertyOf(htmlUnescapes); | |
/** | |
* 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. | |
* | |
* @static | |
* @memberOf _ | |
* @since 1.1.0 | |
* @category Util | |
* @param {Object} [context=root] The context object. | |
* @returns {Function} Returns a new `lodash` function. | |
* @example | |
* | |
* _.mixin({ 'foo': _.constant('foo') }); | |
* | |
* var lodash = _.runInContext(); | |
* lodash.mixin({ 'bar': lodash.constant('bar') }); | |
* | |
* _.isFunction(_.foo); | |
* // => true | |
* _.isFunction(_.bar); | |
* // => false | |
* | |
* lodash.isFunction(lodash.foo); | |
* // => false | |
* lodash.isFunction(lodash.bar); | |
* // => true | |
* | |
* // Create a suped-up `defer` in Node.js. | |
* var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; | |
*/ | |
var runInContext = (function runInContext(context) { | |
context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); | |
/** Built-in constructor references. */ | |
var Array = context.Array, | |
Date = context.Date, | |
Error = context.Error, | |
Function = context.Function, | |
Math = context.Math, | |
Object = context.Object, | |
RegExp = context.RegExp, | |
String = context.String, | |
TypeError = context.TypeError; | |
/** Used for built-in method references. */ | |
var arrayProto = Array.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. */ | |
var funcToString = funcProto.toString; | |
/** Used to check objects for own properties. */ | |
var hasOwnProperty = objectProto.hasOwnProperty; | |
/** Used to generate unique IDs. */ | |
var idCounter = 0; | |
/** Used to detect methods masquerading as native. */ | |
var maskSrcKey = (function() { | |
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); | |
return uid ? ('Symbol(src)_1.' + uid) : ''; | |
}()); | |
/** | |
* Used to resolve the | |
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | |
* of values. | |
*/ | |
var nativeObjectToString = objectProto.toString; | |
/** Used to infer the `Object` constructor. */ | |
var objectCtorString = funcToString.call(Object); | |
/** Used to restore the original `_` reference in `_.noConflict`. */ | |
var oldDash = root._; | |
/** Used to detect if a method is native. */ | |
var reIsNative = RegExp('^' + | |
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') | |
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' | |
); | |
/** Built-in value references. */ | |
var Buffer = moduleExports ? context.Buffer : undefined, | |
Symbol = context.Symbol, | |
Uint8Array = context.Uint8Array, | |
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, | |
getPrototype = overArg(Object.getPrototypeOf, Object), | |
objectCreate = Object.create, | |
propertyIsEnumerable = objectProto.propertyIsEnumerable, | |
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.setTimeout; | |
/* Built-in method references for those with the same name as other `lodash` methods. */ | |
var nativeCeil = Math.ceil, | |
nativeFloor = Math.floor, | |
nativeGetSymbols = Object.getOwnPropertySymbols, | |
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, | |
nativeIsFinite = context.isFinite, | |
nativeJoin = arrayProto.join, | |
nativeKeys = overArg(Object.keys, Object), | |
nativeMax = Math.max, | |
nativeMin = Math.min, | |
nativeNow = Date.now, | |
nativeParseInt = context.parseInt, | |
nativeRandom = Math.random, | |
nativeReverse = arrayProto.reverse; | |
/* Built-in method references that are verified to be native. */ | |
var DataView = getNative(context, 'DataView'), | |
Map = getNative(context, 'Map'), | |
Promise = getNative(context, 'Promise'), | |
Set = getNative(context, 'Set'), | |
WeakMap = getNative(context, 'WeakMap'), | |
nativeCreate = getNative(Object, 'create'); | |
/** Used to store function metadata. */ | |
var metaMap = WeakMap && new WeakMap; | |
/** Used to lookup unminified function names. */ | |
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 | |
* chain sequences. Methods that operate on and return arrays, collections, | |
* and functions can be chained together. Methods that retrieve a single value | |
* or may return a primitive value will automatically end the chain sequence | |
* and return the unwrapped value. Otherwise, the value must be unwrapped | |
* with `_#value`. | |
* | |
* Explicit chain sequences, which must be unwrapped with `_#value`, may be | |
* enabled using `_.chain`. | |
* | |
* The execution of chained methods is lazy, that is, it's deferred until | |
* `_#value` is implicitly or explicitly called. | |
* | |
* Lazy evaluation allows several methods to support shortcut fusion. | |
* Shortcut fusion is an optimization to merge iteratee calls; this avoids | |
* the creation of intermediate arrays and can greatly reduce the number of | |
* iteratee executions. Sections of a chain sequence qualify for shortcut | |
* fusion if the section is applied to an array of at least `200` 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 | |
* directly or indirectly included in the build. | |
* | |
* In addition to lodash methods, wrappers have `Array` and `String` methods. | |
* | |
* The wrapper `Array` methods are: | |
* `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` | |
* | |
* The wrapper `String` methods are: | |
* `replace` and `split` | |
* | |
* The wrapper methods that support shortcut fusion are: | |
* `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, | |
* `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, | |
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` | |
* | |
* The chainable wrapper methods are: | |
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, | |
* `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, | |
* `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, | |
* `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, | |
* `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, | |
* `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, | |
* `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, | |
* `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, | |
* `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, | |
* `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, | |
* `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, | |
* `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, | |
* `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, | |
* `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, | |
* `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, | |
* `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, | |
* `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, | |
* `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, | |
* `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, | |
* `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, | |
* `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, | |
* `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: | |
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, | |
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, | |
* `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, | |
* `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, | |
* `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, | |
* `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, | |
* `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, | |
* `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, | |
* `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, | |
* `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, | |
* `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, | |
* `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, | |
* `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, | |
* `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, | |
* `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, | |
* `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, | |
* `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, | |
* `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, | |
* `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, | |
* `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 _ | |
* @constructor | |
* @category Seq | |
* @param {*} value The value to wrap in a `lodash` instance. | |
* @returns {Object} Returns the new `lodash` wrapper instance. | |
* @example | |
* | |
* function square(n) { | |
* return n * n; | |
* } | |
* | |
* var wrapped = _([1, 2, 3]); | |
* | |
* // Returns an unwrapped value. | |
* wrapped.reduce(_.add); | |
* // => 6 | |
* | |
* // Returns a wrapped value. | |
* var squares = wrapped.map(square); | |
* | |
* _.isArray(squares); | |
* // => false | |
* | |
* _.isArray(squares.value()); | |
* // => true | |
*/ | |
function lodash(value) { | |
if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { | |
if (value instanceof LodashWrapper) { | |
return value; | |
} | |
if (hasOwnProperty.call(value, '__wrapped__')) { | |
return wrapperClone(value); | |
} | |
} | |
return new LodashWrapper(value); | |
} | |
/** | |
* 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 | |
*/ | |
function baseLodash() { | |
// No operation performed. | |
} | |
/** | |
* The base constructor for creating `lodash` wrapper objects. | |
* | |
* @private | |
* @param {*} value The value to wrap. | |
* @param {boolean} [chainAll] Enable explicit method chain sequences. | |
*/ | |
function LodashWrapper(value, chainAll) { | |
this.__wrapped__ = value; | |
this.__actions__ = []; | |
this.__chain__ = !!chainAll; | |
this.__index__ = 0; | |
this.__values__ = undefined; | |
} | |
/** | |
* By default, the template delimiters used by lodash are like those in | |
* embedded Ruby (ERB). Change the following template settings to use | |
* alternative delimiters. | |
* | |
* @static | |
* @memberOf _ | |
* @type {Object} | |
*/ | |
lodash.templateSettings = { | |
/** | |
* Used to detect `data` property values to be HTML-escaped. | |
* | |
* @memberOf _.templateSettings | |
* @type {RegExp} | |
*/ | |
'escape': reEscape, | |
/** | |
* Used to detect code to be evaluated. | |
* | |
* @memberOf _.templateSettings | |
* @type {RegExp} | |
*/ | |
'evaluate': reEvaluate, | |
/** | |
* Used to detect `data` property values to inject. | |
* | |
* @memberOf _.templateSettings | |
* @type {RegExp} | |
*/ | |
'interpolate': reInterpolate, | |
/** | |
* Used to reference the data object in the template text. | |
* | |
* @memberOf _.templateSettings | |
* @type {string} | |
*/ | |
'variable': '', | |
/** | |
* Used to import variables into the compiled template. | |
* | |
* @memberOf _.templateSettings | |
* @type {Object} | |
*/ | |
'imports': { | |
/** | |
* A reference to the `lodash` function. | |
* | |
* @memberOf _.templateSettings.imports | |
* @type {Function} | |
*/ | |
'_': 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 evaluation. | |
* | |
* @private | |
* @constructor | |
* @param {*} value The value to wrap. | |
*/ | |
function LazyWrapper(value) { | |
this.__wrapped__ = value; | |
this.__actions__ = []; | |
this.__dir__ = 1; | |
this.__filtered__ = false; | |
this.__iteratees__ = []; | |
this.__takeCount__ = MAX_ARRAY_LENGTH; | |
this.__views__ = []; | |
} | |
/** | |
* Creates a clone of the lazy wrapper object. | |
* | |
* @private | |
* @name clone | |
* @memberOf LazyWrapper | |
* @returns {Object} Returns the cloned `LazyWrapper` object. | |
*/ | |
function lazyClone() { | |
var result = new LazyWrapper(this.__wrapped__); | |
result.__actions__ = copyArray(this.__actions__); | |
result.__dir__ = this.__dir__; | |
result.__filtered__ = this.__filtered__; | |
result.__iteratees__ = copyArray(this.__iteratees__); | |
result.__takeCount__ = this.__takeCount__; | |
result.__views__ = copyArray(this.__views__); | |
return result; | |
} | |
/** | |
* Reverses the direction of lazy iteration. | |
* | |
* @private | |
* @name reverse | |
* @memberOf LazyWrapper | |
* @returns {Object} Returns the new reversed `LazyWrapper` object. | |
*/ | |
function lazyReverse() { | |
if (this.__filtered__) { | |
var result = new LazyWrapper(this); | |
result.__dir__ = -1; | |
result.__filtered__ = true; | |
} else { | |
result = this.clone(); | |
result.__dir__ *= -1; | |
} | |
return result; | |
} | |
/** | |
* Extracts the unwrapped value from its lazy wrapper. | |
* | |
* @private | |
* @name value | |
* @memberOf LazyWrapper | |
* @returns {*} Returns the unwrapped value. | |
*/ | |
function lazyValue() { | |
var array = this.__wrapped__.value(), | |
dir = this.__dir__, | |
isArr = isArray(array), | |
isRight = dir < 0, | |
arrLength = isArr ? array.length : 0, | |
view = getView(0, arrLength, this.__views__), | |
start = view.start, | |
end = view.end, | |
length = end - start, | |
index = isRight ? end : (start - 1), | |
iteratees = this.__iteratees__, | |
iterLength = iteratees.length, | |
resIndex = 0, | |
takeCount = nativeMin(length, this.__takeCount__); | |
if (!isArr || arrLength < LARGE_ARRAY_SIZE || | |
(arrLength == length && takeCount == length)) { | |
return baseWrapperValue(array, this.__actions__); | |
} | |
var result = []; | |
outer: | |
while (length-- && resIndex < takeCount) { | |
index += dir; | |
var iterIndex = -1, | |
value = array[index]; | |
while (++iterIndex < iterLength) { | |
var data = iteratees[iterIndex], | |
iteratee = data.iteratee, | |
type = data.type, | |
computed = iteratee(value); | |
if (type == LAZY_MAP_FLAG) { | |
value = computed; | |
} else if (!computed) { | |
if (type == LAZY_FILTER_FLAG) { | |
continue outer; | |
} else { | |
break outer; | |
} | |
} | |
} | |
result[resIndex++] = value; | |
} | |
return result; | |
} | |
// Ensure `LazyWrapper` is an instance of `baseLodash`. | |
LazyWrapper.prototype = baseCreate(baseLodash.prototype); | |
LazyWrapper.prototype.constructor = LazyWrapper; | |
/*------------------------------------------------------------------------*/ | |
/** | |
* Creates a hash object. | |
* | |
* @private | |
* @constructor | |
* @param {Array} [entries] The key-value pairs to cache. | |
*/ | |
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. | |
* | |
* @private | |
* @name delete | |
* @memberOf Hash | |
* @param {Object} hash The hash to modify. | |
* @param {string} key The key of the value to remove. | |
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
*/ | |
function hashDelete(key) { | |
var result = this.has(key) && delete this.__data__[key]; | |
this.size -= result ? 1 : 0; | |
return result; | |
} | |
/** | |
* Gets the hash value for `key`. | |
* | |
* @private | |
* @name get | |
* @memberOf Hash | |
* @param {string} key The key of the value to get. | |
* @returns {*} Returns the entry value. | |
*/ | |
function hashGet(key) { | |
var data = this.__data__; | |
if (nativeCreate) { | |
var result = data[key]; | |
return result === HASH_UNDEFINED ? undefined : result; | |
} | |
return hasOwnProperty.call(data, key) ? data[key] : undefined; | |
} | |
/** | |
* Checks if a hash value for `key` exists. | |
* | |
* @private | |
* @name has | |
* @memberOf Hash | |
* @param {string} key The key of the entry to check. | |
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | |
*/ | |
function hashHas(key) { | |
var data = this.__data__; | |
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); | |
} | |
/** | |
* Sets the hash `key` to `value`. | |
* | |
* @private | |
* @name set | |
* @memberOf Hash | |
* @param {string} key The key of the value to set. | |
* @param {*} value The value to set. | |
* @returns {Object} Returns the hash instance. | |
*/ | |
function hashSet(key, 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 `false`. | |
*/ | |
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. | |
* | |
* @private | |
* @constructor | |
* @param {Array} [entries] The key-value pairs to cache. | |
*/ | |
function MapCache(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 map. | |
* | |
* @private | |
* @name clear | |
* @memberOf MapCache | |
*/ | |
function mapCacheClear() { | |
this.size = 0; | |
this.__data__ = { | |
'hash': new Hash, | |
'map': new (Map || ListCache), | |
'string': new Hash | |
}; | |
} | |
/** | |
* Removes `key` and its value from the map. | |
* | |
* @private | |
* @name delete | |
* @memberOf MapCache | |
* @param {string} key The key of the value to remove. | |
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
*/ | |
function mapCacheDelete(key) { | |
var result = getMapData(this, key)['delete'](key); | |
this.size -= result ? 1 : 0; | |
return result; | |
} | |
/** | |
* Gets the map value for `key`. | |
* | |
* @private | |
* @name get | |
* @memberOf MapCache | |
* @param {string} key The key of the value to get. | |
* @returns {*} Returns the entry value. | |
*/ | |
function mapCacheGet(key) { | |
return getMapData(this, key).get(key); | |
} | |
/** | |
* Checks if a map value for `key` exists. | |
* | |
* @private | |
* @name has | |
* @memberOf MapCache | |
* @param {string} key The key of the entry to check. | |
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | |
*/ | |
function mapCacheHas(key) { | |
return getMapData(this, key).has(key); | |
} | |
/** | |
* Sets the map `key` to `value`. | |
* | |
* @private | |
* @name set | |
* @memberOf MapCache | |
* @param {string} key The key of the value to set. | |
* @param {*} value The value to set. | |
* @returns {Object} Returns the map cache instance. | |
*/ | |
function mapCacheSet(key, value) { | |
var data = getMapData(this, key), | |
size = data.size; | |
data.set(key, value); | |
this.size += data.size == size ? 0 : 1; | |
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 an array cache object to store unique values. | |
* | |
* @private | |
* @constructor | |
* @param {Array} [values] The values to cache. | |
*/ | |
function SetCache(values) { | |
var index = -1, | |
length = values == null ? 0 : values.length; | |
this.__data__ = new MapCache; | |
while (++index < length) { | |
this.add(values[index]); | |
} | |
} | |
/** | |
* Adds `value` to the array cache. | |
* | |
* @private | |
* @name add | |
* @memberOf SetCache | |
* @alias push | |
* @param {*} value The value to cache. | |
* @returns {Object} Returns the cache instance. | |
*/ | |
function setCacheAdd(value) { | |
this.__data__.set(value, HASH_UNDEFINED); | |
return this; | |
} | |
/** | |
* Checks if `value` is in the array cache. | |
* | |
* @private | |
* @name has | |
* @memberOf SetCache | |
* @param {*} value The value to search for. | |
* @returns {number} Returns `true` if `value` is found, else `false`. | |
*/ | |
function setCacheHas(value) { | |
return this.__data__.has(value); | |
} | |
// 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. | |
* | |
* @private | |
* @constructor | |
* @param {Array} [entries] The key-value pairs to cache. | |
*/ | |
function Stack(entries) { | |
var data = this.__data__ = new ListCache(entries); | |
this.size = data.size; | |
} | |
/** | |
* Removes all key-value entries from the stack. | |
* | |
* @private | |
* @name clear | |
* @memberOf Stack | |
*/ | |
function stackClear() { | |
this.__data__ = new ListCache; | |
this.size = 0; | |
} | |
/** | |
* Removes `key` and its value from the stack. | |
* | |
* @private | |
* @name delete | |
* @memberOf Stack | |
* @param {string} key The key of the value to remove. | |
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | |
*/ | |
function stackDelete(key) { | |
var data = this.__data__, | |
result = data['delete'](key); | |
this.size = data.size; | |
return result; | |
} | |
/** | |
* Gets the stack value for `key`. | |
* | |
* @private | |
* @name get | |
* @memberOf Stack | |
* @param {string} key The key of the value to get. | |
* @returns {*} Returns the entry value. | |
*/ | |
function stackGet(key) { | |
return this.__data__.get(key); | |
} | |
/** | |
* Checks if a stack value for `key` exists. | |
* | |
* @private | |
* @name has | |
* @memberOf Stack | |
* @param {string} key The key of the entry to check. | |
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | |
*/ | |
function stackHas(key) { | |
return this.__data__.has(key); | |
} | |
/** | |
* Sets the stack `key` to `value`. | |
* | |
* @private | |
* @name set | |
* @memberOf Stack | |
* @param {string} key The key of the value to set. | |
* @param {*} value The value to set. | |
* @returns {Object} Returns the stack cache instance. | |
*/ | |
function stackSet(key, value) { | |
var data = this.__data__; | |
if (data instanceof ListCache) { | |
var pairs = data.__data__; | |
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { | |
pairs.push([key, value]); | |
this.size = ++data.size; | |
return this; | |
} | |
data = this.__data__ = new MapCache(pairs); | |
} | |
data.set(key, value); | |
this.size = data.size; | |
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; | |
/*------------------------------------------------------------------------*/ | |
/** | |
* Creates an array of the enumerable property names of the array-like `value`. | |
* | |
* @private | |
* @param {*} value The value to query. | |
* @param {boolean} inherited Specify returning inherited property names. | |
* @returns {Array} Returns the array of property names. | |
*/ | |
function arrayLikeKeys(value, inherited) { | |
var isArr = isArray(value), | |
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) { | |
if ((inherited || hasOwnProperty.call(value, key)) && | |
!(skipIndexes && ( | |
// Safari 9 has enumerable `arguments.length` in strict mode. | |
key == 'length' || | |
// Node.js 0.10 has enumerable non-index properties on buffers. | |
(isBuff && (key == 'offset' || key == 'parent')) || | |
// PhantomJS 2 has enumerable non-index properties on typed arrays. | |
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || | |
// Skip index properties. | |
isIndex(key, length) | |
))) { | |
result.push(key); | |
} | |
} | |
return result; | |
} | |
/** | |
* A specialized version of `_.sample` for arrays. | |
* | |
* @private | |
* @param {Array} array The array to sample. | |
* @returns {*} Returns the random element. | |
*/ | |
function arraySample(array) { | |
var length = array.length; | |
return length ? array[baseRandom(0, length - 1)] : undefined; | |
} | |
/** | |
* A specialized version of `_.sampleSize` for arrays. | |
* | |
* @private | |
* @param {Array} array The array to sample. | |
* @param {number} n The number of elements to sample. | |
* @returns {Array} Returns the random elements. | |
*/ | |
function arraySampleSize(array, n) { | |
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); | |
} | |
/** | |
* A specialized version of `_.shuffle` for arrays. | |
* | |
* @private | |
* @param {Array} array The array to shuffle. | |
* @returns {Array} Returns the new shuffled array. | |
*/ | |
function arrayShuffle(array) { | |
return shuffleSelf(copyArray(array)); | |
} | |
/** | |
* Used by `_.defaults` to customize its `_.assignIn` use. | |
* | |
* @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 assignInDefaults(objValue, srcValue, key, object) { | |
if (objValue === undefined || | |
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { | |
return srcValue; | |
} | |
return objValue; | |
} | |
/** | |
* This function is like `assignValue` except that it doesn't assign | |
* `undefined` values. | |
* | |
* @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 assignMergeValue(object, key, value) { | |
if ((value !== undefined && !eq(object[key], value)) || | |
(value === undefined && !(key in object))) { | |
baseAssignValue(object, key, value); | |
} | |
} | |
/** | |
* Assigns `value` to `key` of `object` if the existing value is not equivalent | |
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) | |
* for equality comparisons. | |
* | |
* @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 assignValue(object, key, value) { | |
var objValue = object[key]; | |
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || | |
(value === undefined && !(key in object))) { | |
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 transformed | |
* 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 sources | |
* or `customizer` functions. | |
* | |
* @private | |
* @param {Object} object The destination object. | |
* @param {Object} source The source object. | |
* @returns {Object} Returns `object`. | |
*/ | |
function baseAssign(object, source) { | |
return object && copyObject(source, keys(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. | |
* | |
* @private | |
* @param {Object} object The object to iterate over. | |
* @param {string[]} paths The property paths of elements to pick. | |
* @returns {Array} Returns the picked elements. | |
*/ | |
function baseAt(object, paths) { | |
var index = -1, | |
length = paths.length, | |
result = Array(length), | |
skip = object == null; | |
while (++index < length) { | |
result[index] = skip ? undefined : get(object, paths[index]); | |
} | |
return result; | |
} | |
/** | |
* The base implementation of `_.clamp` which doesn't coerce arguments. | |
* | |
* @private | |
* @param {number} number The number to clamp. | |
* @param {number} [lower] The lower bound. | |
* @param {number} upper The upper bound. | |
* @returns {number} Returns the clamped number. | |
*/ | |
function baseClamp(number, lower, upper) { | |
if (number === number) { | |
if (upper !== undefined) { | |
number = number <= upper ? number : upper; | |
} | |
if (lower !== undefined) { | |
number = number >= lower ? number : lower; | |
} | |
} | |
return number; | |
} | |
/** | |
* The base implementation of `_.clone` and `_.cloneDeep` which tracks | |
* traversed objects. | |
* | |
* @private | |
* @param {*} value The value to clone. | |
* @param {boolean} [isDeep] Specify a deep clone. | |
* @param {boolean} [isFull] Specify a clone including symbols. | |
* @param {Function} [customizer] The function to customize cloning. | |
* @param {string} [key] The key of `value`. | |
* @param {Object} [object] The parent object of `value`. | |
* @param {Object} [stack] Tracks traversed objects and their clone counterparts. | |
* @returns {*} Returns the cloned value. | |
*/ | |
function baseClone(value, isDeep, isFull, customizer, key, object, stack) { | |
var result; | |
if (customizer) { | |
result = object ? customizer(value, key, object, stack) : customizer(value); | |
} | |
if (result !== undefined) { | |
return result; | |
} | |
if (!isObject(value)) { | |
return value; | |
} | |
var isArr = isArray(value); | |
if (isArr) { | |
result = initCloneArray(value); | |
if (!isDeep) { | |
return copyArray(value, result); | |
} | |
} else { | |
var tag = getTag(value), | |
isFunc = tag == funcTag || tag == genTag; | |
if (isBuffer(value)) { | |
return cloneBuffer(value, isDeep); | |
} | |
if (tag == objectTag || tag == argsTag || (isFunc && !object)) { | |
result = initCloneObject(isFunc ? {} : value); | |
if (!isDeep) { | |
return copySymbols(value, baseAssign(result, value)); | |
} | |
} else { | |
if (!cloneableTags[tag]) { | |
return object ? value : {}; | |
} | |
result = initCloneByTag(value, tag, baseClone, isDeep); | |
} | |
} | |
// Check for circular references and return its corresponding clone. | |
stack || (stack = new Stack); | |
var stacked = stack.get(value); | |
if (stacked) { | |
return stacked; | |
} | |
stack.set(value, result); | |
var props = isArr ? undefined : (isFull ? getAllKeys : keys)(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, isDeep, isFull, customizer, key, value, stack)); | |
}); | |
return result; | |
} | |
/** | |
* The base implementation of `_.conforms` which doesn't clone `source`. | |
* | |
* @private | |
* @param {Object} source The object of property predicates to conform to. | |
* @returns {Function} Returns the new spec function. | |
*/ | |
function baseConforms(source) { | |
var props = keys(source); | |
return function(object) { | |
return baseConformsTo(object, source, props); | |
}; | |
} | |
/** | |
* The base implementation of `_.conformsTo` which accepts `props` to check. | |
* | |
* @private | |
* @param {Object} object The object to inspect. | |
* @param {Object} source The object of property predicates to conform to. | |
* @returns {boolean} Returns `true` if `object` conforms, else `false`. | |
*/ | |
function baseConformsTo(object, source, props) { | |
var length = props.length; | |
if (object == null) { | |
return !length; | |
} | |
object = Object(object); | |
while (length--) { | |
var key = props[length], | |
predicate = source[key], | |
value = object[key]; | |
if ((value === undefined && !(key in object)) || !predicate(value)) { | |
return false; | |
} | |
} | |
return true; | |
} | |
/** | |
* The base implementation of `_.delay` and `_.defer` which accepts `args` | |
* to provide to `func`. | |
* | |
* @private | |
* @param {Function} func The function to delay. | |
* @param {number} wait The number of milliseconds to delay invocation. | |
* @param {Array} args The arguments to provide to `func`. | |
* @returns {number|Object} Returns the timer id or timeout object. | |
*/ | |
function baseDelay(func, wait, args) { | |
if (typeof func != 'function') { | |
throw new TypeError(FUNC_ERROR_TEXT); | |
} | |
return setTimeout(function() { func.apply(undefined, args); }, wait); | |
} | |
/** | |
* The base implementation of methods like `_.difference` without support | |
* for excluding multiple arrays or iteratee shorthands. | |
* | |
* @private | |
* @param {Array} array The array to inspect. | |
* @param {Array} values The values to exclude. | |
* @param {Function} [iteratee] The iteratee invoked per element. | |
* @param {Function} [comparator] The comparator invoked per element. | |
* @returns {Array} Returns the new array of filtered values. | |
*/ | |
function baseDifference(array, values, iteratee, comparator) { | |
var index = -1, | |
includes = arrayIncludes, | |
isCommon = true, | |
length = array.length, | |
result = [], | |
valuesLength = values.length; | |
if (!length) { | |
return result; | |
} | |
if (iteratee) { | |
values = arrayMap(values, baseUnary(iteratee)); | |
} | |
if (comparator) { | |
includes = arrayIncludesWith; | |
isCommon = false; | |
} | |
else if (values.length >= LARGE_ARRAY_SIZE) { | |
includes = cacheHas; | |
isCommon = false; | |
values = new SetCache(values); | |
} | |
outer: | |
while (++index < length) { | |
var value = array[index], | |
computed = iteratee == null ? value : iteratee(value); | |
value = (comparator || value !== 0) ? value : 0; | |
if (isCommon && computed === computed) { | |
var valuesIndex = valuesLength; | |
while (valuesIndex--) { | |
if (values[valuesIndex] === computed) { | |
continue outer; | |
} | |
} | |
result.push(value); | |
} | |
else if (!includes(values, computed, comparator)) { | |
result.push(value); | |
} | |
} | |
return result; | |
} | |
/** | |
* The base implementation of `_.forEach` without support for iteratee shorthands. | |
* | |
* @private | |
* @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array|Object} Returns `collection`. | |
*/ | |
var baseEach = createBaseEach(baseForOwn); | |
/** | |
* The base implementation of `_.forEachRight` without support for iteratee shorthands. | |
* | |
* @private | |
* @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array|Object} Returns `collection`. | |
*/ | |
var baseEachRight = createBaseEach(baseForOwnRight, true); | |
/** | |
* The base implementation of `_.every` without support for iteratee shorthands. | |
* | |
* @private | |
* @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | |
* @returns {boolean} Returns `true` if all elements pass the predicate check, | |
* else `false` | |
*/ | |
function baseEvery(collection, predicate) { | |
var result = true; | |
baseEach(collection, function(value, index, collection) { | |
result = !!predicate(value, index, collection); | |
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. | |
* | |
* @private | |
* @param {Array} array The array to fill. | |
* @param {*} value The value to fill `array` with. | |
* @param {number} [start=0] The start position. | |
* @param {number} [end=array.length] The end position. | |
* @returns {Array} Returns `array`. | |
*/ | |
function baseFill(array, value, start, end) { | |
var length = array.length; | |
start = toInteger(start); | |
if (start < 0) { | |
start = -start > length ? 0 : (length + start); | |
} | |
end = (end === undefined || end > length) ? length : toInteger(end); | |
if (end < 0) { | |
end += length; | |
} | |
end = start > end ? 0 : toLength(end); | |
while (start < end) { | |
array[start++] = value; | |
} | |
return array; | |
} | |
/** | |
* The base implementation of `_.filter` without support for iteratee shorthands. | |
* | |
* @private | |
* @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} predicate The function invoked per iteration. | |
* @returns {Array} Returns the new filtered array. | |
*/ | |
function baseFilter(collection, predicate) { | |
var result = []; | |
baseEach(collection, function(value, index, collection) { | |
if (predicate(value, index, collection)) { | |
result.push(value); | |
} | |
}); | |
return result; | |
} | |
/** | |
* The base implementation of `_.flatten` with support for restricting flattening. | |
* | |
* @private | |
* @param {Array} array The array to flatten. | |
* @param {number} depth The maximum recursion depth. | |
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration. | |
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. | |
* @param {Array} [result=[]] The initial result value. | |
* @returns {Array} Returns the new flattened array. | |
*/ | |
function baseFlatten(array, depth, predicate, isStrict, result) { | |
var index = -1, | |
length = array.length; | |
predicate || (predicate = isFlattenable); | |
result || (result = []); | |
while (++index < length) { | |
var value = array[index]; | |
if (depth > 0 && predicate(value)) { | |
if (depth > 1) { | |
// Recursively flatten arrays (susceptible to call stack limits). | |
baseFlatten(value, depth - 1, predicate, isStrict, result); | |
} else { | |
arrayPush(result, value); | |
} | |
} else if (!isStrict) { | |
result[result.length] = value; | |
} | |
} | |
return result; | |
} | |
/** | |
* The base implementation of `baseForOwn` which iterates over `object` | |
* properties returned by `keysFunc` and invokes `iteratee` for each property. | |
* Iteratee functions may exit iteration early by explicitly returning `false`. | |
* | |
* @private | |
* @param {Object} object The object to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @param {Function} keysFunc The function to get the keys of `object`. | |
* @returns {Object} Returns `object`. | |
*/ | |
var baseFor = createBaseFor(); | |
/** | |
* This function is like `baseFor` except that it iterates over properties | |
* in the opposite order. | |
* | |
* @private | |
* @param {Object} object The object to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @param {Function} keysFunc The function to get the keys of `object`. | |
* @returns {Object} Returns `object`. | |
*/ | |
var baseForRight = createBaseFor(true); | |
/** | |
* The base implementation of `_.forOwn` without support for iteratee shorthands. | |
* | |
* @private | |
* @param {Object} object The object to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @returns {Object} Returns `object`. | |
*/ | |
function baseForOwn(object, iteratee) { | |
return object && baseFor(object, iteratee, keys); | |
} | |
/** | |
* The base implementation of `_.forOwnRight` without support for iteratee shorthands. | |
* | |
* @private | |
* @param {Object} object The object to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @returns {Object} Returns `object`. | |
*/ | |
function baseForOwnRight(object, iteratee) { | |
return object && baseForRight(object, iteratee, keys); | |
} | |
/** | |
* The base implementation of `_.functions` which creates an array of | |
* `object` function property names filtered from `props`. | |
* | |
* @private | |
* @param {Object} object The object to inspect. | |
* @param {Array} props The property names to filter. | |
* @returns {Array} Returns the function names. | |
*/ | |
function baseFunctions(object, props) { | |
return arrayFilter(props, function(key) { | |
return isFunction(object[key]); | |
}); | |
} | |
/** | |
* The base implementation of `_.get` without support for default values. | |
* | |
* @private | |
* @param {Object} object The object to query. | |
* @param {Array|string} path The path of the property to get. | |
* @returns {*} Returns the resolved value. | |
*/ | |
function baseGet(object, path) { | |
path = isKey(path, object) ? [path] : castPath(path); | |
var index = 0, | |
length = path.length; | |
while (object != null && index < length) { | |
object = object[toKey(path[index++])]; | |
} | |
return (index && index == length) ? object : undefined; | |
} | |
/** | |
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses | |
* `keysFunc` and `symbolsFunc` to get the enumerable property names and | |
* symbols of `object`. | |
* | |
* @private | |
* @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 environments. | |
* | |
* @private | |
* @param {*} value The value to query. | |
* @returns {string} Returns the `toStringTag`. | |
*/ | |
function baseGetTag(value) { | |
if (value == null) { | |
return value === undefined ? undefinedTag : nullTag; | |
} | |
value = Object(value); | |
return (symToStringTag && symToStringTag in 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. | |
* @returns {boolean} Returns `true` if `key` exists, else `false`. | |
*/ | |
function baseHas(object, key) { | |
return object != null && hasOwnProperty.call(object, key); | |
} | |
/** | |
* The base implementation of `_.hasIn` without support for deep paths. | |
* | |
* @private | |
* @param {Object} [object] The object to query. | |
* @param {Array|string} key The key to check. | |
* @returns {boolean} Returns `true` if `key` exists, else `false`. | |
*/ | |
function baseHasIn(object, key) { | |
return object != null && key in Object(object); | |
} | |
/** | |
* The base implementation of `_.inRange` which doesn't coerce arguments. | |
* | |
* @private | |
* @param {number} number The number to check. | |
* @param {number} start The start of the range. | |
* @param {number} end The end of the range. | |
* @returns {boolean} Returns `true` if `number` is in the range, else `false`. | |
*/ | |
function baseInRange(number, start, end) { | |
return number >= nativeMin(start, end) && number < nativeMax(start, end); | |
} | |
/** | |
* The base implementation of methods like `_.intersection`, without support | |
* for iteratee shorthands, that accepts an array of arrays to inspect. | |
* | |
* @private | |
* @param {Array} arrays The arrays to inspect. | |
* @param {Function} [iteratee] The iteratee invoked per element. | |
* @param {Function} [comparator] The comparator invoked per element. | |
* @returns {Array} Returns the new array of shared values. | |
*/ | |
function baseIntersection(arrays, iteratee, comparator) { | |
var includes = comparator ? arrayIncludesWith : arrayIncludes, | |
length = arrays[0].length, | |
othLength = arrays.length, | |
othIndex = othLength, | |
caches = Array(othLength), | |
maxLength = Infinity, | |
result = []; | |
while (othIndex--) { | |
var array = arrays[othIndex]; | |
if (othIndex && iteratee) { | |
array = arrayMap(array, baseUnary(iteratee)); | |
} | |
maxLength = nativeMin(array.length, maxLength); | |
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) | |
? new SetCache(othIndex && array) | |
: undefined; | |
} | |
array = arrays[0]; | |
var index = -1, | |
seen = caches[0]; | |
outer: | |
while (++index < length && result.length < maxLength) { | |
var value = array[index], | |
computed = iteratee ? iteratee(value) : value; | |
value = (comparator || value !== 0) ? value : 0; | |
if (!(seen | |
? cacheHas(seen, computed) | |
: includes(result, computed, comparator) | |
)) { | |
othIndex = othLength; | |
while (--othIndex) { | |
var cache = caches[othIndex]; | |
if (!(cache | |
? cacheHas(cache, computed) | |
: includes(arrays[othIndex], computed, comparator)) | |
) { | |
continue outer; | |
} | |
} | |
if (seen) { | |
seen.push(computed); | |
} | |
result.push(value); | |
} | |
} | |
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 | |
* method arguments. | |
* | |
* @private | |
* @param {Object} object The object to query. | |
* @param {Array|string} path The path of the method to invoke. | |
* @param {Array} args The arguments to invoke the method with. | |
* @returns {*} Returns the result of the invoked method. | |
*/ | |
function baseInvoke(object, path, args) { | |
if (!isKey(path, object)) { | |
path = castPath(path); | |
object = parent(object, path); | |
path = last(path); | |
} | |
var func = object == null ? object : object[toKey(path)]; | |
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 optimizations. | |
* | |
* @private | |
* @param {*} value The value to check. | |
* @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. | |
*/ | |
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 `false`. | |
*/ | |
function baseIsDate(value) { | |
return isObjectLike(value) && baseGetTag(value) == dateTag; | |
} | |
/** | |
* The base implementation of `_.isEqual` which supports partial comparisons | |
* and tracks traversed objects. | |
* | |
* @private | |
* @param {*} value The value to compare. | |
* @param {*} other The other value to compare. | |
* @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. | |
* @returns {boolean} Returns `true` if the values are equivalent, else `false`. | |
*/ | |
function baseIsEqual(value, other, customizer, bitmask, stack) { | |
if (value === other) { | |
return true; | |
} | |
if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { | |
return value !== value && other !== other; | |
} | |
return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack); | |
} | |
/** | |
* A specialized version of `baseIsEqual` for arrays and objects which performs | |
* deep comparisons and tracks traversed objects enabling objects with circular | |
* references to be compared. | |
* | |
* @private | |
* @param {Object} object The object to compare. | |
* @param {Object} other The other object to compare. | |
* @param {Function} equalFunc The function to determine equivalents of values. | |
* @param {Function} [customizer] The function to customize comparisons. | |
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` | |
* for more details. | |
* @param {Object} [stack] Tracks traversed `object` and `other` objects. | |
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`. | |
*/ | |
function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) { | |
var objIsArr = isArray(object), | |
othIsArr = isArray(other), | |
objTag = arrayTag, | |
othTag = arrayTag; | |
if (!objIsArr) { | |
objTag = getTag(object); | |
objTag = objTag == argsTag ? objectTag : objTag; | |
} | |
if (!othIsArr) { | |
othTag = getTag(other); | |
othTag = othTag == argsTag ? objectTag : othTag; | |
} | |
var objIsObj = objTag == objectTag, | |
othIsObj = othTag == objectTag, | |
isSameTag = objTag == othTag; | |
if (isSameTag && isBuffer(object)) { | |
if (!isBuffer(other)) { | |
return false; | |
} | |
objIsArr = true; | |
objIsObj = false; | |
} | |
if (isSameTag && !objIsObj) { | |
stack || (stack = new Stack); | |
return (objIsArr || isTypedArray(object)) | |
? equalArrays(object, other, equalFunc, customizer, bitmask, stack) | |
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack); | |
} | |
if (!(bitmask & PARTIAL_COMPARE_FLAG)) { | |
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), | |
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); | |
if (objIsWrapped || othIsWrapped) { | |
var objUnwrapped = objIsWrapped ? object.value() : object, | |
othUnwrapped = othIsWrapped ? other.value() : other; | |
stack || (stack = new Stack); | |
return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack); | |
} | |
} | |
if (!isSameTag) { | |
return false; | |
} | |
stack || (stack = new Stack); | |
return equalObjects(object, other, equalFunc, customizer, 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 shorthands. | |
* | |
* @private | |
* @param {Object} object The object to inspect. | |
* @param {Object} source The object of property values to match. | |
* @param {Array} matchData The property names, values, and compare flags to match. | |
* @param {Function} [customizer] The function to customize comparisons. | |
* @returns {boolean} Returns `true` if `object` is a match, else `false`. | |
*/ | |
function baseIsMatch(object, source, matchData, customizer) { | |
var index = matchData.length, | |
length = index, | |
noCustomizer = !customizer; | |
if (object == null) { | |
return !length; | |
} | |
object = Object(object); | |
while (index--) { | |
var data = matchData[index]; | |
if ((noCustomizer && data[2]) | |
? data[1] !== object[data[0]] | |
: !(data[0] in object) | |
) { | |
return false; | |
} | |
} | |
while (++index < length) { | |
data = matchData[index]; | |
var key = data[0], | |
objValue = object[key], | |
srcValue = data[1]; | |
if (noCustomizer && data[2]) { | |
if (objValue === undefined && !(key in object)) { | |
return false; | |
} | |
} else { | |
var stack = new Stack; | |
if (customizer) { | |
var result = customizer(objValue, srcValue, key, object, source, stack); | |
} | |
if (!(result === undefined | |
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) | |
: result | |
)) { | |
return false; | |
} | |
} | |
} | |
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 `false`. | |
*/ | |
function baseIsTypedArray(value) { | |
return isObjectLike(value) && | |
isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; | |
} | |
/** | |
* The base implementation of `_.iteratee`. | |
* | |
* @private | |
* @param {*} [value=_.identity] The value to convert to an iteratee. | |
* @returns {Function} Returns the iteratee. | |
*/ | |
function baseIteratee(value) { | |
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. | |
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. | |
if (typeof value == 'function') { | |
return value; | |
} | |
if (value == null) { | |
return identity; | |
} | |
if (typeof value == 'object') { | |
return isArray(value) | |
? baseMatchesProperty(value[0], value[1]) | |
: baseMatches(value); | |
} | |
return property(value); | |
} | |
/** | |
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense. | |
* | |
* @private | |
* @param {Object} object The object to query. | |
* @returns {Array} Returns the array of property names. | |
*/ | |
function baseKeys(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 treat sparse arrays as dense. | |
* | |
* @private | |
* @param {Object} object The object to query. | |
* @returns {Array} Returns the array of property names. | |
*/ | |
function baseKeysIn(object) { | |
if (!isObject(object)) { | |
return nativeKeysIn(object); | |
} | |
var isProto = isPrototype(object), | |
result = []; | |
for (var key in object) { | |
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { | |
result.push(key); | |
} | |
} | |
return result; | |
} | |
/** | |
* The base implementation of `_.lt` 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 less than `other`, | |
* else `false`. | |
*/ | |
function baseLt(value, other) { | |
return value < other; | |
} | |
/** | |
* The base implementation of `_.map` without support for iteratee shorthands. | |
* | |
* @private | |
* @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} iteratee The function invoked per iteration. | |
* @returns {Array} Returns the new mapped array. | |
*/ | |
function baseMap(collection, iteratee) { | |