@joint/core 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +376 -0
- package/README.md +49 -0
- package/dist/geometry.js +6486 -0
- package/dist/geometry.min.js +8 -0
- package/dist/joint.d.ts +5536 -0
- package/dist/joint.js +39629 -0
- package/dist/joint.min.js +8 -0
- package/dist/joint.nowrap.js +39626 -0
- package/dist/joint.nowrap.min.js +8 -0
- package/dist/vectorizer.js +9135 -0
- package/dist/vectorizer.min.js +8 -0
- package/dist/version.mjs +3 -0
- package/index.js +3 -0
- package/joint.mjs +27 -0
- package/package.json +192 -0
- package/src/V/annotation.mjs +0 -0
- package/src/V/index.mjs +2642 -0
- package/src/anchors/index.mjs +123 -0
- package/src/config/index.mjs +12 -0
- package/src/connectionPoints/index.mjs +202 -0
- package/src/connectionStrategies/index.mjs +73 -0
- package/src/connectors/curve.mjs +553 -0
- package/src/connectors/index.mjs +6 -0
- package/src/connectors/jumpover.mjs +452 -0
- package/src/connectors/normal.mjs +12 -0
- package/src/connectors/rounded.mjs +17 -0
- package/src/connectors/smooth.mjs +44 -0
- package/src/connectors/straight.mjs +110 -0
- package/src/dia/Cell.mjs +945 -0
- package/src/dia/CellView.mjs +1316 -0
- package/src/dia/Element.mjs +519 -0
- package/src/dia/ElementView.mjs +859 -0
- package/src/dia/Graph.mjs +1112 -0
- package/src/dia/HighlighterView.mjs +319 -0
- package/src/dia/Link.mjs +565 -0
- package/src/dia/LinkView.mjs +2207 -0
- package/src/dia/Paper.mjs +3171 -0
- package/src/dia/PaperLayer.mjs +75 -0
- package/src/dia/ToolView.mjs +69 -0
- package/src/dia/ToolsView.mjs +128 -0
- package/src/dia/attributes/calc.mjs +128 -0
- package/src/dia/attributes/connection.mjs +75 -0
- package/src/dia/attributes/defs.mjs +76 -0
- package/src/dia/attributes/eval.mjs +64 -0
- package/src/dia/attributes/index.mjs +69 -0
- package/src/dia/attributes/legacy.mjs +148 -0
- package/src/dia/attributes/offset.mjs +53 -0
- package/src/dia/attributes/props.mjs +30 -0
- package/src/dia/attributes/shape.mjs +92 -0
- package/src/dia/attributes/text.mjs +180 -0
- package/src/dia/index.mjs +13 -0
- package/src/dia/layers/GridLayer.mjs +176 -0
- package/src/dia/ports.mjs +874 -0
- package/src/elementTools/Control.mjs +153 -0
- package/src/elementTools/HoverConnect.mjs +37 -0
- package/src/elementTools/index.mjs +5 -0
- package/src/env/index.mjs +43 -0
- package/src/g/bezier.mjs +175 -0
- package/src/g/curve.mjs +956 -0
- package/src/g/ellipse.mjs +245 -0
- package/src/g/extend.mjs +64 -0
- package/src/g/geometry.helpers.mjs +58 -0
- package/src/g/index.mjs +17 -0
- package/src/g/intersection.mjs +511 -0
- package/src/g/line.bearing.mjs +30 -0
- package/src/g/line.length.mjs +5 -0
- package/src/g/line.mjs +356 -0
- package/src/g/line.squaredLength.mjs +10 -0
- package/src/g/path.mjs +2260 -0
- package/src/g/point.mjs +375 -0
- package/src/g/points.mjs +247 -0
- package/src/g/polygon.mjs +51 -0
- package/src/g/polyline.mjs +523 -0
- package/src/g/rect.mjs +556 -0
- package/src/g/types.mjs +10 -0
- package/src/highlighters/addClass.mjs +27 -0
- package/src/highlighters/index.mjs +5 -0
- package/src/highlighters/list.mjs +111 -0
- package/src/highlighters/mask.mjs +220 -0
- package/src/highlighters/opacity.mjs +17 -0
- package/src/highlighters/stroke.mjs +100 -0
- package/src/layout/index.mjs +4 -0
- package/src/layout/ports/port.mjs +188 -0
- package/src/layout/ports/portLabel.mjs +224 -0
- package/src/linkAnchors/index.mjs +76 -0
- package/src/linkTools/Anchor.mjs +235 -0
- package/src/linkTools/Arrowhead.mjs +103 -0
- package/src/linkTools/Boundary.mjs +48 -0
- package/src/linkTools/Button.mjs +121 -0
- package/src/linkTools/Connect.mjs +85 -0
- package/src/linkTools/HoverConnect.mjs +161 -0
- package/src/linkTools/Segments.mjs +393 -0
- package/src/linkTools/Vertices.mjs +253 -0
- package/src/linkTools/helpers.mjs +33 -0
- package/src/linkTools/index.mjs +8 -0
- package/src/mvc/Collection.mjs +560 -0
- package/src/mvc/Data.mjs +46 -0
- package/src/mvc/Dom/Dom.mjs +587 -0
- package/src/mvc/Dom/Event.mjs +130 -0
- package/src/mvc/Dom/animations.mjs +122 -0
- package/src/mvc/Dom/events.mjs +69 -0
- package/src/mvc/Dom/index.mjs +13 -0
- package/src/mvc/Dom/methods.mjs +392 -0
- package/src/mvc/Dom/props.mjs +77 -0
- package/src/mvc/Dom/vars.mjs +5 -0
- package/src/mvc/Events.mjs +337 -0
- package/src/mvc/Listener.mjs +33 -0
- package/src/mvc/Model.mjs +239 -0
- package/src/mvc/View.mjs +323 -0
- package/src/mvc/ViewBase.mjs +182 -0
- package/src/mvc/index.mjs +9 -0
- package/src/mvc/mvcUtils.mjs +90 -0
- package/src/polyfills/array.js +4 -0
- package/src/polyfills/base64.js +68 -0
- package/src/polyfills/index.mjs +5 -0
- package/src/polyfills/number.js +3 -0
- package/src/polyfills/string.js +3 -0
- package/src/polyfills/typedArray.js +47 -0
- package/src/routers/index.mjs +6 -0
- package/src/routers/manhattan.mjs +856 -0
- package/src/routers/metro.mjs +91 -0
- package/src/routers/normal.mjs +6 -0
- package/src/routers/oneSide.mjs +60 -0
- package/src/routers/orthogonal.mjs +323 -0
- package/src/routers/rightAngle.mjs +1056 -0
- package/src/shapes/index.mjs +3 -0
- package/src/shapes/standard.mjs +755 -0
- package/src/util/cloneCells.mjs +67 -0
- package/src/util/getRectPoint.mjs +65 -0
- package/src/util/index.mjs +5 -0
- package/src/util/svgTagTemplate.mjs +110 -0
- package/src/util/util.mjs +1754 -0
- package/src/util/utilHelpers.mjs +2402 -0
- package/src/util/wrappers.mjs +56 -0
- package/types/geometry.d.ts +815 -0
- package/types/index.d.ts +53 -0
- package/types/joint.d.ts +4391 -0
- package/types/joint.head.d.ts +12 -0
- package/types/vectorizer.d.ts +327 -0
|
@@ -0,0 +1,2402 @@
|
|
|
1
|
+
// code is inspired by https://github.com/lodash/lodash
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-case-declarations */
|
|
4
|
+
// -- helper constants
|
|
5
|
+
const argsTag = '[object Arguments]';
|
|
6
|
+
const arrayTag = '[object Array]';
|
|
7
|
+
const boolTag = '[object Boolean]';
|
|
8
|
+
const dateTag = '[object Date]';
|
|
9
|
+
const errorTag = '[object Error]';
|
|
10
|
+
const funcTag = '[object Function]';
|
|
11
|
+
const mapTag = '[object Map]';
|
|
12
|
+
const numberTag = '[object Number]';
|
|
13
|
+
const nullTag = '[object Null]';
|
|
14
|
+
const objectTag = '[object Object]';
|
|
15
|
+
const regexpTag = '[object RegExp]';
|
|
16
|
+
const setTag = '[object Set]';
|
|
17
|
+
const stringTag = '[object String]';
|
|
18
|
+
const symbolTag = '[object Symbol]';
|
|
19
|
+
const undefinedTag = '[object Undefined]';
|
|
20
|
+
const weakMapTag = '[object WeakMap]';
|
|
21
|
+
const arrayBufferTag = '[object ArrayBuffer]';
|
|
22
|
+
const dataViewTag = '[object DataView]';
|
|
23
|
+
const float32Tag = '[object Float32Array]';
|
|
24
|
+
const float64Tag = '[object Float64Array]';
|
|
25
|
+
const int8Tag = '[object Int8Array]';
|
|
26
|
+
const int16Tag = '[object Int16Array]';
|
|
27
|
+
const int32Tag = '[object Int32Array]';
|
|
28
|
+
const uint8Tag = '[object Uint8Array]';
|
|
29
|
+
const uint8ClampedTag = '[object Uint8ClampedArray]';
|
|
30
|
+
const uint16Tag = '[object Uint16Array]';
|
|
31
|
+
const uint32Tag = '[object Uint32Array]';
|
|
32
|
+
|
|
33
|
+
const CLONEABLE_TAGS = {
|
|
34
|
+
[argsTag]: true,
|
|
35
|
+
[arrayTag]: true,
|
|
36
|
+
[arrayBufferTag]: true,
|
|
37
|
+
[dataViewTag]: true,
|
|
38
|
+
[boolTag]: true,
|
|
39
|
+
[dateTag]: true,
|
|
40
|
+
[float32Tag]: true,
|
|
41
|
+
[float64Tag]: true,
|
|
42
|
+
[int8Tag]: true,
|
|
43
|
+
[int16Tag]: true,
|
|
44
|
+
[int32Tag]: true,
|
|
45
|
+
[mapTag]: true,
|
|
46
|
+
[numberTag]: true,
|
|
47
|
+
[objectTag]: true,
|
|
48
|
+
[regexpTag]: true,
|
|
49
|
+
[setTag]: true,
|
|
50
|
+
[stringTag]: true,
|
|
51
|
+
[symbolTag]: true,
|
|
52
|
+
[uint8Tag]: true,
|
|
53
|
+
[uint8ClampedTag]: true,
|
|
54
|
+
[uint16Tag]: true,
|
|
55
|
+
[uint32Tag]: true,
|
|
56
|
+
[errorTag]: false,
|
|
57
|
+
[funcTag]: false,
|
|
58
|
+
[weakMapTag]: false,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Used to compose unicode character classes. */
|
|
62
|
+
const rsAstralRange = '\\ud800-\\udfff';
|
|
63
|
+
const rsComboMarksRange = '\\u0300-\\u036f';
|
|
64
|
+
const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
|
|
65
|
+
const rsComboSymbolsRange = '\\u20d0-\\u20ff';
|
|
66
|
+
const rsComboMarksExtendedRange = '\\u1ab0-\\u1aff';
|
|
67
|
+
const rsComboMarksSupplementRange = '\\u1dc0-\\u1dff';
|
|
68
|
+
const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange;
|
|
69
|
+
const rsDingbatRange = '\\u2700-\\u27bf';
|
|
70
|
+
const rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff';
|
|
71
|
+
const rsMathOpRange = '\\xac\\xb1\\xd7\\xf7';
|
|
72
|
+
const rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf';
|
|
73
|
+
const rsPunctuationRange = '\\u2000-\\u206f';
|
|
74
|
+
const 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';
|
|
75
|
+
const rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde';
|
|
76
|
+
const rsVarRange = '\\ufe0e\\ufe0f';
|
|
77
|
+
const rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
|
|
78
|
+
|
|
79
|
+
/** Used to compose unicode capture groups. */
|
|
80
|
+
const rsApos = '[\'\u2019]';
|
|
81
|
+
const rsBreak = `[${rsBreakRange}]`;
|
|
82
|
+
const rsCombo = `[${rsComboRange}]`;
|
|
83
|
+
const rsDigit = '\\d';
|
|
84
|
+
const rsDingbat = `[${rsDingbatRange}]`;
|
|
85
|
+
const rsLower = `[${rsLowerRange}]`;
|
|
86
|
+
const rsMisc = `[^${rsAstralRange}${rsBreakRange + rsDigit + rsDingbatRange + rsLowerRange + rsUpperRange}]`;
|
|
87
|
+
const rsFitz = '\\ud83c[\\udffb-\\udfff]';
|
|
88
|
+
const rsModifier = `(?:${rsCombo}|${rsFitz})`;
|
|
89
|
+
const rsNonAstral = `[^${rsAstralRange}]`;
|
|
90
|
+
const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
|
|
91
|
+
const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
|
|
92
|
+
const rsUpper = `[${rsUpperRange}]`;
|
|
93
|
+
const rsZWJ = '\\u200d';
|
|
94
|
+
|
|
95
|
+
/** Used to compose unicode regexes. */
|
|
96
|
+
const rsMiscLower = `(?:${rsLower}|${rsMisc})`;
|
|
97
|
+
const rsMiscUpper = `(?:${rsUpper}|${rsMisc})`;
|
|
98
|
+
const rsOptContrLower = `(?:${rsApos}(?:d|ll|m|re|s|t|ve))?`;
|
|
99
|
+
const rsOptContrUpper = `(?:${rsApos}(?:D|LL|M|RE|S|T|VE))?`;
|
|
100
|
+
const reOptMod = `${rsModifier}?`;
|
|
101
|
+
const rsOptVar = `[${rsVarRange}]?`;
|
|
102
|
+
const rsOptJoin = `(?:${rsZWJ}(?:${[rsNonAstral, rsRegional, rsSurrPair].join('|')})${rsOptVar + reOptMod})*`;
|
|
103
|
+
const rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])';
|
|
104
|
+
const rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])';
|
|
105
|
+
const rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
|
106
|
+
const rsEmoji = `(?:${[rsDingbat, rsRegional, rsSurrPair].join('|')})${rsSeq}`;
|
|
107
|
+
|
|
108
|
+
const reUnicodeWords = RegExp([
|
|
109
|
+
`${rsUpper}?${rsLower}+${rsOptContrLower}(?=${[rsBreak, rsUpper, '$'].join('|')})`,
|
|
110
|
+
`${rsMiscUpper}+${rsOptContrUpper}(?=${[rsBreak, rsUpper + rsMiscLower, '$'].join('|')})`,
|
|
111
|
+
`${rsUpper}?${rsMiscLower}+${rsOptContrLower}`,
|
|
112
|
+
`${rsUpper}+${rsOptContrUpper}`,
|
|
113
|
+
rsOrdUpper,
|
|
114
|
+
rsOrdLower,
|
|
115
|
+
`${rsDigit}+`,
|
|
116
|
+
rsEmoji
|
|
117
|
+
].join('|'), 'g');
|
|
118
|
+
|
|
119
|
+
const LARGE_ARRAY_SIZE = 200;
|
|
120
|
+
const HASH_UNDEFINED = '__hash_undefined__';
|
|
121
|
+
|
|
122
|
+
// Used to match `toStringTag` values of typed arrays
|
|
123
|
+
const reTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/;
|
|
124
|
+
|
|
125
|
+
// Used to compose unicode capture groups
|
|
126
|
+
const rsAstral = `[${rsAstralRange}]`;
|
|
127
|
+
|
|
128
|
+
// Used to compose unicode regexes
|
|
129
|
+
const rsNonAstralCombo = `${rsNonAstral}${rsCombo}?`;
|
|
130
|
+
const rsSymbol = `(?:${[rsNonAstralCombo, rsCombo, rsRegional, rsSurrPair, rsAstral].join('|')})`;
|
|
131
|
+
|
|
132
|
+
// Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode)
|
|
133
|
+
const reUnicode = RegExp(`${rsFitz}(?=${rsFitz})|${rsSymbol + rsSeq}`, 'g');
|
|
134
|
+
|
|
135
|
+
const reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
136
|
+
const reIsPlainProp = /^\w*$/;
|
|
137
|
+
|
|
138
|
+
const charCodeOfDot = '.'.charCodeAt(0);
|
|
139
|
+
const reEscapeChar = /\\(\\)?/g;
|
|
140
|
+
const rePropName = RegExp(
|
|
141
|
+
// Match anything that isn't a dot or bracket.
|
|
142
|
+
'[^.[\\]]+' + '|' +
|
|
143
|
+
// Or match property names within brackets.
|
|
144
|
+
'\\[(?:' +
|
|
145
|
+
// Match a non-string expression.
|
|
146
|
+
'([^"\'][^[]*)' + '|' +
|
|
147
|
+
// Or match strings (supports escaping characters).
|
|
148
|
+
'(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2' +
|
|
149
|
+
')\\]'+ '|' +
|
|
150
|
+
// Or match "" as the space between consecutive dots or empty brackets.
|
|
151
|
+
'(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))'
|
|
152
|
+
, 'g');
|
|
153
|
+
const reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
154
|
+
|
|
155
|
+
const hasUnicodeWord = RegExp.prototype.test.bind(
|
|
156
|
+
/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const MAX_ARRAY_INDEX = 4294967295 - 1;
|
|
160
|
+
|
|
161
|
+
/** Used to match words composed of alphanumeric characters. */
|
|
162
|
+
// eslint-disable-next-line no-control-regex
|
|
163
|
+
const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
// -- helper functions
|
|
168
|
+
const hasUnicode = (string) => {
|
|
169
|
+
return reUnicode.test(string);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const unicodeToArray = (string) => {
|
|
173
|
+
return string.match(reUnicode) || [];
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const asciiToArray = (string) => {
|
|
177
|
+
return string.split('');
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const stringToArray = (string) => {
|
|
181
|
+
return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const values = (object) => {
|
|
185
|
+
if (object == null) {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return keys(object).map((key) => object[key]);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const keys = (object) => {
|
|
193
|
+
return isArrayLike(object) ? arrayLikeKeys(object) : Object.keys(Object(object));
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const baseKeys = (object) => {
|
|
197
|
+
if (!isPrototype(object)) {
|
|
198
|
+
return Object.keys(object);
|
|
199
|
+
}
|
|
200
|
+
var result = [];
|
|
201
|
+
for (var key in Object(object)) {
|
|
202
|
+
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
|
203
|
+
result.push(key);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return result;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const arrayLikeKeys = (value, inherited) => {
|
|
211
|
+
const isArr = Array.isArray(value);
|
|
212
|
+
const isArg = !isArr && isObjectLike(value) && getTag(value) === argsTag;
|
|
213
|
+
const isType = !isArr && !isArg && isTypedArray(value);
|
|
214
|
+
const skipIndexes = isArr || isArg || isType;
|
|
215
|
+
const length = value.length;
|
|
216
|
+
const result = new Array(skipIndexes ? length : 0);
|
|
217
|
+
let index = skipIndexes ? -1 : length;
|
|
218
|
+
while (++index < length) {
|
|
219
|
+
result[index] = `${index}`;
|
|
220
|
+
}
|
|
221
|
+
for (const key in value) {
|
|
222
|
+
if ((inherited || hasOwnProperty.call(value, key)) &&
|
|
223
|
+
!(skipIndexes && (
|
|
224
|
+
// Safari 9 has enumerable `arguments.length` in strict mode.
|
|
225
|
+
key === 'length' ||
|
|
226
|
+
// Skip index properties.
|
|
227
|
+
isIndex(key, length)
|
|
228
|
+
))
|
|
229
|
+
) {
|
|
230
|
+
result.push(key);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return result;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const assocIndexOf = (array, key) => {
|
|
237
|
+
let { length } = array;
|
|
238
|
+
while (length--) {
|
|
239
|
+
if (eq(array[length][0], key)) {
|
|
240
|
+
return length;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return -1;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const eq = (value, other) => {
|
|
247
|
+
return value === other || (value !== value && other !== other);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const isObjectLike = (value) => {
|
|
251
|
+
return value != null && typeof value == 'object';
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const isIterateeCall = (value, index, object) => {
|
|
255
|
+
if (!isObject(object)) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
const type = typeof index;
|
|
259
|
+
|
|
260
|
+
const isPossibleIteratee = type == 'number' ?
|
|
261
|
+
(isArrayLike(object) && index > -1 && index < object.length) :
|
|
262
|
+
(type == 'string' && index in object);
|
|
263
|
+
|
|
264
|
+
if (isPossibleIteratee) {
|
|
265
|
+
return eq(object[index], value);
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const isSet = (value) => {
|
|
271
|
+
return isObjectLike(value) && getTag(value) == setTag;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const isMap = (value) => {
|
|
275
|
+
return isObjectLike(value) && getTag(value) == mapTag;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
const isPrototype = (value) => {
|
|
279
|
+
const Ctor = value && value.constructor;
|
|
280
|
+
const proto = (typeof Ctor === 'function' && Ctor.prototype) || Object.prototype;
|
|
281
|
+
|
|
282
|
+
return value === proto;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const assignValue = (object, key, value) => {
|
|
286
|
+
const objValue = object[key];
|
|
287
|
+
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
|
288
|
+
(value === undefined && !(key in object))) {
|
|
289
|
+
object[key] = value;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const copyObject = (source, props, object) => {
|
|
294
|
+
let index = -1;
|
|
295
|
+
const length = props.length;
|
|
296
|
+
|
|
297
|
+
while (++index < length) {
|
|
298
|
+
const key = props[index];
|
|
299
|
+
assignValue(object, key, source[key]);
|
|
300
|
+
}
|
|
301
|
+
return object;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
const isArrayLike = (value) => {
|
|
305
|
+
return value != null && typeof value !== 'function' && typeof value.length === 'number' &&
|
|
306
|
+
value.length > -1 && value.length % 1 === 0;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const isSymbol = (value) => {
|
|
310
|
+
return typeof value == 'symbol' ||
|
|
311
|
+
(isObjectLike(value) && getTag(value) === symbolTag);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const initCloneArray = (array) => {
|
|
315
|
+
const length = array.length;
|
|
316
|
+
let result = new array.constructor(length);
|
|
317
|
+
|
|
318
|
+
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
|
319
|
+
result.index = array.index;
|
|
320
|
+
result.input = array.input;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return result;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
const copyArray = (source, array) => {
|
|
327
|
+
let index = -1;
|
|
328
|
+
const length = source.length;
|
|
329
|
+
|
|
330
|
+
array || (array = new Array(length));
|
|
331
|
+
while (++index < length) {
|
|
332
|
+
array[index] = source[index];
|
|
333
|
+
}
|
|
334
|
+
return array;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
const getTag = (value) => {
|
|
338
|
+
if (value == null) {
|
|
339
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return Object.prototype.toString.call(value);
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
const cloneArrayBuffer = (arrayBuffer) => {
|
|
346
|
+
const result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
347
|
+
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
|
348
|
+
return result;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
const cloneTypedArray = (typedArray, isDeep) => {
|
|
352
|
+
const buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
|
|
353
|
+
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const cloneRegExp = (regexp) =>{
|
|
357
|
+
const result = new regexp.constructor(regexp.source, /\w*$/.exec(regexp));
|
|
358
|
+
result.lastIndex = regexp.lastIndex;
|
|
359
|
+
return result;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const initCloneObject = (object) => {
|
|
363
|
+
return (typeof object.constructor == 'function' && !isPrototype(object))
|
|
364
|
+
? Object.create(Object.getPrototypeOf(object))
|
|
365
|
+
: {};
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
const getSymbols = (object) => {
|
|
369
|
+
if (object == null) {
|
|
370
|
+
return [];
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
object = Object(object);
|
|
374
|
+
const symbols = Object.getOwnPropertySymbols(object);
|
|
375
|
+
|
|
376
|
+
return symbols.filter((symbol) => propertyIsEnumerable.call(object, symbol));
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const copySymbols = (source, object) => {
|
|
380
|
+
return copyObject(source, getSymbols(source), object);
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
function cloneDataView(dataView, isDeep) {
|
|
384
|
+
const buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
|
|
385
|
+
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const initCloneByTag = (object, tag, isDeep) => {
|
|
389
|
+
const Constructor = object.constructor;
|
|
390
|
+
switch(tag) {
|
|
391
|
+
case arrayBufferTag:
|
|
392
|
+
return cloneArrayBuffer(object, isDeep);
|
|
393
|
+
case boolTag:
|
|
394
|
+
case dateTag:
|
|
395
|
+
return new Constructor(+object);
|
|
396
|
+
case dataViewTag:
|
|
397
|
+
return cloneDataView(object, isDeep);
|
|
398
|
+
case float32Tag:
|
|
399
|
+
case float64Tag:
|
|
400
|
+
case int8Tag:
|
|
401
|
+
case int16Tag:
|
|
402
|
+
case int32Tag:
|
|
403
|
+
case uint8Tag:
|
|
404
|
+
case uint8ClampedTag:
|
|
405
|
+
case uint16Tag:
|
|
406
|
+
case uint32Tag:
|
|
407
|
+
return cloneTypedArray(object, isDeep);
|
|
408
|
+
case mapTag:
|
|
409
|
+
return new Constructor(object);
|
|
410
|
+
case numberTag:
|
|
411
|
+
case stringTag:
|
|
412
|
+
return new Constructor(object);
|
|
413
|
+
case regexpTag:
|
|
414
|
+
return cloneRegExp(object);
|
|
415
|
+
case setTag:
|
|
416
|
+
return new Constructor;
|
|
417
|
+
case symbolTag:
|
|
418
|
+
return Symbol.prototype.valueOf ? Object(Symbol.prototype.valueOf.call(object)) : {};
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const isTypedArray = (value) => {
|
|
423
|
+
return isObjectLike(value) && reTypedTag.test(getTag(value));
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const getAllKeys = (object) => {
|
|
427
|
+
const result = Object.keys(object);
|
|
428
|
+
if(!Array.isArray(object) && object != null) {
|
|
429
|
+
result.push(...getSymbols(Object(object)));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return result;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
const getSymbolsIn = (object) => {
|
|
436
|
+
const result = [];
|
|
437
|
+
while (object) {
|
|
438
|
+
result.push(...getSymbols(object));
|
|
439
|
+
object = Object.getPrototypeOf(Object(object));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return result;
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
const getAllKeysIn = (object) => {
|
|
446
|
+
const result = [];
|
|
447
|
+
|
|
448
|
+
for (const key in object) {
|
|
449
|
+
result.push(key);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if (!Array.isArray(object)) {
|
|
453
|
+
result.push(...getSymbolsIn(object));
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
return result;
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const getMapData = ({ __data__ }, key) => {
|
|
460
|
+
const data = __data__;
|
|
461
|
+
return isKeyable(key)
|
|
462
|
+
? data[typeof key === 'string' ? 'string' : 'hash']
|
|
463
|
+
: data.map;
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
const equalObjects = (object, other, equalFunc, stack) => {
|
|
467
|
+
const objProps = getAllKeys(object);
|
|
468
|
+
const objLength = objProps.length;
|
|
469
|
+
const othProps = getAllKeys(other);
|
|
470
|
+
const othLength = othProps.length;
|
|
471
|
+
|
|
472
|
+
if (objLength != othLength) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
let key;
|
|
476
|
+
let index = objLength;
|
|
477
|
+
while (index--) {
|
|
478
|
+
key = objProps[index];
|
|
479
|
+
if (!(hasOwnProperty.call(other, key))) {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const objStacked = stack.get(object);
|
|
485
|
+
const othStacked = stack.get(other);
|
|
486
|
+
if (objStacked && othStacked) {
|
|
487
|
+
return objStacked == other && othStacked == object;
|
|
488
|
+
}
|
|
489
|
+
let result = true;
|
|
490
|
+
stack.set(object, other);
|
|
491
|
+
stack.set(other, object);
|
|
492
|
+
|
|
493
|
+
let compared;
|
|
494
|
+
let skipCtor;
|
|
495
|
+
|
|
496
|
+
while (++index < objLength) {
|
|
497
|
+
key = objProps[index];
|
|
498
|
+
const objValue = object[key];
|
|
499
|
+
const othValue = other[key];
|
|
500
|
+
|
|
501
|
+
if (!(compared === undefined
|
|
502
|
+
? (objValue === othValue || equalFunc(objValue, othValue, stack))
|
|
503
|
+
: compared
|
|
504
|
+
)) {
|
|
505
|
+
result = false;
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
skipCtor || (skipCtor = key == 'constructor');
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (result && !skipCtor) {
|
|
512
|
+
const objCtor = object.constructor;
|
|
513
|
+
const othCtor = other.constructor;
|
|
514
|
+
|
|
515
|
+
if (objCtor != othCtor &&
|
|
516
|
+
('constructor' in object && 'constructor' in other) &&
|
|
517
|
+
!(typeof objCtor === 'function' && objCtor instanceof objCtor &&
|
|
518
|
+
typeof othCtor === 'function' && othCtor instanceof othCtor)) {
|
|
519
|
+
result = false;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
stack['delete'](object);
|
|
523
|
+
stack['delete'](other);
|
|
524
|
+
return result;
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
const baseIsEqual = (value, other, stack) => {
|
|
528
|
+
if (value === other) {
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
|
|
532
|
+
return value !== value && other !== other;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return baseIsEqualDeep(value, other, baseIsEqual, stack);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
const baseIsEqualDeep = (object, other, equalFunc, stack) => {
|
|
539
|
+
let objIsArr = Array.isArray(object);
|
|
540
|
+
const othIsArr = Array.isArray(other);
|
|
541
|
+
let objTag = objIsArr ? arrayTag : getTag(object);
|
|
542
|
+
let othTag = othIsArr ? arrayTag : getTag(other);
|
|
543
|
+
|
|
544
|
+
objTag = objTag == argsTag ? objectTag : objTag;
|
|
545
|
+
othTag = othTag == argsTag ? objectTag : othTag;
|
|
546
|
+
|
|
547
|
+
let objIsObj = objTag == objectTag;
|
|
548
|
+
const othIsObj = othTag == objectTag;
|
|
549
|
+
const isSameTag = objTag == othTag;
|
|
550
|
+
|
|
551
|
+
if (isSameTag && !objIsObj) {
|
|
552
|
+
stack || (stack = new Stack);
|
|
553
|
+
return (objIsArr || isTypedArray(object))
|
|
554
|
+
? equalArrays(object, other, false, equalFunc, stack)
|
|
555
|
+
: equalByTag(object, other, objTag, equalFunc, stack);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
const objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__');
|
|
559
|
+
const othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|
560
|
+
|
|
561
|
+
if (objIsWrapped || othIsWrapped) {
|
|
562
|
+
const objUnwrapped = objIsWrapped ? object.value() : object;
|
|
563
|
+
const othUnwrapped = othIsWrapped ? other.value() : other;
|
|
564
|
+
|
|
565
|
+
stack || (stack = new Stack);
|
|
566
|
+
return equalFunc(objUnwrapped, othUnwrapped, stack);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (!isSameTag) {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
stack || (stack = new Stack);
|
|
574
|
+
return equalObjects(object, other, equalFunc, stack);
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
const equalArrays = (array, other, compareUnordered, equalFunc, stack) => {
|
|
578
|
+
const isPartial = false;
|
|
579
|
+
const arrLength = array.length;
|
|
580
|
+
const othLength = other.length;
|
|
581
|
+
|
|
582
|
+
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
// Assume cyclic values are equal.
|
|
586
|
+
const arrStacked = stack.get(array);
|
|
587
|
+
const othStacked = stack.get(other);
|
|
588
|
+
if (arrStacked && othStacked) {
|
|
589
|
+
return arrStacked == other && othStacked == array;
|
|
590
|
+
}
|
|
591
|
+
let index = -1;
|
|
592
|
+
let result = true;
|
|
593
|
+
const seen = compareUnordered ? new SetCache : undefined;
|
|
594
|
+
|
|
595
|
+
stack.set(array, other);
|
|
596
|
+
stack.set(other, array);
|
|
597
|
+
|
|
598
|
+
while (++index < arrLength) {
|
|
599
|
+
let compared;
|
|
600
|
+
const arrValue = array[index];
|
|
601
|
+
const othValue = other[index];
|
|
602
|
+
|
|
603
|
+
if (compared !== undefined) {
|
|
604
|
+
if (compared) {
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
607
|
+
result = false;
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
if (seen) {
|
|
612
|
+
if (!some(other, (othValue, othIndex) => {
|
|
613
|
+
if (!cacheHas(seen, othIndex) &&
|
|
614
|
+
(arrValue === othValue || equalFunc(arrValue, othValue, stack))) {
|
|
615
|
+
return seen.push(othIndex);
|
|
616
|
+
}
|
|
617
|
+
})) {
|
|
618
|
+
result = false;
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
} else if (!(
|
|
622
|
+
arrValue === othValue ||
|
|
623
|
+
equalFunc(arrValue, othValue, stack)
|
|
624
|
+
)) {
|
|
625
|
+
result = false;
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
stack['delete'](array);
|
|
630
|
+
stack['delete'](other);
|
|
631
|
+
return result;
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
const some = (array, predicate) => {
|
|
635
|
+
let index = -1;
|
|
636
|
+
const length = array == null ? 0 : array.length;
|
|
637
|
+
|
|
638
|
+
while (++index < length) {
|
|
639
|
+
if (predicate(array[index], index, array)) {
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return false;
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
const cacheHas = (cache, key) => {
|
|
647
|
+
return cache.has(key);
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
const compareArrayBufferTag = (object, other, equalFunc, stack) => {
|
|
651
|
+
if ((object.byteLength != other.byteLength) ||
|
|
652
|
+
!equalFunc(new Uint8Array(object), new Uint8Array(other), stack)) {
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
return true;
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
const equalByTag = (object, other, tag, equalFunc, stack) => {
|
|
659
|
+
|
|
660
|
+
switch (tag) {
|
|
661
|
+
case dataViewTag:
|
|
662
|
+
if ((object.byteLength != other.byteLength) ||
|
|
663
|
+
(object.byteOffset != other.byteOffset)) {
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
object = object.buffer;
|
|
667
|
+
other = other.buffer;
|
|
668
|
+
return compareArrayBufferTag(object, other, equalFunc, stack);
|
|
669
|
+
case arrayBufferTag:
|
|
670
|
+
return compareArrayBufferTag(object, other, equalFunc, stack);
|
|
671
|
+
case boolTag:
|
|
672
|
+
case dateTag:
|
|
673
|
+
case numberTag:
|
|
674
|
+
return eq(+object, +other);
|
|
675
|
+
case errorTag:
|
|
676
|
+
return object.name == other.name && object.message == other.message;
|
|
677
|
+
case regexpTag:
|
|
678
|
+
case stringTag:
|
|
679
|
+
return object == `${other}`;
|
|
680
|
+
case mapTag:
|
|
681
|
+
let convert = mapToArray;
|
|
682
|
+
// Intentional fallthrough
|
|
683
|
+
// eslint-disable-next-line no-fallthrough
|
|
684
|
+
case setTag:
|
|
685
|
+
convert || (convert = setToArray);
|
|
686
|
+
|
|
687
|
+
if (object.size != other.size) {
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
// Assume cyclic values are equal.
|
|
691
|
+
const stacked = stack.get(object);
|
|
692
|
+
if (stacked) {
|
|
693
|
+
return stacked == other;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// Recursively compare objects (susceptible to call stack limits).
|
|
697
|
+
stack.set(object, other);
|
|
698
|
+
const result = equalArrays(convert(object), convert(other), true, equalFunc, stack);
|
|
699
|
+
stack['delete'](object);
|
|
700
|
+
return result;
|
|
701
|
+
case symbolTag:
|
|
702
|
+
return Symbol.prototype.valueOf.call(object) == Symbol.prototype.valueOf.call(other);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
return false;
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
const mapToArray = (map) => {
|
|
709
|
+
let index = -1;
|
|
710
|
+
let result = Array(map.size);
|
|
711
|
+
|
|
712
|
+
map.forEach((value, key) => {
|
|
713
|
+
result[++index] = [key, value];
|
|
714
|
+
});
|
|
715
|
+
return result;
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
const setToArray = (set) => {
|
|
719
|
+
let index = -1;
|
|
720
|
+
const result = new Array(set.size);
|
|
721
|
+
|
|
722
|
+
set.forEach((value) => {
|
|
723
|
+
result[++index] = value;
|
|
724
|
+
});
|
|
725
|
+
return result;
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
const isKey = (value, object) => {
|
|
729
|
+
if (Array.isArray(value)) {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
const type = typeof value;
|
|
733
|
+
if (type === 'number' || type === 'boolean' || value == null || isSymbol(value)) {
|
|
734
|
+
return true;
|
|
735
|
+
}
|
|
736
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
|
737
|
+
(object != null && value in Object(object));
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
const stringToPath = (string) => {
|
|
741
|
+
const result = [];
|
|
742
|
+
if (string.charCodeAt(0) === charCodeOfDot) {
|
|
743
|
+
result.push('');
|
|
744
|
+
}
|
|
745
|
+
string.replace(rePropName, (match, expression, quote, subString) => {
|
|
746
|
+
let key = match;
|
|
747
|
+
if (quote) {
|
|
748
|
+
key = subString.replace(reEscapeChar, '$1');
|
|
749
|
+
}
|
|
750
|
+
else if (expression) {
|
|
751
|
+
key = expression.trim();
|
|
752
|
+
}
|
|
753
|
+
result.push(key);
|
|
754
|
+
});
|
|
755
|
+
return result;
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
const castPath = (path, object) => {
|
|
759
|
+
if (Array.isArray(path)) {
|
|
760
|
+
return path;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
return isKey(path, object) ? [path] : stringToPath(`${path}`);
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
const get = (object, path) => {
|
|
767
|
+
path = castPath(path, object);
|
|
768
|
+
|
|
769
|
+
let index = 0;
|
|
770
|
+
const length = path.length;
|
|
771
|
+
|
|
772
|
+
while (object != null && index < length) {
|
|
773
|
+
object = object[toKey(path[index])];
|
|
774
|
+
index++;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
return (index && index == length) ? object : undefined;
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
function compareAscending(value, other) {
|
|
781
|
+
if (value !== other) {
|
|
782
|
+
const valIsDefined = value !== undefined;
|
|
783
|
+
const valIsNull = value === null;
|
|
784
|
+
const valIsReflexive = value === value;
|
|
785
|
+
const valIsSymbol = isSymbol(value);
|
|
786
|
+
|
|
787
|
+
const othIsDefined = other !== undefined;
|
|
788
|
+
const othIsNull = other === null;
|
|
789
|
+
const othIsReflexive = other === other;
|
|
790
|
+
const othIsSymbol = isSymbol(other);
|
|
791
|
+
|
|
792
|
+
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
|
|
793
|
+
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
|
|
794
|
+
(valIsNull && othIsDefined && othIsReflexive) ||
|
|
795
|
+
(!valIsDefined && othIsReflexive) ||
|
|
796
|
+
!valIsReflexive) {
|
|
797
|
+
return 1;
|
|
798
|
+
}
|
|
799
|
+
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
|
|
800
|
+
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
|
|
801
|
+
(othIsNull && valIsDefined && valIsReflexive) ||
|
|
802
|
+
(!othIsDefined && valIsReflexive) ||
|
|
803
|
+
!othIsReflexive) {
|
|
804
|
+
return -1;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return 0;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function compareMultiple(object, other, orders) {
|
|
811
|
+
let index = -1;
|
|
812
|
+
const objCriteria = object.criteria;
|
|
813
|
+
const othCriteria = other.criteria;
|
|
814
|
+
const length = objCriteria.length;
|
|
815
|
+
const ordersLength = orders.length;
|
|
816
|
+
|
|
817
|
+
while (++index < length) {
|
|
818
|
+
const order = index < ordersLength ? orders[index] : null;
|
|
819
|
+
const cmpFn = (order && typeof order === 'function') ? order : compareAscending;
|
|
820
|
+
const result = cmpFn(objCriteria[index], othCriteria[index]);
|
|
821
|
+
if (result) {
|
|
822
|
+
if (order && typeof order !== 'function') {
|
|
823
|
+
return result * (order == 'desc' ? -1 : 1);
|
|
824
|
+
}
|
|
825
|
+
return result;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
return object.index - other.index;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
const diff = (array, values) => {
|
|
833
|
+
let includes = (array, value) => {
|
|
834
|
+
const length = array == null ? 0 : array.length;
|
|
835
|
+
return !!length && array.indexOf(value) > -1;
|
|
836
|
+
};
|
|
837
|
+
let isCommon = true;
|
|
838
|
+
const result = [];
|
|
839
|
+
const valuesLength = values.length;
|
|
840
|
+
|
|
841
|
+
if (!array.length) {
|
|
842
|
+
return result;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
if (values.length >= LARGE_ARRAY_SIZE) {
|
|
846
|
+
includes = (cache, key) => cache.has(key);
|
|
847
|
+
isCommon = false;
|
|
848
|
+
values = new SetCache(values);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
outer:
|
|
852
|
+
for (let key in array) {
|
|
853
|
+
let value = array[key];
|
|
854
|
+
const computed = value;
|
|
855
|
+
|
|
856
|
+
value = (value !== 0) ? value : 0;
|
|
857
|
+
if (isCommon && computed === computed) {
|
|
858
|
+
let valuesIndex = valuesLength;
|
|
859
|
+
while (valuesIndex--) {
|
|
860
|
+
if (values[valuesIndex] === computed) {
|
|
861
|
+
continue outer;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
result.push(value);
|
|
865
|
+
}
|
|
866
|
+
else if (!includes(values, computed)) {
|
|
867
|
+
result.push(value);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
return result;
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
const intersect = (arrays) => {
|
|
875
|
+
const includes = (array, value) => {
|
|
876
|
+
const length = array == null ? 0 : array.length;
|
|
877
|
+
return !!length && array.indexOf(value) > -1;
|
|
878
|
+
};
|
|
879
|
+
const cacheHas = (cache, key) => cache.has(key);
|
|
880
|
+
const length = arrays[0].length;
|
|
881
|
+
const othLength = arrays.length;
|
|
882
|
+
const caches = new Array(othLength);
|
|
883
|
+
const result = [];
|
|
884
|
+
|
|
885
|
+
let array;
|
|
886
|
+
let maxLength = Infinity;
|
|
887
|
+
let othIndex = othLength;
|
|
888
|
+
|
|
889
|
+
while (othIndex--) {
|
|
890
|
+
array = arrays[othIndex];
|
|
891
|
+
|
|
892
|
+
maxLength = Math.min(array.length, maxLength);
|
|
893
|
+
caches[othIndex] = length >= 120 && array.length >= 120
|
|
894
|
+
? new SetCache(othIndex && array)
|
|
895
|
+
: undefined;
|
|
896
|
+
}
|
|
897
|
+
array = arrays[0];
|
|
898
|
+
|
|
899
|
+
let index = -1;
|
|
900
|
+
const seen = caches[0];
|
|
901
|
+
|
|
902
|
+
outer:
|
|
903
|
+
while (++index < length && result.length < maxLength) {
|
|
904
|
+
let value = array[index];
|
|
905
|
+
const computed = value;
|
|
906
|
+
|
|
907
|
+
value = (value !== 0) ? value : 0;
|
|
908
|
+
if (!(seen
|
|
909
|
+
? cacheHas(seen, computed)
|
|
910
|
+
: includes(result, computed)
|
|
911
|
+
)) {
|
|
912
|
+
othIndex = othLength;
|
|
913
|
+
while (--othIndex) {
|
|
914
|
+
const cache = caches[othIndex];
|
|
915
|
+
if (!(cache
|
|
916
|
+
? cacheHas(cache, computed)
|
|
917
|
+
: includes(arrays[othIndex], computed))
|
|
918
|
+
) {
|
|
919
|
+
continue outer;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
if (seen) {
|
|
923
|
+
seen.push(computed);
|
|
924
|
+
}
|
|
925
|
+
result.push(value);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
return result;
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
const toKey = (value) => {
|
|
932
|
+
if (typeof value === 'string' || isSymbol(value)) {
|
|
933
|
+
return value;
|
|
934
|
+
}
|
|
935
|
+
const result = `${value}`;
|
|
936
|
+
return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
const baseClone = (value, isDeep = false, isFlat = false, isFull = true, customizer, key, object, stack) => {
|
|
940
|
+
let result;
|
|
941
|
+
|
|
942
|
+
if (customizer) {
|
|
943
|
+
result = object ? customizer(value, key, object, stack) : customizer(value);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
if (result !== undefined) {
|
|
947
|
+
return result;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
if (!isObject(value)) {
|
|
951
|
+
return value;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
const isArr = Array.isArray(value);
|
|
955
|
+
const tag = getTag(value);
|
|
956
|
+
|
|
957
|
+
if (isArr) {
|
|
958
|
+
result = initCloneArray(value);
|
|
959
|
+
|
|
960
|
+
if (!isDeep) {
|
|
961
|
+
return copyArray(value, result);
|
|
962
|
+
}
|
|
963
|
+
} else {
|
|
964
|
+
const isFunc = typeof value === 'function';
|
|
965
|
+
|
|
966
|
+
if (tag === objectTag || tag === argsTag || (isFunc && !object)) {
|
|
967
|
+
result = (isFlat || isFunc) ? {} : initCloneObject(value);
|
|
968
|
+
if (!isDeep) {
|
|
969
|
+
return isFlat ?
|
|
970
|
+
copySymbolsIn(value, copyObject(value, Object.keys(value), result)) :
|
|
971
|
+
copySymbols(value, Object.assign(result, value));
|
|
972
|
+
}
|
|
973
|
+
} else {
|
|
974
|
+
if (isFunc || !CLONEABLE_TAGS[tag]) {
|
|
975
|
+
return object ? value : {};
|
|
976
|
+
}
|
|
977
|
+
result = initCloneByTag(value, tag, isDeep);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
stack || (stack = new Stack);
|
|
982
|
+
const stacked = stack.get(value);
|
|
983
|
+
|
|
984
|
+
if (stacked) {
|
|
985
|
+
return stacked;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
stack.set(value, result);
|
|
989
|
+
|
|
990
|
+
if (isMap(value)) {
|
|
991
|
+
value.forEach((subValue, key) => {
|
|
992
|
+
result.set(key, baseClone(subValue, isDeep, isFlat, isFull, customizer, key, value, stack));
|
|
993
|
+
});
|
|
994
|
+
|
|
995
|
+
return result;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
if (isSet(value)) {
|
|
999
|
+
value.forEach(subValue => {
|
|
1000
|
+
result.add(baseClone(subValue, isDeep, isFlat, isFull, customizer, subValue, value, stack));
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
return result;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
if(isTypedArray(value)) {
|
|
1007
|
+
return result;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const keysFunc = isFull
|
|
1011
|
+
? (isFlat ? getAllKeysIn : getAllKeys)
|
|
1012
|
+
: (isFlat ? keysIn : keys);
|
|
1013
|
+
|
|
1014
|
+
const props = isArr ? undefined : keysFunc(value);
|
|
1015
|
+
|
|
1016
|
+
(props || value).forEach((subValue, key) => {
|
|
1017
|
+
if (props) {
|
|
1018
|
+
key = subValue;
|
|
1019
|
+
subValue = value[key];
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
assignValue(result, key, baseClone(subValue, isDeep, isFlat, isFull, customizer, key, value, stack));
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
return result;
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
const copySymbolsIn = (source, object) => {
|
|
1029
|
+
return copyObject(source, getSymbolsIn(source), object);
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
const parent = (object, path) => {
|
|
1033
|
+
return path.length < 2 ? object : get(object, path.slice(0, -1));
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
const set = (object, path, value) => {
|
|
1037
|
+
if (!isObject(object)) {
|
|
1038
|
+
return object;
|
|
1039
|
+
}
|
|
1040
|
+
path = castPath(path, object);
|
|
1041
|
+
|
|
1042
|
+
const length = path.length;
|
|
1043
|
+
const lastIndex = length - 1;
|
|
1044
|
+
|
|
1045
|
+
let index = -1;
|
|
1046
|
+
let nested = object;
|
|
1047
|
+
|
|
1048
|
+
while (nested != null && ++index < length) {
|
|
1049
|
+
const key = toKey(path[index]);
|
|
1050
|
+
let newValue = value;
|
|
1051
|
+
|
|
1052
|
+
if (index != lastIndex) {
|
|
1053
|
+
const objValue = nested[key];
|
|
1054
|
+
newValue = undefined;
|
|
1055
|
+
if (newValue === undefined) {
|
|
1056
|
+
newValue = isObject(objValue)
|
|
1057
|
+
? objValue
|
|
1058
|
+
: (isIndex(path[index + 1]) ? [] : {});
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
assignValue(nested, key, newValue);
|
|
1062
|
+
nested = nested[key];
|
|
1063
|
+
}
|
|
1064
|
+
return object;
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
const isIndex = (value, length) => {
|
|
1068
|
+
const type = typeof value;
|
|
1069
|
+
length = length == null ? Number.MAX_SAFE_INTEGER : length;
|
|
1070
|
+
|
|
1071
|
+
return !!length &&
|
|
1072
|
+
(type === 'number' ||
|
|
1073
|
+
(type !== 'symbol' && reIsUint.test(value))) &&
|
|
1074
|
+
(value > -1 && value % 1 == 0 && value < length);
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
const unset = (object, path) => {
|
|
1078
|
+
path = castPath(path, object);
|
|
1079
|
+
object = parent(object, path);
|
|
1080
|
+
const lastSegment = path[path.length - 1];
|
|
1081
|
+
return object == null || delete object[toKey(lastSegment)];
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
const isKeyable = (value) => {
|
|
1085
|
+
const type = typeof value;
|
|
1086
|
+
return (type === 'string' || type === 'number' || type === 'symbol' || type === 'boolean')
|
|
1087
|
+
? (value !== '__proto__')
|
|
1088
|
+
: (value === null);
|
|
1089
|
+
};
|
|
1090
|
+
|
|
1091
|
+
const keysIn = (object) => {
|
|
1092
|
+
const result = [];
|
|
1093
|
+
for (const key in object) {
|
|
1094
|
+
result.push(key);
|
|
1095
|
+
}
|
|
1096
|
+
return result;
|
|
1097
|
+
};
|
|
1098
|
+
|
|
1099
|
+
const toPlainObject = (value) => {
|
|
1100
|
+
value = Object(value);
|
|
1101
|
+
const result = {};
|
|
1102
|
+
for (const key in value) {
|
|
1103
|
+
result[key] = value[key];
|
|
1104
|
+
}
|
|
1105
|
+
return result;
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
const safeGet = (object, key) => {
|
|
1109
|
+
if (key === 'constructor' && typeof object[key] === 'function') {
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
if (key == '__proto__') {
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
return object[key];
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
function createAssigner(assigner, isMerge = false) {
|
|
1121
|
+
return (object, ...sources) => {
|
|
1122
|
+
let index = -1;
|
|
1123
|
+
let length = sources.length;
|
|
1124
|
+
let customizer = length > 1 ? sources[length - 1] : undefined;
|
|
1125
|
+
const guard = length > 2 ? sources[2] : undefined;
|
|
1126
|
+
|
|
1127
|
+
customizer = (assigner.length > 3 && typeof customizer === 'function')
|
|
1128
|
+
? (length--, customizer)
|
|
1129
|
+
: isMerge ? (a, b) => {
|
|
1130
|
+
if (Array.isArray(a) && !Array.isArray(b)) {
|
|
1131
|
+
return b;
|
|
1132
|
+
}
|
|
1133
|
+
} : undefined;
|
|
1134
|
+
|
|
1135
|
+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|
1136
|
+
customizer = length < 3 ? undefined : customizer;
|
|
1137
|
+
length = 1;
|
|
1138
|
+
}
|
|
1139
|
+
object = Object(object);
|
|
1140
|
+
while (++index < length) {
|
|
1141
|
+
const source = sources[index];
|
|
1142
|
+
if (source) {
|
|
1143
|
+
assigner(object, source, index, customizer);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return object;
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
const baseMerge = (object, source, srcIndex, customizer, stack) => {
|
|
1151
|
+
if (object === source) {
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
forIn(source, (srcValue, key) => {
|
|
1156
|
+
if (isObject(srcValue)) {
|
|
1157
|
+
stack || (stack = new Stack);
|
|
1158
|
+
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
|
1159
|
+
} else {
|
|
1160
|
+
let newValue = customizer
|
|
1161
|
+
? customizer(object[key], srcValue, `${key}`, object, source, stack)
|
|
1162
|
+
: undefined;
|
|
1163
|
+
|
|
1164
|
+
if (newValue === undefined) {
|
|
1165
|
+
newValue = srcValue;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
assignMergeValue(object, key, newValue);
|
|
1169
|
+
}
|
|
1170
|
+
}, keysIn);
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
const baseMergeDeep = (object, source, key, srcIndex, mergeFunc, customizer, stack) => {
|
|
1174
|
+
const objValue = safeGet(object, key);
|
|
1175
|
+
const srcValue = safeGet(source, key);
|
|
1176
|
+
const stacked = stack.get(srcValue);
|
|
1177
|
+
|
|
1178
|
+
if (stacked) {
|
|
1179
|
+
assignMergeValue(object, key, stacked);
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
let newValue = customizer
|
|
1184
|
+
? customizer(objValue, srcValue, `${key}`, object, source, stack)
|
|
1185
|
+
: undefined;
|
|
1186
|
+
|
|
1187
|
+
let isCommon = newValue === undefined;
|
|
1188
|
+
|
|
1189
|
+
if (isCommon) {
|
|
1190
|
+
const isArr = Array.isArray(srcValue);
|
|
1191
|
+
const isTyped = !isArr && isTypedArray(srcValue);
|
|
1192
|
+
|
|
1193
|
+
newValue = srcValue;
|
|
1194
|
+
if (isArr || isTyped) {
|
|
1195
|
+
if (Array.isArray(objValue)) {
|
|
1196
|
+
newValue = objValue;
|
|
1197
|
+
}
|
|
1198
|
+
else if (isObjectLike(objValue) && isArrayLike(objValue)) {
|
|
1199
|
+
newValue = copyArray(objValue);
|
|
1200
|
+
}
|
|
1201
|
+
else if (isTyped) {
|
|
1202
|
+
isCommon = false;
|
|
1203
|
+
newValue = cloneTypedArray(srcValue, true);
|
|
1204
|
+
}
|
|
1205
|
+
else {
|
|
1206
|
+
newValue = [];
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
|
1210
|
+
newValue = objValue;
|
|
1211
|
+
if (isArguments(objValue)) {
|
|
1212
|
+
newValue = toPlainObject(objValue);
|
|
1213
|
+
}
|
|
1214
|
+
else if (typeof objValue === 'function' || !isObject(objValue)) {
|
|
1215
|
+
newValue = initCloneObject(srcValue);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
else {
|
|
1219
|
+
isCommon = false;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
if (isCommon) {
|
|
1223
|
+
// Recursively merge objects and arrays (susceptible to call stack limits).
|
|
1224
|
+
stack.set(srcValue, newValue);
|
|
1225
|
+
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
|
1226
|
+
stack['delete'](srcValue);
|
|
1227
|
+
}
|
|
1228
|
+
assignMergeValue(object, key, newValue);
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1231
|
+
const assignMergeValue = (object, key, value) => {
|
|
1232
|
+
if ((value !== undefined && !eq(object[key], value)) ||
|
|
1233
|
+
(value === undefined && !(key in object))) {
|
|
1234
|
+
assignValue(object, key, value);
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
function baseFor(object, iteratee, keysFunc) {
|
|
1239
|
+
const iterable = Object(object);
|
|
1240
|
+
const props = keysFunc(object);
|
|
1241
|
+
let { length } = props;
|
|
1242
|
+
let index = -1;
|
|
1243
|
+
|
|
1244
|
+
while (length--) {
|
|
1245
|
+
const key = props[++index];
|
|
1246
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
1247
|
+
break;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
return object;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
const baseForOwn = (object, iteratee) => {
|
|
1254
|
+
return object && baseFor(object, iteratee, keys);
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
const baseEach = (collection, iteratee) => {
|
|
1258
|
+
if (collection == null) {
|
|
1259
|
+
return collection;
|
|
1260
|
+
}
|
|
1261
|
+
if (!isArrayLike(collection)) {
|
|
1262
|
+
return baseForOwn(collection, iteratee);
|
|
1263
|
+
}
|
|
1264
|
+
const length = collection.length;
|
|
1265
|
+
const iterable = Object(collection);
|
|
1266
|
+
let index = -1;
|
|
1267
|
+
|
|
1268
|
+
while (++index < length) {
|
|
1269
|
+
if (iteratee(iterable[index], index, iterable) === false) {
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
return collection;
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
function last(array) {
|
|
1277
|
+
const length = array == null ? 0 : array.length;
|
|
1278
|
+
return length ? array[length - 1] : undefined;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
const createSet = (Set && (1 / setToArray(new Set([undefined,-0]))[1]) == 1 / 0)
|
|
1282
|
+
? (values) => new Set(values)
|
|
1283
|
+
: () => {};
|
|
1284
|
+
|
|
1285
|
+
function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
|
|
1286
|
+
if (isObject(objValue) && isObject(srcValue)) {
|
|
1287
|
+
// Recursively merge objects and arrays (susceptible to call stack limits).
|
|
1288
|
+
stack.set(srcValue, objValue);
|
|
1289
|
+
baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
|
|
1290
|
+
stack['delete'](srcValue);
|
|
1291
|
+
}
|
|
1292
|
+
return objValue;
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
function baseOrderBy(collection, iteratees, orders) {
|
|
1296
|
+
if (iteratees.length) {
|
|
1297
|
+
iteratees = iteratees.map((iteratee) => {
|
|
1298
|
+
if (Array.isArray(iteratee)) {
|
|
1299
|
+
return (value) => get(value, iteratee.length === 1 ? iteratee[0] : iteratee);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
return iteratee;
|
|
1303
|
+
});
|
|
1304
|
+
} else {
|
|
1305
|
+
iteratees = [(value) => value];
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
let criteriaIndex = -1;
|
|
1309
|
+
let eachIndex = -1;
|
|
1310
|
+
|
|
1311
|
+
const result = isArrayLike(collection) ? new Array(collection.length) : [];
|
|
1312
|
+
|
|
1313
|
+
baseEach(collection, (value) => {
|
|
1314
|
+
const criteria = iteratees.map((iteratee) => iteratee(value));
|
|
1315
|
+
|
|
1316
|
+
result[++eachIndex] = {
|
|
1317
|
+
criteria,
|
|
1318
|
+
index: ++criteriaIndex,
|
|
1319
|
+
value
|
|
1320
|
+
};
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
return baseSortBy(result, (object, other) => compareMultiple(object, other, orders));
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
function baseSortBy(array, comparer) {
|
|
1327
|
+
let { length } = array;
|
|
1328
|
+
|
|
1329
|
+
array.sort(comparer);
|
|
1330
|
+
while (length--) {
|
|
1331
|
+
array[length] = array[length].value;
|
|
1332
|
+
}
|
|
1333
|
+
return array;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
function isStrictComparable(value) {
|
|
1337
|
+
return value === value && !isObject(value);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
function matchesStrictComparable(key, srcValue) {
|
|
1341
|
+
return (object) => {
|
|
1342
|
+
if (object == null) {
|
|
1343
|
+
return false;
|
|
1344
|
+
}
|
|
1345
|
+
return object[key] === srcValue &&
|
|
1346
|
+
(srcValue !== undefined || (key in Object(object)));
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
function hasIn(object, path) {
|
|
1351
|
+
return object != null && hasPath(object, path, baseHasIn);
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
function baseMatchesProperty(path, srcValue) {
|
|
1355
|
+
if (isKey(path) && isStrictComparable(srcValue)) {
|
|
1356
|
+
return matchesStrictComparable(toKey(path), srcValue);
|
|
1357
|
+
}
|
|
1358
|
+
return (object) => {
|
|
1359
|
+
const objValue = get(object, path);
|
|
1360
|
+
return (objValue === undefined && objValue === srcValue)
|
|
1361
|
+
? hasIn(object, path)
|
|
1362
|
+
: baseIsEqual(srcValue, objValue);
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function baseMatches(source) {
|
|
1367
|
+
const matchData = getMatchData(source);
|
|
1368
|
+
if (matchData.length === 1 && matchData[0][2]) {
|
|
1369
|
+
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
|
1370
|
+
}
|
|
1371
|
+
return (object) => object === source || baseIsMatch(object, source, matchData);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
function getMatchData(object) {
|
|
1375
|
+
const result = keys(object);
|
|
1376
|
+
let length = result.length;
|
|
1377
|
+
|
|
1378
|
+
while (length--) {
|
|
1379
|
+
const key = result[length];
|
|
1380
|
+
const value = object[key];
|
|
1381
|
+
result[length] = [key, value, isStrictComparable(value)];
|
|
1382
|
+
}
|
|
1383
|
+
return result;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
function baseIsMatch(object, source, matchData, customizer) {
|
|
1387
|
+
let index = matchData.length;
|
|
1388
|
+
const length = index;
|
|
1389
|
+
const noCustomizer = !customizer;
|
|
1390
|
+
|
|
1391
|
+
if (object == null) {
|
|
1392
|
+
return !length;
|
|
1393
|
+
}
|
|
1394
|
+
let data;
|
|
1395
|
+
let result;
|
|
1396
|
+
object = Object(object);
|
|
1397
|
+
while (index--) {
|
|
1398
|
+
data = matchData[index];
|
|
1399
|
+
if ((noCustomizer && data[2])
|
|
1400
|
+
? data[1] !== object[data[0]]
|
|
1401
|
+
: !(data[0] in object)
|
|
1402
|
+
) {
|
|
1403
|
+
return false;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
while (++index < length) {
|
|
1407
|
+
data = matchData[index];
|
|
1408
|
+
const key = data[0];
|
|
1409
|
+
const objValue = object[key];
|
|
1410
|
+
const srcValue = data[1];
|
|
1411
|
+
|
|
1412
|
+
if (noCustomizer && data[2]) {
|
|
1413
|
+
if (objValue === undefined && !(key in object)) {
|
|
1414
|
+
return false;
|
|
1415
|
+
}
|
|
1416
|
+
} else {
|
|
1417
|
+
const stack = new Stack;
|
|
1418
|
+
if (customizer) {
|
|
1419
|
+
result = customizer(objValue, srcValue, key, object, source, stack);
|
|
1420
|
+
}
|
|
1421
|
+
if (!(result === undefined
|
|
1422
|
+
? baseIsEqual(srcValue, objValue, stack)
|
|
1423
|
+
: result
|
|
1424
|
+
)) {
|
|
1425
|
+
return false;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
return true;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
function property(path) {
|
|
1433
|
+
return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
function baseProperty(key) {
|
|
1437
|
+
return (object) => object == null ? undefined : object[key];
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
function basePropertyDeep(path) {
|
|
1441
|
+
return (object) => get(object, path);
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
function baseIteratee(value) {
|
|
1445
|
+
if (typeof value == 'function') {
|
|
1446
|
+
return value;
|
|
1447
|
+
}
|
|
1448
|
+
if (value == null) {
|
|
1449
|
+
return (val) => val;
|
|
1450
|
+
}
|
|
1451
|
+
if (typeof value == 'object') {
|
|
1452
|
+
return Array.isArray(value)
|
|
1453
|
+
? baseMatchesProperty(value[0], value[1])
|
|
1454
|
+
: baseMatches(value);
|
|
1455
|
+
}
|
|
1456
|
+
return property(value);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
function getIteratee() {
|
|
1460
|
+
const result = baseIteratee;
|
|
1461
|
+
return arguments.length ? result(arguments[0], arguments[1]) : result;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
const arrayReduce = (array, iteratee, accumulator, initAccum) => {
|
|
1465
|
+
let index = -1;
|
|
1466
|
+
const length = array == null ? 0 : array.length;
|
|
1467
|
+
|
|
1468
|
+
if (initAccum && length) {
|
|
1469
|
+
accumulator = array[++index];
|
|
1470
|
+
}
|
|
1471
|
+
while (++index < length) {
|
|
1472
|
+
accumulator = iteratee(accumulator, array[index], index, array);
|
|
1473
|
+
}
|
|
1474
|
+
return accumulator;
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1477
|
+
const baseReduce = (collection, iteratee, accumulator, initAccum, eachFunc) => {
|
|
1478
|
+
eachFunc(collection, (value, index, collection) => {
|
|
1479
|
+
accumulator = initAccum
|
|
1480
|
+
? (initAccum = false, value)
|
|
1481
|
+
: iteratee(accumulator, value, index, collection);
|
|
1482
|
+
});
|
|
1483
|
+
return accumulator;
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
function reduce(collection, iteratee, accumulator) {
|
|
1487
|
+
const func = Array.isArray(collection) ? arrayReduce : baseReduce;
|
|
1488
|
+
const initAccum = arguments.length < 3;
|
|
1489
|
+
return func(collection, iteratee, accumulator, initAccum, baseEach);
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
const isFlattenable = (value) => {
|
|
1493
|
+
return Array.isArray(value) || isArguments(value) ||
|
|
1494
|
+
!!(value && value[Symbol.isConcatSpreadable]);
|
|
1495
|
+
};
|
|
1496
|
+
|
|
1497
|
+
function baseFlatten(array, depth, predicate, isStrict, result) {
|
|
1498
|
+
let index = -1;
|
|
1499
|
+
const length = array.length;
|
|
1500
|
+
|
|
1501
|
+
predicate || (predicate = isFlattenable);
|
|
1502
|
+
result || (result = []);
|
|
1503
|
+
|
|
1504
|
+
while (++index < length) {
|
|
1505
|
+
var value = array[index];
|
|
1506
|
+
if (depth > 0 && predicate(value)) {
|
|
1507
|
+
if (depth > 1) {
|
|
1508
|
+
// Recursively flatten arrays (susceptible to call stack limits).
|
|
1509
|
+
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
|
1510
|
+
} else {
|
|
1511
|
+
result.push(...value);
|
|
1512
|
+
}
|
|
1513
|
+
} else if (!isStrict) {
|
|
1514
|
+
result[result.length] = value;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
return result;
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
const isArguments = (value) => {
|
|
1521
|
+
return isObjectLike(value) && getTag(value) == '[object Arguments]';
|
|
1522
|
+
};
|
|
1523
|
+
|
|
1524
|
+
const basePick = (object, paths) => {
|
|
1525
|
+
return basePickBy(object, paths, (value, path) => hasIn(object, path));
|
|
1526
|
+
};
|
|
1527
|
+
|
|
1528
|
+
const basePickBy = (object, paths, predicate) => {
|
|
1529
|
+
let index = -1;
|
|
1530
|
+
const length = paths.length;
|
|
1531
|
+
const result = {};
|
|
1532
|
+
|
|
1533
|
+
while (++index < length) {
|
|
1534
|
+
const path = paths[index];
|
|
1535
|
+
const value = get(object, path);
|
|
1536
|
+
if (predicate(value, path)) {
|
|
1537
|
+
set(result, castPath(path, object), value);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return result;
|
|
1541
|
+
};
|
|
1542
|
+
|
|
1543
|
+
const isLength = (value) => {
|
|
1544
|
+
return typeof value == 'number' &&
|
|
1545
|
+
value > -1 && value % 1 == 0 && value <= Number.MAX_SAFE_INTEGER;
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
const baseHasIn = (object, key) =>{
|
|
1549
|
+
return object != null && key in Object(object);
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1552
|
+
const hasPath = (object, path, hasFunc) => {
|
|
1553
|
+
path = castPath(path, object);
|
|
1554
|
+
|
|
1555
|
+
var index = -1,
|
|
1556
|
+
length = path.length,
|
|
1557
|
+
result = false;
|
|
1558
|
+
|
|
1559
|
+
while (++index < length) {
|
|
1560
|
+
var key = toKey(path[index]);
|
|
1561
|
+
if (!(result = object != null && hasFunc(object, key))) {
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
object = object[key];
|
|
1565
|
+
}
|
|
1566
|
+
if (result || ++index != length) {
|
|
1567
|
+
return result;
|
|
1568
|
+
}
|
|
1569
|
+
length = object == null ? 0 : object.length;
|
|
1570
|
+
return !!length && isLength(length) && isIndex(key, length) &&
|
|
1571
|
+
(Array.isArray(object) || isArguments(object));
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1574
|
+
const asciiWords = (string) => {
|
|
1575
|
+
return string.match(reAsciiWord);
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
const unicodeWords = (string) => {
|
|
1579
|
+
return string.match(reUnicodeWords);
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1582
|
+
const words = (string, pattern) => {
|
|
1583
|
+
if (pattern === undefined) {
|
|
1584
|
+
const result = hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
|
|
1585
|
+
return result || [];
|
|
1586
|
+
}
|
|
1587
|
+
return string.match(pattern) || [];
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1590
|
+
const castSlice = (array, start, end) => {
|
|
1591
|
+
const { length } = array;
|
|
1592
|
+
end = end === undefined ? length : end;
|
|
1593
|
+
return (!start && end >= length) ? array : array.slice(start, end);
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1596
|
+
const upperFirst = createCaseFirst('toUpperCase');
|
|
1597
|
+
|
|
1598
|
+
function createCaseFirst(methodName) {
|
|
1599
|
+
return (string) => {
|
|
1600
|
+
if (!string) {
|
|
1601
|
+
return '';
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
const strSymbols = hasUnicode(string)
|
|
1605
|
+
? stringToArray(string)
|
|
1606
|
+
: undefined;
|
|
1607
|
+
|
|
1608
|
+
const chr = strSymbols
|
|
1609
|
+
? strSymbols[0]
|
|
1610
|
+
: string[0];
|
|
1611
|
+
|
|
1612
|
+
const trailing = strSymbols
|
|
1613
|
+
? castSlice(strSymbols, 1).join('')
|
|
1614
|
+
: string.slice(1);
|
|
1615
|
+
|
|
1616
|
+
return chr[methodName]() + trailing;
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
export function matches(source) {
|
|
1621
|
+
return baseMatches(baseClone(source, true));
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
// -- helper classes
|
|
1625
|
+
class Stack {
|
|
1626
|
+
constructor(entries) {
|
|
1627
|
+
const data = this.__data__ = new ListCache(entries);
|
|
1628
|
+
this.size = data.size;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
clear() {
|
|
1632
|
+
this.__data__ = new ListCache;
|
|
1633
|
+
this.size = 0;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
delete(key) {
|
|
1637
|
+
const data = this.__data__;
|
|
1638
|
+
const result = data['delete'](key);
|
|
1639
|
+
|
|
1640
|
+
this.size = data.size;
|
|
1641
|
+
return result;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
get(key) {
|
|
1645
|
+
return this.__data__.get(key);
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
has(key) {
|
|
1649
|
+
return this.__data__.has(key);
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
set(key, value) {
|
|
1653
|
+
let data = this.__data__;
|
|
1654
|
+
if (data instanceof ListCache) {
|
|
1655
|
+
const pairs = data.__data__;
|
|
1656
|
+
if (pairs.length < LARGE_ARRAY_SIZE - 1) {
|
|
1657
|
+
pairs.push([key, value]);
|
|
1658
|
+
this.size = ++data.size;
|
|
1659
|
+
return this;
|
|
1660
|
+
}
|
|
1661
|
+
data = this.__data__ = new MapCache(pairs);
|
|
1662
|
+
}
|
|
1663
|
+
data.set(key, value);
|
|
1664
|
+
this.size = data.size;
|
|
1665
|
+
return this;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
class ListCache {
|
|
1670
|
+
constructor(entries) {
|
|
1671
|
+
let index = -1;
|
|
1672
|
+
const length = entries == null ? 0 : entries.length;
|
|
1673
|
+
|
|
1674
|
+
this.clear();
|
|
1675
|
+
while (++index < length) {
|
|
1676
|
+
const entry = entries[index];
|
|
1677
|
+
this.set(entry[0], entry[1]);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
clear() {
|
|
1682
|
+
this.__data__ = [];
|
|
1683
|
+
this.size = 0;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
delete(key) {
|
|
1687
|
+
const data = this.__data__;
|
|
1688
|
+
const index = assocIndexOf(data, key);
|
|
1689
|
+
|
|
1690
|
+
if (index < 0) {
|
|
1691
|
+
return false;
|
|
1692
|
+
}
|
|
1693
|
+
const lastIndex = data.length - 1;
|
|
1694
|
+
if (index == lastIndex) {
|
|
1695
|
+
data.pop();
|
|
1696
|
+
} else {
|
|
1697
|
+
data.splice(index, 1);
|
|
1698
|
+
}
|
|
1699
|
+
--this.size;
|
|
1700
|
+
return true;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
get(key) {
|
|
1704
|
+
const data = this.__data__;
|
|
1705
|
+
const index = assocIndexOf(data, key);
|
|
1706
|
+
return index < 0 ? undefined : data[index][1];
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
has(key) {
|
|
1710
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
set(key, value) {
|
|
1714
|
+
const data = this.__data__;
|
|
1715
|
+
const index = assocIndexOf(data, key);
|
|
1716
|
+
|
|
1717
|
+
if (index < 0) {
|
|
1718
|
+
++this.size;
|
|
1719
|
+
data.push([key, value]);
|
|
1720
|
+
} else {
|
|
1721
|
+
data[index][1] = value;
|
|
1722
|
+
}
|
|
1723
|
+
return this;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
class MapCache {
|
|
1728
|
+
constructor(entries) {
|
|
1729
|
+
let index = -1;
|
|
1730
|
+
const length = entries == null ? 0 : entries.length;
|
|
1731
|
+
|
|
1732
|
+
this.clear();
|
|
1733
|
+
while (++index < length) {
|
|
1734
|
+
const entry = entries[index];
|
|
1735
|
+
this.set(entry[0], entry[1]);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
clear() {
|
|
1740
|
+
this.size = 0;
|
|
1741
|
+
this.__data__ = {
|
|
1742
|
+
'hash': new Hash,
|
|
1743
|
+
'map': new Map,
|
|
1744
|
+
'string': new Hash
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
delete(key) {
|
|
1749
|
+
const result = getMapData(this, key)['delete'](key);
|
|
1750
|
+
this.size -= result ? 1 : 0;
|
|
1751
|
+
return result;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
get(key) {
|
|
1755
|
+
return getMapData(this, key).get(key);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
has(key) {
|
|
1759
|
+
return getMapData(this, key).has(key);
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
set(key, value) {
|
|
1763
|
+
const data = getMapData(this, key);
|
|
1764
|
+
const size = data.size;
|
|
1765
|
+
|
|
1766
|
+
data.set(key, value);
|
|
1767
|
+
this.size += data.size == size ? 0 : 1;
|
|
1768
|
+
return this;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
class Hash {
|
|
1773
|
+
constructor(entries) {
|
|
1774
|
+
let index = -1;
|
|
1775
|
+
const length = entries == null ? 0 : entries.length;
|
|
1776
|
+
|
|
1777
|
+
this.clear();
|
|
1778
|
+
while (++index < length) {
|
|
1779
|
+
const entry = entries[index];
|
|
1780
|
+
this.set(entry[0], entry[1]);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
clear() {
|
|
1785
|
+
this.__data__ = Object.create(null);
|
|
1786
|
+
this.size = 0;
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
delete(key) {
|
|
1790
|
+
const result = this.has(key) && delete this.__data__[key];
|
|
1791
|
+
this.size -= result ? 1 : 0;
|
|
1792
|
+
return result;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
get(key) {
|
|
1796
|
+
const data = this.__data__;
|
|
1797
|
+
const result = data[key];
|
|
1798
|
+
return result === HASH_UNDEFINED ? undefined : result;
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
has(key) {
|
|
1802
|
+
const data = this.__data__;
|
|
1803
|
+
return data[key] !== undefined;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
set(key, value) {
|
|
1807
|
+
const data = this.__data__;
|
|
1808
|
+
this.size += this.has(key) ? 0 : 1;
|
|
1809
|
+
data[key] = value === undefined ? HASH_UNDEFINED : value;
|
|
1810
|
+
return this;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
class SetCache {
|
|
1815
|
+
constructor(values) {
|
|
1816
|
+
let index = -1;
|
|
1817
|
+
const length = values == null ? 0 : values.length;
|
|
1818
|
+
|
|
1819
|
+
this.__data__ = new MapCache;
|
|
1820
|
+
while (++index < length) {
|
|
1821
|
+
this.add(values[index]);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
add(value) {
|
|
1826
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
1827
|
+
return this;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
has(value) {
|
|
1831
|
+
return this.__data__.has(value);
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
SetCache.prototype.push = SetCache.prototype.add;
|
|
1836
|
+
|
|
1837
|
+
// -- top level functions
|
|
1838
|
+
|
|
1839
|
+
export const isBoolean = function(value) {
|
|
1840
|
+
var toString = Object.prototype.toString;
|
|
1841
|
+
return value === true || value === false || (!!value && typeof value === 'object' && toString.call(value) === boolTag);
|
|
1842
|
+
};
|
|
1843
|
+
|
|
1844
|
+
export const isObject = function(value) {
|
|
1845
|
+
return !!value && (typeof value === 'object' || typeof value === 'function');
|
|
1846
|
+
};
|
|
1847
|
+
|
|
1848
|
+
export const isNumber = function(value) {
|
|
1849
|
+
var toString = Object.prototype.toString;
|
|
1850
|
+
return typeof value === 'number' || (!!value && typeof value === 'object' && toString.call(value) === numberTag);
|
|
1851
|
+
};
|
|
1852
|
+
|
|
1853
|
+
export const isString = function(value) {
|
|
1854
|
+
var toString = Object.prototype.toString;
|
|
1855
|
+
return typeof value === 'string' || (!!value && typeof value === 'object' && toString.call(value) === stringTag);
|
|
1856
|
+
};
|
|
1857
|
+
|
|
1858
|
+
export const assign = createAssigner((object, source) => {
|
|
1859
|
+
if (isPrototype(source) || isArrayLike(source)) {
|
|
1860
|
+
copyObject(source, keys(source), object);
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
for (var key in source) {
|
|
1864
|
+
if (hasOwnProperty.call(source, key)) {
|
|
1865
|
+
assignValue(object, key, source[key]);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
});
|
|
1869
|
+
|
|
1870
|
+
export const mixin = assign;
|
|
1871
|
+
|
|
1872
|
+
export const deepMixin = mixin;
|
|
1873
|
+
|
|
1874
|
+
export const supplement = (object, ...sources) => {
|
|
1875
|
+
let index = -1;
|
|
1876
|
+
let length = sources.length;
|
|
1877
|
+
const guard = length > 2 ? sources[2] : undefined;
|
|
1878
|
+
|
|
1879
|
+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|
1880
|
+
length = 1;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
while (++index < length) {
|
|
1884
|
+
const source = sources[index];
|
|
1885
|
+
|
|
1886
|
+
if (source == null) {
|
|
1887
|
+
continue;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
const props = Object.keys(source);
|
|
1891
|
+
const propsLength = props.length;
|
|
1892
|
+
let propsIndex = -1;
|
|
1893
|
+
|
|
1894
|
+
while (++propsIndex < propsLength) {
|
|
1895
|
+
const key = props[propsIndex];
|
|
1896
|
+
const value = object[key];
|
|
1897
|
+
|
|
1898
|
+
if (value === undefined ||
|
|
1899
|
+
(eq(value, Object.prototype[key]) && !hasOwnProperty.call(object, key))) {
|
|
1900
|
+
object[key] = source[key];
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
return object;
|
|
1906
|
+
};
|
|
1907
|
+
|
|
1908
|
+
export const defaults = supplement;
|
|
1909
|
+
|
|
1910
|
+
export const deepSupplement = function defaultsDeep(...args) {
|
|
1911
|
+
args.push(undefined, customDefaultsMerge);
|
|
1912
|
+
return merge.apply(undefined, args);
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1915
|
+
export const defaultsDeep = deepSupplement;
|
|
1916
|
+
|
|
1917
|
+
// _.invokeMap
|
|
1918
|
+
export const invoke = (collection, path, ...args) => {
|
|
1919
|
+
let index = -1;
|
|
1920
|
+
const isFunc = typeof path === 'function';
|
|
1921
|
+
const result = isArrayLike(collection) ? new Array(collection.length) : [];
|
|
1922
|
+
|
|
1923
|
+
baseEach(collection, (value) => {
|
|
1924
|
+
result[++index] = isFunc ? path.apply(value, args) : invokeProperty(value, path, ...args);
|
|
1925
|
+
});
|
|
1926
|
+
|
|
1927
|
+
return result;
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
// _.invoke
|
|
1931
|
+
export const invokeProperty = (object, path, ...args) => {
|
|
1932
|
+
path = castPath(path, object);
|
|
1933
|
+
object = parent(object, path);
|
|
1934
|
+
const func = object == null ? object : object[toKey(last(path))];
|
|
1935
|
+
return func == null ? undefined : func.apply(object, args);
|
|
1936
|
+
};
|
|
1937
|
+
|
|
1938
|
+
export const sortedIndex = (array, value, iteratee) => {
|
|
1939
|
+
let low = 0;
|
|
1940
|
+
let high = array == null ? 0 : array.length;
|
|
1941
|
+
if (high == 0) {
|
|
1942
|
+
return 0;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
iteratee = getIteratee(iteratee, 2);
|
|
1946
|
+
value = iteratee(value);
|
|
1947
|
+
|
|
1948
|
+
const valIsNaN = value !== value;
|
|
1949
|
+
const valIsNull = value === null;
|
|
1950
|
+
const valIsSymbol = isSymbol(value);
|
|
1951
|
+
const valIsUndefined = value === undefined;
|
|
1952
|
+
|
|
1953
|
+
while (low < high) {
|
|
1954
|
+
let setLow;
|
|
1955
|
+
const mid = Math.floor((low + high) / 2);
|
|
1956
|
+
const computed = iteratee(array[mid]);
|
|
1957
|
+
const othIsDefined = computed !== undefined;
|
|
1958
|
+
const othIsNull = computed === null;
|
|
1959
|
+
const othIsReflexive = computed === computed;
|
|
1960
|
+
const othIsSymbol = isSymbol(computed);
|
|
1961
|
+
|
|
1962
|
+
if (valIsNaN) {
|
|
1963
|
+
setLow = othIsReflexive;
|
|
1964
|
+
} else if (valIsUndefined) {
|
|
1965
|
+
setLow = othIsReflexive &&othIsDefined;
|
|
1966
|
+
} else if (valIsNull) {
|
|
1967
|
+
setLow = othIsReflexive && othIsDefined && !othIsNull;
|
|
1968
|
+
} else if (valIsSymbol) {
|
|
1969
|
+
setLow = othIsReflexive && othIsDefined && !othIsNull && !othIsSymbol;
|
|
1970
|
+
} else if (othIsNull || othIsSymbol) {
|
|
1971
|
+
setLow = false;
|
|
1972
|
+
} else {
|
|
1973
|
+
setLow = computed < value;
|
|
1974
|
+
}
|
|
1975
|
+
if (setLow) {
|
|
1976
|
+
low = mid + 1;
|
|
1977
|
+
} else {
|
|
1978
|
+
high = mid;
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
return Math.min(high, MAX_ARRAY_INDEX);
|
|
1982
|
+
};
|
|
1983
|
+
|
|
1984
|
+
export const uniq = (array, iteratee) => {
|
|
1985
|
+
let index = -1;
|
|
1986
|
+
let includes = (array, value) => {
|
|
1987
|
+
const length = array == null ? 0 : array.length;
|
|
1988
|
+
return !!length && array.indexOf(value) > -1;
|
|
1989
|
+
};
|
|
1990
|
+
iteratee = getIteratee(iteratee, 2);
|
|
1991
|
+
let isCommon = true;
|
|
1992
|
+
|
|
1993
|
+
const { length } = array;
|
|
1994
|
+
const result = [];
|
|
1995
|
+
let seen = result;
|
|
1996
|
+
|
|
1997
|
+
if (length >= LARGE_ARRAY_SIZE) {
|
|
1998
|
+
const set = iteratee ? null : createSet(array);
|
|
1999
|
+
if (set) {
|
|
2000
|
+
return setToArray(set);
|
|
2001
|
+
}
|
|
2002
|
+
isCommon = false;
|
|
2003
|
+
includes = (cache, key) => cache.has(key);
|
|
2004
|
+
seen = new SetCache;
|
|
2005
|
+
} else {
|
|
2006
|
+
seen = iteratee ? [] : result;
|
|
2007
|
+
}
|
|
2008
|
+
outer:
|
|
2009
|
+
while (++index < length) {
|
|
2010
|
+
let value = array[index];
|
|
2011
|
+
const computed = iteratee ? iteratee(value) : value;
|
|
2012
|
+
|
|
2013
|
+
value = (value !== 0) ? value : 0;
|
|
2014
|
+
if (isCommon && computed === computed) {
|
|
2015
|
+
let seenIndex = seen.length;
|
|
2016
|
+
while (seenIndex--) {
|
|
2017
|
+
if (seen[seenIndex] === computed) {
|
|
2018
|
+
continue outer;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
if (iteratee) {
|
|
2022
|
+
seen.push(computed);
|
|
2023
|
+
}
|
|
2024
|
+
result.push(value);
|
|
2025
|
+
}
|
|
2026
|
+
else if (!includes(seen, computed)) {
|
|
2027
|
+
if (seen !== result) {
|
|
2028
|
+
seen.push(computed);
|
|
2029
|
+
}
|
|
2030
|
+
result.push(value);
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
return result;
|
|
2034
|
+
};
|
|
2035
|
+
|
|
2036
|
+
export const clone = (value) => baseClone(value);
|
|
2037
|
+
|
|
2038
|
+
export const cloneDeep = (value) => baseClone(value, true);
|
|
2039
|
+
|
|
2040
|
+
export const isEmpty = (value) => {
|
|
2041
|
+
if (value == null) {
|
|
2042
|
+
return true;
|
|
2043
|
+
}
|
|
2044
|
+
if (isArrayLike(value) &&
|
|
2045
|
+
(Array.isArray(value) || typeof value === 'string' || typeof value.splice === 'function' ||
|
|
2046
|
+
isTypedArray(value) || isArguments(value))) {
|
|
2047
|
+
return !value.length;
|
|
2048
|
+
}
|
|
2049
|
+
const tag = getTag(value);
|
|
2050
|
+
if (tag == '[object Map]' || tag == '[object Set]') {
|
|
2051
|
+
return !value.size;
|
|
2052
|
+
}
|
|
2053
|
+
if (isPrototype(value)) {
|
|
2054
|
+
return !baseKeys(value).length;
|
|
2055
|
+
}
|
|
2056
|
+
for (const key in value) {
|
|
2057
|
+
if (hasOwnProperty.call(value, key)) {
|
|
2058
|
+
return false;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
return true;
|
|
2062
|
+
};
|
|
2063
|
+
export const isEqual = (object, other) => baseIsEqual(object, other);
|
|
2064
|
+
|
|
2065
|
+
export const isFunction = (value) => typeof value === 'function';
|
|
2066
|
+
|
|
2067
|
+
export const isPlainObject = (value) => {
|
|
2068
|
+
if (!isObjectLike(value) || getTag(value) != '[object Object]') {
|
|
2069
|
+
return false;
|
|
2070
|
+
}
|
|
2071
|
+
if (Object.getPrototypeOf(value) === null) {
|
|
2072
|
+
return true;
|
|
2073
|
+
}
|
|
2074
|
+
let proto = value;
|
|
2075
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
2076
|
+
proto = Object.getPrototypeOf(proto);
|
|
2077
|
+
}
|
|
2078
|
+
return Object.getPrototypeOf(value) === proto;
|
|
2079
|
+
};
|
|
2080
|
+
|
|
2081
|
+
export const toArray = (value) => {
|
|
2082
|
+
if (!value) {
|
|
2083
|
+
return [];
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
if (isArrayLike(value)) {
|
|
2087
|
+
return isString(value) ? stringToArray(value) : copyArray(value);
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
if (Symbol.iterator && Symbol.iterator in Object(value)) {
|
|
2091
|
+
const iterator = value[Symbol.iterator]();
|
|
2092
|
+
let data;
|
|
2093
|
+
const result = [];
|
|
2094
|
+
|
|
2095
|
+
while (!(data = iterator.next()).done) {
|
|
2096
|
+
result.push(data.value);
|
|
2097
|
+
}
|
|
2098
|
+
return result;
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
const tag = getTag(value);
|
|
2102
|
+
const func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
|
|
2103
|
+
|
|
2104
|
+
return func(value);
|
|
2105
|
+
};
|
|
2106
|
+
|
|
2107
|
+
export function debounce(func, wait, opt) {
|
|
2108
|
+
if (typeof func !== 'function') {
|
|
2109
|
+
throw new TypeError('Expected a function');
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
let lastArgs;
|
|
2113
|
+
let lastThis;
|
|
2114
|
+
let maxWait;
|
|
2115
|
+
let result;
|
|
2116
|
+
let timerId;
|
|
2117
|
+
let lastCallTime;
|
|
2118
|
+
let lastInvokeTime = 0;
|
|
2119
|
+
let leading = false;
|
|
2120
|
+
let maxing = false;
|
|
2121
|
+
let trailing = true;
|
|
2122
|
+
|
|
2123
|
+
const useRaf = (!wait && wait !== 0 && window && typeof window.requestAnimationFrame === 'function');
|
|
2124
|
+
|
|
2125
|
+
wait = +wait || 0;
|
|
2126
|
+
|
|
2127
|
+
if (isObject(opt)) {
|
|
2128
|
+
leading = !!opt.leading;
|
|
2129
|
+
maxing = 'maxWait' in opt;
|
|
2130
|
+
maxWait = maxing ? Math.max(+opt.maxWait || 0, wait) : maxWait;
|
|
2131
|
+
trailing = 'trailing' in opt ? !!opt.trailing : trailing;
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
function invokeFunc(time) {
|
|
2135
|
+
const args = lastArgs;
|
|
2136
|
+
const thisArg = lastThis;
|
|
2137
|
+
|
|
2138
|
+
lastArgs = lastThis = undefined;
|
|
2139
|
+
lastInvokeTime = time;
|
|
2140
|
+
result = func.apply(thisArg, args);
|
|
2141
|
+
return result;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
function startTimer(pendingFunc, wait) {
|
|
2145
|
+
if (useRaf) {
|
|
2146
|
+
window.cancelAnimationFrame(timerId);
|
|
2147
|
+
return window.requestAnimationFrame(pendingFunc);
|
|
2148
|
+
}
|
|
2149
|
+
return setTimeout(pendingFunc, wait);
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
function cancelTimer(id) {
|
|
2153
|
+
if (useRaf) {
|
|
2154
|
+
return window.cancelAnimationFrame(id);
|
|
2155
|
+
}
|
|
2156
|
+
clearTimeout(id);
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
function leadingEdge(time) {
|
|
2160
|
+
lastInvokeTime = time;
|
|
2161
|
+
timerId = startTimer(timerExpired, wait);
|
|
2162
|
+
return leading ? invokeFunc(time) : result;
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
function remainingWait(time) {
|
|
2166
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
2167
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
2168
|
+
const timeWaiting = wait - timeSinceLastCall;
|
|
2169
|
+
|
|
2170
|
+
return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
function shouldInvoke(time) {
|
|
2174
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
2175
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
2176
|
+
|
|
2177
|
+
return (lastCallTime === undefined || (timeSinceLastCall >= wait) || (timeSinceLastCall < 0) ||
|
|
2178
|
+
(maxing && timeSinceLastInvoke >= maxWait));
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
function timerExpired() {
|
|
2182
|
+
const time = Date.now();
|
|
2183
|
+
if (shouldInvoke(time)) {
|
|
2184
|
+
return trailingEdge(time);
|
|
2185
|
+
}
|
|
2186
|
+
timerId = startTimer(timerExpired, remainingWait(time));
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
function trailingEdge(time) {
|
|
2190
|
+
timerId = undefined;
|
|
2191
|
+
|
|
2192
|
+
if (trailing && lastArgs) {
|
|
2193
|
+
return invokeFunc(time);
|
|
2194
|
+
}
|
|
2195
|
+
lastArgs = lastThis = undefined;
|
|
2196
|
+
return result;
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
function debounced(...args) {
|
|
2200
|
+
const time = Date.now();
|
|
2201
|
+
const isInvoking = shouldInvoke(time);
|
|
2202
|
+
|
|
2203
|
+
lastArgs = args;
|
|
2204
|
+
lastThis = this;
|
|
2205
|
+
lastCallTime = time;
|
|
2206
|
+
|
|
2207
|
+
if (isInvoking) {
|
|
2208
|
+
if (timerId === undefined) {
|
|
2209
|
+
return leadingEdge(lastCallTime);
|
|
2210
|
+
}
|
|
2211
|
+
if (maxing) {
|
|
2212
|
+
timerId = startTimer(timerExpired, wait);
|
|
2213
|
+
return invokeFunc(lastCallTime);
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
if (timerId === undefined) {
|
|
2217
|
+
timerId = startTimer(timerExpired, wait);
|
|
2218
|
+
}
|
|
2219
|
+
return result;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
debounced.cancel = () => {
|
|
2223
|
+
if (timerId !== undefined) {
|
|
2224
|
+
cancelTimer(timerId);
|
|
2225
|
+
}
|
|
2226
|
+
lastInvokeTime = 0;
|
|
2227
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
2228
|
+
};
|
|
2229
|
+
debounced.flush = () => timerId === undefined ? result : trailingEdge(Date.now());
|
|
2230
|
+
debounced.pending = () => timerId !== undefined;
|
|
2231
|
+
|
|
2232
|
+
return debounced;
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
export const groupBy = (collection, iteratee) => {
|
|
2236
|
+
iteratee = getIteratee(iteratee, 2);
|
|
2237
|
+
|
|
2238
|
+
return reduce(collection, (result, value, key) => {
|
|
2239
|
+
key = iteratee(value);
|
|
2240
|
+
if (hasOwnProperty.call(result, key)) {
|
|
2241
|
+
result[key].push(value);
|
|
2242
|
+
} else {
|
|
2243
|
+
assignValue(result, key, [value]);
|
|
2244
|
+
}
|
|
2245
|
+
return result;
|
|
2246
|
+
}, {});
|
|
2247
|
+
};
|
|
2248
|
+
|
|
2249
|
+
export const sortBy = (collection, iteratees = []) => {
|
|
2250
|
+
if (collection == null) {
|
|
2251
|
+
return [];
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
const length = iteratees.length;
|
|
2255
|
+
if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
|
|
2256
|
+
iteratees = [];
|
|
2257
|
+
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
|
2258
|
+
iteratees = [iteratees[0]];
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
if (!Array.isArray(iteratees)) {
|
|
2262
|
+
iteratees = [getIteratee(iteratees, 2)];
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
return baseOrderBy(collection, iteratees.flat(1), []);
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2268
|
+
export const flattenDeep = (array) => {
|
|
2269
|
+
const length = array == null ? 0 : array.length;
|
|
2270
|
+
return length ? baseFlatten(array, Infinity) : [];
|
|
2271
|
+
};
|
|
2272
|
+
|
|
2273
|
+
export const without = (array, ...values) => isArrayLike(array) ? diff(array, values) : [];
|
|
2274
|
+
|
|
2275
|
+
export const difference = (array, ...values) =>
|
|
2276
|
+
isObjectLike(array) && isArrayLike(array) ?
|
|
2277
|
+
diff(array, values.flat(1)) : [];
|
|
2278
|
+
|
|
2279
|
+
export const intersection = (...arrays) => {
|
|
2280
|
+
const mapped = arrays.map((array) =>
|
|
2281
|
+
isObjectLike(array) && isArrayLike(array) ?
|
|
2282
|
+
array : []
|
|
2283
|
+
);
|
|
2284
|
+
|
|
2285
|
+
return mapped.length && mapped[0] === arrays[0] ?
|
|
2286
|
+
intersect(mapped) : [];
|
|
2287
|
+
};
|
|
2288
|
+
|
|
2289
|
+
export const union = (...arrays) => {
|
|
2290
|
+
const array = arrays.flat(1);
|
|
2291
|
+
return uniq(array);
|
|
2292
|
+
};
|
|
2293
|
+
|
|
2294
|
+
export const has = (object, key) => {
|
|
2295
|
+
if (object == null) {
|
|
2296
|
+
return false;
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
if (typeof key === 'string') {
|
|
2300
|
+
key = key.split('.');
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
let index = -1;
|
|
2304
|
+
let value = object;
|
|
2305
|
+
|
|
2306
|
+
while (++index < key.length) {
|
|
2307
|
+
if (!value || !hasOwnProperty.call(value, key[index])) {
|
|
2308
|
+
return false;
|
|
2309
|
+
}
|
|
2310
|
+
value = value[key[index]];
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
return true;
|
|
2314
|
+
};
|
|
2315
|
+
|
|
2316
|
+
export const result = (object, path, defaultValue) => {
|
|
2317
|
+
path = castPath(path, object);
|
|
2318
|
+
|
|
2319
|
+
let index = -1;
|
|
2320
|
+
let length = path.length;
|
|
2321
|
+
|
|
2322
|
+
if (!length) {
|
|
2323
|
+
length = 1;
|
|
2324
|
+
object = undefined;
|
|
2325
|
+
}
|
|
2326
|
+
while (++index < length) {
|
|
2327
|
+
let value = object == null ? undefined : object[toKey(path[index])];
|
|
2328
|
+
if (value === undefined) {
|
|
2329
|
+
index = length;
|
|
2330
|
+
value = defaultValue;
|
|
2331
|
+
}
|
|
2332
|
+
object = typeof value === 'function' ? value.call(object) : value;
|
|
2333
|
+
}
|
|
2334
|
+
return object;
|
|
2335
|
+
};
|
|
2336
|
+
|
|
2337
|
+
export const omit = (object, ...paths) => {
|
|
2338
|
+
let result = {};
|
|
2339
|
+
if (object == null) {
|
|
2340
|
+
return result;
|
|
2341
|
+
}
|
|
2342
|
+
let isDeep = false;
|
|
2343
|
+
paths = paths.flat(1).map((path) => {
|
|
2344
|
+
path = castPath(path, object);
|
|
2345
|
+
isDeep || (isDeep = path.length > 1);
|
|
2346
|
+
return path;
|
|
2347
|
+
});
|
|
2348
|
+
copyObject(object, getAllKeysIn(object), result);
|
|
2349
|
+
if (isDeep) {
|
|
2350
|
+
result = baseClone(result, true, true, true, (value) => isPlainObject(value) ? undefined : value);
|
|
2351
|
+
}
|
|
2352
|
+
let length = paths.length;
|
|
2353
|
+
while (length--) {
|
|
2354
|
+
unset(result, paths[length]);
|
|
2355
|
+
}
|
|
2356
|
+
return result;
|
|
2357
|
+
};
|
|
2358
|
+
|
|
2359
|
+
export const pick = (object, ...paths) => {
|
|
2360
|
+
return object == null ? {} : basePick(object, paths.flat(Infinity));
|
|
2361
|
+
};
|
|
2362
|
+
|
|
2363
|
+
export const bindAll = (object, ...methodNames) => {
|
|
2364
|
+
methodNames.flat(1).forEach((key) => {
|
|
2365
|
+
key = toKey(key);
|
|
2366
|
+
assignValue(object, key, object[key].bind(object));
|
|
2367
|
+
});
|
|
2368
|
+
return object;
|
|
2369
|
+
};
|
|
2370
|
+
|
|
2371
|
+
export const forIn = (object, iteratee = (value) => value) => {
|
|
2372
|
+
let index = -1;
|
|
2373
|
+
const iterable = Object(object);
|
|
2374
|
+
const props = isArrayLike(object) ? arrayLikeKeys(object, true) : keysIn(object);
|
|
2375
|
+
let length = props.length;
|
|
2376
|
+
|
|
2377
|
+
while(length--) {
|
|
2378
|
+
const key = props[++index];
|
|
2379
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
2380
|
+
break;
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
};
|
|
2384
|
+
|
|
2385
|
+
export const camelCase = (string = '') => (
|
|
2386
|
+
words(`${string}`.replace(/['\u2019]/g, ''))
|
|
2387
|
+
.reduce((result, word, index) => {
|
|
2388
|
+
word = word.toLowerCase();
|
|
2389
|
+
return result + (index ? upperFirst(word) : word);
|
|
2390
|
+
}, '')
|
|
2391
|
+
);
|
|
2392
|
+
|
|
2393
|
+
let idCounter = 0;
|
|
2394
|
+
|
|
2395
|
+
export const uniqueId = (prefix = '') => {
|
|
2396
|
+
const id = ++idCounter;
|
|
2397
|
+
return `${prefix}` + id;
|
|
2398
|
+
};
|
|
2399
|
+
|
|
2400
|
+
export const merge = createAssigner((object, source, srcIndex, customizer) => {
|
|
2401
|
+
baseMerge(object, source, srcIndex, customizer);
|
|
2402
|
+
}, true);
|