@reactuses/core 2.2.5 → 2.2.7
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/dist/index.cjs +2429 -24
- package/dist/index.mjs +2421 -16
- package/package.json +6 -4
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var lodash = require('lodash');
|
|
7
6
|
|
|
8
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
8
|
|
|
@@ -45,10 +44,10 @@ const createUpdateEffect = (hook) => (effect, deps) => {
|
|
|
45
44
|
|
|
46
45
|
var useUpdateEffect = createUpdateEffect(React.useEffect);
|
|
47
46
|
|
|
48
|
-
var
|
|
47
|
+
var index$4 = createUpdateEffect(React.useLayoutEffect);
|
|
49
48
|
|
|
50
49
|
var _a;
|
|
51
|
-
const isFunction = (val) => typeof val === "function";
|
|
50
|
+
const isFunction$1 = (val) => typeof val === "function";
|
|
52
51
|
const isDev = process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
53
52
|
const isBrowser = typeof window !== "undefined";
|
|
54
53
|
const isNavigator = typeof navigator !== "undefined";
|
|
@@ -65,7 +64,7 @@ const useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : React.useE
|
|
|
65
64
|
|
|
66
65
|
function useEvent(fn) {
|
|
67
66
|
if (isDev) {
|
|
68
|
-
if (!isFunction(fn)) {
|
|
67
|
+
if (!isFunction$1(fn)) {
|
|
69
68
|
console.error(
|
|
70
69
|
`useEvent expected parameter is a function, got ${typeof fn}`
|
|
71
70
|
);
|
|
@@ -81,6 +80,2412 @@ function useEvent(fn) {
|
|
|
81
80
|
}, []);
|
|
82
81
|
}
|
|
83
82
|
|
|
83
|
+
/** Detect free variable `global` from Node.js. */
|
|
84
|
+
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
85
|
+
|
|
86
|
+
/** Detect free variable `self`. */
|
|
87
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
88
|
+
|
|
89
|
+
/** Used as a reference to the global object. */
|
|
90
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
91
|
+
|
|
92
|
+
/** Built-in value references. */
|
|
93
|
+
var Symbol = root.Symbol;
|
|
94
|
+
|
|
95
|
+
/** Used for built-in method references. */
|
|
96
|
+
var objectProto$b = Object.prototype;
|
|
97
|
+
|
|
98
|
+
/** Used to check objects for own properties. */
|
|
99
|
+
var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Used to resolve the
|
|
103
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
104
|
+
* of values.
|
|
105
|
+
*/
|
|
106
|
+
var nativeObjectToString$1 = objectProto$b.toString;
|
|
107
|
+
|
|
108
|
+
/** Built-in value references. */
|
|
109
|
+
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
113
|
+
*
|
|
114
|
+
* @private
|
|
115
|
+
* @param {*} value The value to query.
|
|
116
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
117
|
+
*/
|
|
118
|
+
function getRawTag(value) {
|
|
119
|
+
var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
|
|
120
|
+
tag = value[symToStringTag$1];
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
value[symToStringTag$1] = undefined;
|
|
124
|
+
var unmasked = true;
|
|
125
|
+
} catch (e) {}
|
|
126
|
+
|
|
127
|
+
var result = nativeObjectToString$1.call(value);
|
|
128
|
+
if (unmasked) {
|
|
129
|
+
if (isOwn) {
|
|
130
|
+
value[symToStringTag$1] = tag;
|
|
131
|
+
} else {
|
|
132
|
+
delete value[symToStringTag$1];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Used for built-in method references. */
|
|
139
|
+
var objectProto$a = Object.prototype;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Used to resolve the
|
|
143
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
144
|
+
* of values.
|
|
145
|
+
*/
|
|
146
|
+
var nativeObjectToString = objectProto$a.toString;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
150
|
+
*
|
|
151
|
+
* @private
|
|
152
|
+
* @param {*} value The value to convert.
|
|
153
|
+
* @returns {string} Returns the converted string.
|
|
154
|
+
*/
|
|
155
|
+
function objectToString(value) {
|
|
156
|
+
return nativeObjectToString.call(value);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** `Object#toString` result references. */
|
|
160
|
+
var nullTag = '[object Null]',
|
|
161
|
+
undefinedTag = '[object Undefined]';
|
|
162
|
+
|
|
163
|
+
/** Built-in value references. */
|
|
164
|
+
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
168
|
+
*
|
|
169
|
+
* @private
|
|
170
|
+
* @param {*} value The value to query.
|
|
171
|
+
* @returns {string} Returns the `toStringTag`.
|
|
172
|
+
*/
|
|
173
|
+
function baseGetTag(value) {
|
|
174
|
+
if (value == null) {
|
|
175
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
176
|
+
}
|
|
177
|
+
return (symToStringTag && symToStringTag in Object(value))
|
|
178
|
+
? getRawTag(value)
|
|
179
|
+
: objectToString(value);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
184
|
+
* and has a `typeof` result of "object".
|
|
185
|
+
*
|
|
186
|
+
* @static
|
|
187
|
+
* @memberOf _
|
|
188
|
+
* @since 4.0.0
|
|
189
|
+
* @category Lang
|
|
190
|
+
* @param {*} value The value to check.
|
|
191
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
192
|
+
* @example
|
|
193
|
+
*
|
|
194
|
+
* _.isObjectLike({});
|
|
195
|
+
* // => true
|
|
196
|
+
*
|
|
197
|
+
* _.isObjectLike([1, 2, 3]);
|
|
198
|
+
* // => true
|
|
199
|
+
*
|
|
200
|
+
* _.isObjectLike(_.noop);
|
|
201
|
+
* // => false
|
|
202
|
+
*
|
|
203
|
+
* _.isObjectLike(null);
|
|
204
|
+
* // => false
|
|
205
|
+
*/
|
|
206
|
+
function isObjectLike(value) {
|
|
207
|
+
return value != null && typeof value == 'object';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** `Object#toString` result references. */
|
|
211
|
+
var symbolTag$1 = '[object Symbol]';
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
215
|
+
*
|
|
216
|
+
* @static
|
|
217
|
+
* @memberOf _
|
|
218
|
+
* @since 4.0.0
|
|
219
|
+
* @category Lang
|
|
220
|
+
* @param {*} value The value to check.
|
|
221
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
222
|
+
* @example
|
|
223
|
+
*
|
|
224
|
+
* _.isSymbol(Symbol.iterator);
|
|
225
|
+
* // => true
|
|
226
|
+
*
|
|
227
|
+
* _.isSymbol('abc');
|
|
228
|
+
* // => false
|
|
229
|
+
*/
|
|
230
|
+
function isSymbol(value) {
|
|
231
|
+
return typeof value == 'symbol' ||
|
|
232
|
+
(isObjectLike(value) && baseGetTag(value) == symbolTag$1);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Checks if `value` is classified as an `Array` object.
|
|
237
|
+
*
|
|
238
|
+
* @static
|
|
239
|
+
* @memberOf _
|
|
240
|
+
* @since 0.1.0
|
|
241
|
+
* @category Lang
|
|
242
|
+
* @param {*} value The value to check.
|
|
243
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
244
|
+
* @example
|
|
245
|
+
*
|
|
246
|
+
* _.isArray([1, 2, 3]);
|
|
247
|
+
* // => true
|
|
248
|
+
*
|
|
249
|
+
* _.isArray(document.body.children);
|
|
250
|
+
* // => false
|
|
251
|
+
*
|
|
252
|
+
* _.isArray('abc');
|
|
253
|
+
* // => false
|
|
254
|
+
*
|
|
255
|
+
* _.isArray(_.noop);
|
|
256
|
+
* // => false
|
|
257
|
+
*/
|
|
258
|
+
var isArray = Array.isArray;
|
|
259
|
+
|
|
260
|
+
/** Used to match a single whitespace character. */
|
|
261
|
+
var reWhitespace = /\s/;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
|
|
265
|
+
* character of `string`.
|
|
266
|
+
*
|
|
267
|
+
* @private
|
|
268
|
+
* @param {string} string The string to inspect.
|
|
269
|
+
* @returns {number} Returns the index of the last non-whitespace character.
|
|
270
|
+
*/
|
|
271
|
+
function trimmedEndIndex(string) {
|
|
272
|
+
var index = string.length;
|
|
273
|
+
|
|
274
|
+
while (index-- && reWhitespace.test(string.charAt(index))) {}
|
|
275
|
+
return index;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** Used to match leading whitespace. */
|
|
279
|
+
var reTrimStart = /^\s+/;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* The base implementation of `_.trim`.
|
|
283
|
+
*
|
|
284
|
+
* @private
|
|
285
|
+
* @param {string} string The string to trim.
|
|
286
|
+
* @returns {string} Returns the trimmed string.
|
|
287
|
+
*/
|
|
288
|
+
function baseTrim(string) {
|
|
289
|
+
return string
|
|
290
|
+
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
|
|
291
|
+
: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Checks if `value` is the
|
|
296
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
297
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
298
|
+
*
|
|
299
|
+
* @static
|
|
300
|
+
* @memberOf _
|
|
301
|
+
* @since 0.1.0
|
|
302
|
+
* @category Lang
|
|
303
|
+
* @param {*} value The value to check.
|
|
304
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
305
|
+
* @example
|
|
306
|
+
*
|
|
307
|
+
* _.isObject({});
|
|
308
|
+
* // => true
|
|
309
|
+
*
|
|
310
|
+
* _.isObject([1, 2, 3]);
|
|
311
|
+
* // => true
|
|
312
|
+
*
|
|
313
|
+
* _.isObject(_.noop);
|
|
314
|
+
* // => true
|
|
315
|
+
*
|
|
316
|
+
* _.isObject(null);
|
|
317
|
+
* // => false
|
|
318
|
+
*/
|
|
319
|
+
function isObject(value) {
|
|
320
|
+
var type = typeof value;
|
|
321
|
+
return value != null && (type == 'object' || type == 'function');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** Used as references for various `Number` constants. */
|
|
325
|
+
var NAN = 0 / 0;
|
|
326
|
+
|
|
327
|
+
/** Used to detect bad signed hexadecimal string values. */
|
|
328
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
329
|
+
|
|
330
|
+
/** Used to detect binary string values. */
|
|
331
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
332
|
+
|
|
333
|
+
/** Used to detect octal string values. */
|
|
334
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
335
|
+
|
|
336
|
+
/** Built-in method references without a dependency on `root`. */
|
|
337
|
+
var freeParseInt = parseInt;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Converts `value` to a number.
|
|
341
|
+
*
|
|
342
|
+
* @static
|
|
343
|
+
* @memberOf _
|
|
344
|
+
* @since 4.0.0
|
|
345
|
+
* @category Lang
|
|
346
|
+
* @param {*} value The value to process.
|
|
347
|
+
* @returns {number} Returns the number.
|
|
348
|
+
* @example
|
|
349
|
+
*
|
|
350
|
+
* _.toNumber(3.2);
|
|
351
|
+
* // => 3.2
|
|
352
|
+
*
|
|
353
|
+
* _.toNumber(Number.MIN_VALUE);
|
|
354
|
+
* // => 5e-324
|
|
355
|
+
*
|
|
356
|
+
* _.toNumber(Infinity);
|
|
357
|
+
* // => Infinity
|
|
358
|
+
*
|
|
359
|
+
* _.toNumber('3.2');
|
|
360
|
+
* // => 3.2
|
|
361
|
+
*/
|
|
362
|
+
function toNumber(value) {
|
|
363
|
+
if (typeof value == 'number') {
|
|
364
|
+
return value;
|
|
365
|
+
}
|
|
366
|
+
if (isSymbol(value)) {
|
|
367
|
+
return NAN;
|
|
368
|
+
}
|
|
369
|
+
if (isObject(value)) {
|
|
370
|
+
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
371
|
+
value = isObject(other) ? (other + '') : other;
|
|
372
|
+
}
|
|
373
|
+
if (typeof value != 'string') {
|
|
374
|
+
return value === 0 ? value : +value;
|
|
375
|
+
}
|
|
376
|
+
value = baseTrim(value);
|
|
377
|
+
var isBinary = reIsBinary.test(value);
|
|
378
|
+
return (isBinary || reIsOctal.test(value))
|
|
379
|
+
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
380
|
+
: (reIsBadHex.test(value) ? NAN : +value);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** `Object#toString` result references. */
|
|
384
|
+
var asyncTag = '[object AsyncFunction]',
|
|
385
|
+
funcTag$1 = '[object Function]',
|
|
386
|
+
genTag = '[object GeneratorFunction]',
|
|
387
|
+
proxyTag = '[object Proxy]';
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Checks if `value` is classified as a `Function` object.
|
|
391
|
+
*
|
|
392
|
+
* @static
|
|
393
|
+
* @memberOf _
|
|
394
|
+
* @since 0.1.0
|
|
395
|
+
* @category Lang
|
|
396
|
+
* @param {*} value The value to check.
|
|
397
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
398
|
+
* @example
|
|
399
|
+
*
|
|
400
|
+
* _.isFunction(_);
|
|
401
|
+
* // => true
|
|
402
|
+
*
|
|
403
|
+
* _.isFunction(/abc/);
|
|
404
|
+
* // => false
|
|
405
|
+
*/
|
|
406
|
+
function isFunction(value) {
|
|
407
|
+
if (!isObject(value)) {
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
411
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
412
|
+
var tag = baseGetTag(value);
|
|
413
|
+
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/** Used to detect overreaching core-js shims. */
|
|
417
|
+
var coreJsData = root['__core-js_shared__'];
|
|
418
|
+
|
|
419
|
+
/** Used to detect methods masquerading as native. */
|
|
420
|
+
var maskSrcKey = (function() {
|
|
421
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
422
|
+
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
423
|
+
}());
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Checks if `func` has its source masked.
|
|
427
|
+
*
|
|
428
|
+
* @private
|
|
429
|
+
* @param {Function} func The function to check.
|
|
430
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
431
|
+
*/
|
|
432
|
+
function isMasked(func) {
|
|
433
|
+
return !!maskSrcKey && (maskSrcKey in func);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** Used for built-in method references. */
|
|
437
|
+
var funcProto$1 = Function.prototype;
|
|
438
|
+
|
|
439
|
+
/** Used to resolve the decompiled source of functions. */
|
|
440
|
+
var funcToString$1 = funcProto$1.toString;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Converts `func` to its source code.
|
|
444
|
+
*
|
|
445
|
+
* @private
|
|
446
|
+
* @param {Function} func The function to convert.
|
|
447
|
+
* @returns {string} Returns the source code.
|
|
448
|
+
*/
|
|
449
|
+
function toSource(func) {
|
|
450
|
+
if (func != null) {
|
|
451
|
+
try {
|
|
452
|
+
return funcToString$1.call(func);
|
|
453
|
+
} catch (e) {}
|
|
454
|
+
try {
|
|
455
|
+
return (func + '');
|
|
456
|
+
} catch (e) {}
|
|
457
|
+
}
|
|
458
|
+
return '';
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Used to match `RegExp`
|
|
463
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
464
|
+
*/
|
|
465
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
466
|
+
|
|
467
|
+
/** Used to detect host constructors (Safari). */
|
|
468
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
469
|
+
|
|
470
|
+
/** Used for built-in method references. */
|
|
471
|
+
var funcProto = Function.prototype,
|
|
472
|
+
objectProto$9 = Object.prototype;
|
|
473
|
+
|
|
474
|
+
/** Used to resolve the decompiled source of functions. */
|
|
475
|
+
var funcToString = funcProto.toString;
|
|
476
|
+
|
|
477
|
+
/** Used to check objects for own properties. */
|
|
478
|
+
var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
|
|
479
|
+
|
|
480
|
+
/** Used to detect if a method is native. */
|
|
481
|
+
var reIsNative = RegExp('^' +
|
|
482
|
+
funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
|
|
483
|
+
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
488
|
+
*
|
|
489
|
+
* @private
|
|
490
|
+
* @param {*} value The value to check.
|
|
491
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
492
|
+
* else `false`.
|
|
493
|
+
*/
|
|
494
|
+
function baseIsNative(value) {
|
|
495
|
+
if (!isObject(value) || isMasked(value)) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
499
|
+
return pattern.test(toSource(value));
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Gets the value at `key` of `object`.
|
|
504
|
+
*
|
|
505
|
+
* @private
|
|
506
|
+
* @param {Object} [object] The object to query.
|
|
507
|
+
* @param {string} key The key of the property to get.
|
|
508
|
+
* @returns {*} Returns the property value.
|
|
509
|
+
*/
|
|
510
|
+
function getValue(object, key) {
|
|
511
|
+
return object == null ? undefined : object[key];
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Gets the native function at `key` of `object`.
|
|
516
|
+
*
|
|
517
|
+
* @private
|
|
518
|
+
* @param {Object} object The object to query.
|
|
519
|
+
* @param {string} key The key of the method to get.
|
|
520
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
521
|
+
*/
|
|
522
|
+
function getNative(object, key) {
|
|
523
|
+
var value = getValue(object, key);
|
|
524
|
+
return baseIsNative(value) ? value : undefined;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/* Built-in method references that are verified to be native. */
|
|
528
|
+
var WeakMap = getNative(root, 'WeakMap');
|
|
529
|
+
|
|
530
|
+
/** Used as references for various `Number` constants. */
|
|
531
|
+
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
|
532
|
+
|
|
533
|
+
/** Used to detect unsigned integer values. */
|
|
534
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Checks if `value` is a valid array-like index.
|
|
538
|
+
*
|
|
539
|
+
* @private
|
|
540
|
+
* @param {*} value The value to check.
|
|
541
|
+
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|
542
|
+
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|
543
|
+
*/
|
|
544
|
+
function isIndex(value, length) {
|
|
545
|
+
var type = typeof value;
|
|
546
|
+
length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
|
547
|
+
|
|
548
|
+
return !!length &&
|
|
549
|
+
(type == 'number' ||
|
|
550
|
+
(type != 'symbol' && reIsUint.test(value))) &&
|
|
551
|
+
(value > -1 && value % 1 == 0 && value < length);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Performs a
|
|
556
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
557
|
+
* comparison between two values to determine if they are equivalent.
|
|
558
|
+
*
|
|
559
|
+
* @static
|
|
560
|
+
* @memberOf _
|
|
561
|
+
* @since 4.0.0
|
|
562
|
+
* @category Lang
|
|
563
|
+
* @param {*} value The value to compare.
|
|
564
|
+
* @param {*} other The other value to compare.
|
|
565
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
566
|
+
* @example
|
|
567
|
+
*
|
|
568
|
+
* var object = { 'a': 1 };
|
|
569
|
+
* var other = { 'a': 1 };
|
|
570
|
+
*
|
|
571
|
+
* _.eq(object, object);
|
|
572
|
+
* // => true
|
|
573
|
+
*
|
|
574
|
+
* _.eq(object, other);
|
|
575
|
+
* // => false
|
|
576
|
+
*
|
|
577
|
+
* _.eq('a', 'a');
|
|
578
|
+
* // => true
|
|
579
|
+
*
|
|
580
|
+
* _.eq('a', Object('a'));
|
|
581
|
+
* // => false
|
|
582
|
+
*
|
|
583
|
+
* _.eq(NaN, NaN);
|
|
584
|
+
* // => true
|
|
585
|
+
*/
|
|
586
|
+
function eq(value, other) {
|
|
587
|
+
return value === other || (value !== value && other !== other);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/** Used as references for various `Number` constants. */
|
|
591
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Checks if `value` is a valid array-like length.
|
|
595
|
+
*
|
|
596
|
+
* **Note:** This method is loosely based on
|
|
597
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
598
|
+
*
|
|
599
|
+
* @static
|
|
600
|
+
* @memberOf _
|
|
601
|
+
* @since 4.0.0
|
|
602
|
+
* @category Lang
|
|
603
|
+
* @param {*} value The value to check.
|
|
604
|
+
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
605
|
+
* @example
|
|
606
|
+
*
|
|
607
|
+
* _.isLength(3);
|
|
608
|
+
* // => true
|
|
609
|
+
*
|
|
610
|
+
* _.isLength(Number.MIN_VALUE);
|
|
611
|
+
* // => false
|
|
612
|
+
*
|
|
613
|
+
* _.isLength(Infinity);
|
|
614
|
+
* // => false
|
|
615
|
+
*
|
|
616
|
+
* _.isLength('3');
|
|
617
|
+
* // => false
|
|
618
|
+
*/
|
|
619
|
+
function isLength(value) {
|
|
620
|
+
return typeof value == 'number' &&
|
|
621
|
+
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
626
|
+
* not a function and has a `value.length` that's an integer greater than or
|
|
627
|
+
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
628
|
+
*
|
|
629
|
+
* @static
|
|
630
|
+
* @memberOf _
|
|
631
|
+
* @since 4.0.0
|
|
632
|
+
* @category Lang
|
|
633
|
+
* @param {*} value The value to check.
|
|
634
|
+
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
635
|
+
* @example
|
|
636
|
+
*
|
|
637
|
+
* _.isArrayLike([1, 2, 3]);
|
|
638
|
+
* // => true
|
|
639
|
+
*
|
|
640
|
+
* _.isArrayLike(document.body.children);
|
|
641
|
+
* // => true
|
|
642
|
+
*
|
|
643
|
+
* _.isArrayLike('abc');
|
|
644
|
+
* // => true
|
|
645
|
+
*
|
|
646
|
+
* _.isArrayLike(_.noop);
|
|
647
|
+
* // => false
|
|
648
|
+
*/
|
|
649
|
+
function isArrayLike(value) {
|
|
650
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/** Used for built-in method references. */
|
|
654
|
+
var objectProto$8 = Object.prototype;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Checks if `value` is likely a prototype object.
|
|
658
|
+
*
|
|
659
|
+
* @private
|
|
660
|
+
* @param {*} value The value to check.
|
|
661
|
+
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
662
|
+
*/
|
|
663
|
+
function isPrototype(value) {
|
|
664
|
+
var Ctor = value && value.constructor,
|
|
665
|
+
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
|
|
666
|
+
|
|
667
|
+
return value === proto;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* The base implementation of `_.times` without support for iteratee shorthands
|
|
672
|
+
* or max array length checks.
|
|
673
|
+
*
|
|
674
|
+
* @private
|
|
675
|
+
* @param {number} n The number of times to invoke `iteratee`.
|
|
676
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
677
|
+
* @returns {Array} Returns the array of results.
|
|
678
|
+
*/
|
|
679
|
+
function baseTimes(n, iteratee) {
|
|
680
|
+
var index = -1,
|
|
681
|
+
result = Array(n);
|
|
682
|
+
|
|
683
|
+
while (++index < n) {
|
|
684
|
+
result[index] = iteratee(index);
|
|
685
|
+
}
|
|
686
|
+
return result;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/** `Object#toString` result references. */
|
|
690
|
+
var argsTag$2 = '[object Arguments]';
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* The base implementation of `_.isArguments`.
|
|
694
|
+
*
|
|
695
|
+
* @private
|
|
696
|
+
* @param {*} value The value to check.
|
|
697
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
698
|
+
*/
|
|
699
|
+
function baseIsArguments(value) {
|
|
700
|
+
return isObjectLike(value) && baseGetTag(value) == argsTag$2;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/** Used for built-in method references. */
|
|
704
|
+
var objectProto$7 = Object.prototype;
|
|
705
|
+
|
|
706
|
+
/** Used to check objects for own properties. */
|
|
707
|
+
var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
|
|
708
|
+
|
|
709
|
+
/** Built-in value references. */
|
|
710
|
+
var propertyIsEnumerable$1 = objectProto$7.propertyIsEnumerable;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Checks if `value` is likely an `arguments` object.
|
|
714
|
+
*
|
|
715
|
+
* @static
|
|
716
|
+
* @memberOf _
|
|
717
|
+
* @since 0.1.0
|
|
718
|
+
* @category Lang
|
|
719
|
+
* @param {*} value The value to check.
|
|
720
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
721
|
+
* else `false`.
|
|
722
|
+
* @example
|
|
723
|
+
*
|
|
724
|
+
* _.isArguments(function() { return arguments; }());
|
|
725
|
+
* // => true
|
|
726
|
+
*
|
|
727
|
+
* _.isArguments([1, 2, 3]);
|
|
728
|
+
* // => false
|
|
729
|
+
*/
|
|
730
|
+
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
731
|
+
return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') &&
|
|
732
|
+
!propertyIsEnumerable$1.call(value, 'callee');
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* This method returns `false`.
|
|
737
|
+
*
|
|
738
|
+
* @static
|
|
739
|
+
* @memberOf _
|
|
740
|
+
* @since 4.13.0
|
|
741
|
+
* @category Util
|
|
742
|
+
* @returns {boolean} Returns `false`.
|
|
743
|
+
* @example
|
|
744
|
+
*
|
|
745
|
+
* _.times(2, _.stubFalse);
|
|
746
|
+
* // => [false, false]
|
|
747
|
+
*/
|
|
748
|
+
function stubFalse() {
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/** Detect free variable `exports`. */
|
|
753
|
+
var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
754
|
+
|
|
755
|
+
/** Detect free variable `module`. */
|
|
756
|
+
var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
|
|
757
|
+
|
|
758
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
759
|
+
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
|
|
760
|
+
|
|
761
|
+
/** Built-in value references. */
|
|
762
|
+
var Buffer = moduleExports$1 ? root.Buffer : undefined;
|
|
763
|
+
|
|
764
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
765
|
+
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Checks if `value` is a buffer.
|
|
769
|
+
*
|
|
770
|
+
* @static
|
|
771
|
+
* @memberOf _
|
|
772
|
+
* @since 4.3.0
|
|
773
|
+
* @category Lang
|
|
774
|
+
* @param {*} value The value to check.
|
|
775
|
+
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
776
|
+
* @example
|
|
777
|
+
*
|
|
778
|
+
* _.isBuffer(new Buffer(2));
|
|
779
|
+
* // => true
|
|
780
|
+
*
|
|
781
|
+
* _.isBuffer(new Uint8Array(2));
|
|
782
|
+
* // => false
|
|
783
|
+
*/
|
|
784
|
+
var isBuffer = nativeIsBuffer || stubFalse;
|
|
785
|
+
|
|
786
|
+
/** `Object#toString` result references. */
|
|
787
|
+
var argsTag$1 = '[object Arguments]',
|
|
788
|
+
arrayTag$1 = '[object Array]',
|
|
789
|
+
boolTag$1 = '[object Boolean]',
|
|
790
|
+
dateTag$1 = '[object Date]',
|
|
791
|
+
errorTag$1 = '[object Error]',
|
|
792
|
+
funcTag = '[object Function]',
|
|
793
|
+
mapTag$2 = '[object Map]',
|
|
794
|
+
numberTag$1 = '[object Number]',
|
|
795
|
+
objectTag$2 = '[object Object]',
|
|
796
|
+
regexpTag$1 = '[object RegExp]',
|
|
797
|
+
setTag$2 = '[object Set]',
|
|
798
|
+
stringTag$1 = '[object String]',
|
|
799
|
+
weakMapTag$1 = '[object WeakMap]';
|
|
800
|
+
|
|
801
|
+
var arrayBufferTag$1 = '[object ArrayBuffer]',
|
|
802
|
+
dataViewTag$2 = '[object DataView]',
|
|
803
|
+
float32Tag = '[object Float32Array]',
|
|
804
|
+
float64Tag = '[object Float64Array]',
|
|
805
|
+
int8Tag = '[object Int8Array]',
|
|
806
|
+
int16Tag = '[object Int16Array]',
|
|
807
|
+
int32Tag = '[object Int32Array]',
|
|
808
|
+
uint8Tag = '[object Uint8Array]',
|
|
809
|
+
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
810
|
+
uint16Tag = '[object Uint16Array]',
|
|
811
|
+
uint32Tag = '[object Uint32Array]';
|
|
812
|
+
|
|
813
|
+
/** Used to identify `toStringTag` values of typed arrays. */
|
|
814
|
+
var typedArrayTags = {};
|
|
815
|
+
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
816
|
+
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
817
|
+
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
818
|
+
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
819
|
+
typedArrayTags[uint32Tag] = true;
|
|
820
|
+
typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
|
|
821
|
+
typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
|
|
822
|
+
typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] =
|
|
823
|
+
typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
|
|
824
|
+
typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] =
|
|
825
|
+
typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] =
|
|
826
|
+
typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] =
|
|
827
|
+
typedArrayTags[weakMapTag$1] = false;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
831
|
+
*
|
|
832
|
+
* @private
|
|
833
|
+
* @param {*} value The value to check.
|
|
834
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
835
|
+
*/
|
|
836
|
+
function baseIsTypedArray(value) {
|
|
837
|
+
return isObjectLike(value) &&
|
|
838
|
+
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* The base implementation of `_.unary` without support for storing metadata.
|
|
843
|
+
*
|
|
844
|
+
* @private
|
|
845
|
+
* @param {Function} func The function to cap arguments for.
|
|
846
|
+
* @returns {Function} Returns the new capped function.
|
|
847
|
+
*/
|
|
848
|
+
function baseUnary(func) {
|
|
849
|
+
return function(value) {
|
|
850
|
+
return func(value);
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/** Detect free variable `exports`. */
|
|
855
|
+
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
856
|
+
|
|
857
|
+
/** Detect free variable `module`. */
|
|
858
|
+
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
|
859
|
+
|
|
860
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
861
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
862
|
+
|
|
863
|
+
/** Detect free variable `process` from Node.js. */
|
|
864
|
+
var freeProcess = moduleExports && freeGlobal.process;
|
|
865
|
+
|
|
866
|
+
/** Used to access faster Node.js helpers. */
|
|
867
|
+
var nodeUtil = (function() {
|
|
868
|
+
try {
|
|
869
|
+
// Use `util.types` for Node.js 10+.
|
|
870
|
+
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
871
|
+
|
|
872
|
+
if (types) {
|
|
873
|
+
return types;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// Legacy `process.binding('util')` for Node.js < 10.
|
|
877
|
+
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
878
|
+
} catch (e) {}
|
|
879
|
+
}());
|
|
880
|
+
|
|
881
|
+
/* Node.js helper references. */
|
|
882
|
+
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Checks if `value` is classified as a typed array.
|
|
886
|
+
*
|
|
887
|
+
* @static
|
|
888
|
+
* @memberOf _
|
|
889
|
+
* @since 3.0.0
|
|
890
|
+
* @category Lang
|
|
891
|
+
* @param {*} value The value to check.
|
|
892
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
893
|
+
* @example
|
|
894
|
+
*
|
|
895
|
+
* _.isTypedArray(new Uint8Array);
|
|
896
|
+
* // => true
|
|
897
|
+
*
|
|
898
|
+
* _.isTypedArray([]);
|
|
899
|
+
* // => false
|
|
900
|
+
*/
|
|
901
|
+
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
902
|
+
|
|
903
|
+
/** Used for built-in method references. */
|
|
904
|
+
var objectProto$6 = Object.prototype;
|
|
905
|
+
|
|
906
|
+
/** Used to check objects for own properties. */
|
|
907
|
+
var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Creates an array of the enumerable property names of the array-like `value`.
|
|
911
|
+
*
|
|
912
|
+
* @private
|
|
913
|
+
* @param {*} value The value to query.
|
|
914
|
+
* @param {boolean} inherited Specify returning inherited property names.
|
|
915
|
+
* @returns {Array} Returns the array of property names.
|
|
916
|
+
*/
|
|
917
|
+
function arrayLikeKeys(value, inherited) {
|
|
918
|
+
var isArr = isArray(value),
|
|
919
|
+
isArg = !isArr && isArguments(value),
|
|
920
|
+
isBuff = !isArr && !isArg && isBuffer(value),
|
|
921
|
+
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
|
922
|
+
skipIndexes = isArr || isArg || isBuff || isType,
|
|
923
|
+
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
924
|
+
length = result.length;
|
|
925
|
+
|
|
926
|
+
for (var key in value) {
|
|
927
|
+
if ((inherited || hasOwnProperty$5.call(value, key)) &&
|
|
928
|
+
!(skipIndexes && (
|
|
929
|
+
// Safari 9 has enumerable `arguments.length` in strict mode.
|
|
930
|
+
key == 'length' ||
|
|
931
|
+
// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
932
|
+
(isBuff && (key == 'offset' || key == 'parent')) ||
|
|
933
|
+
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
934
|
+
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
|
935
|
+
// Skip index properties.
|
|
936
|
+
isIndex(key, length)
|
|
937
|
+
))) {
|
|
938
|
+
result.push(key);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
return result;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Creates a unary function that invokes `func` with its argument transformed.
|
|
946
|
+
*
|
|
947
|
+
* @private
|
|
948
|
+
* @param {Function} func The function to wrap.
|
|
949
|
+
* @param {Function} transform The argument transform.
|
|
950
|
+
* @returns {Function} Returns the new function.
|
|
951
|
+
*/
|
|
952
|
+
function overArg(func, transform) {
|
|
953
|
+
return function(arg) {
|
|
954
|
+
return func(transform(arg));
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
959
|
+
var nativeKeys = overArg(Object.keys, Object);
|
|
960
|
+
|
|
961
|
+
/** Used for built-in method references. */
|
|
962
|
+
var objectProto$5 = Object.prototype;
|
|
963
|
+
|
|
964
|
+
/** Used to check objects for own properties. */
|
|
965
|
+
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|
969
|
+
*
|
|
970
|
+
* @private
|
|
971
|
+
* @param {Object} object The object to query.
|
|
972
|
+
* @returns {Array} Returns the array of property names.
|
|
973
|
+
*/
|
|
974
|
+
function baseKeys(object) {
|
|
975
|
+
if (!isPrototype(object)) {
|
|
976
|
+
return nativeKeys(object);
|
|
977
|
+
}
|
|
978
|
+
var result = [];
|
|
979
|
+
for (var key in Object(object)) {
|
|
980
|
+
if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
|
|
981
|
+
result.push(key);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
return result;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* Creates an array of the own enumerable property names of `object`.
|
|
989
|
+
*
|
|
990
|
+
* **Note:** Non-object values are coerced to objects. See the
|
|
991
|
+
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|
992
|
+
* for more details.
|
|
993
|
+
*
|
|
994
|
+
* @static
|
|
995
|
+
* @since 0.1.0
|
|
996
|
+
* @memberOf _
|
|
997
|
+
* @category Object
|
|
998
|
+
* @param {Object} object The object to query.
|
|
999
|
+
* @returns {Array} Returns the array of property names.
|
|
1000
|
+
* @example
|
|
1001
|
+
*
|
|
1002
|
+
* function Foo() {
|
|
1003
|
+
* this.a = 1;
|
|
1004
|
+
* this.b = 2;
|
|
1005
|
+
* }
|
|
1006
|
+
*
|
|
1007
|
+
* Foo.prototype.c = 3;
|
|
1008
|
+
*
|
|
1009
|
+
* _.keys(new Foo);
|
|
1010
|
+
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|
1011
|
+
*
|
|
1012
|
+
* _.keys('hi');
|
|
1013
|
+
* // => ['0', '1']
|
|
1014
|
+
*/
|
|
1015
|
+
function keys(object) {
|
|
1016
|
+
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/* Built-in method references that are verified to be native. */
|
|
1020
|
+
var nativeCreate = getNative(Object, 'create');
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Removes all key-value entries from the hash.
|
|
1024
|
+
*
|
|
1025
|
+
* @private
|
|
1026
|
+
* @name clear
|
|
1027
|
+
* @memberOf Hash
|
|
1028
|
+
*/
|
|
1029
|
+
function hashClear() {
|
|
1030
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
1031
|
+
this.size = 0;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* Removes `key` and its value from the hash.
|
|
1036
|
+
*
|
|
1037
|
+
* @private
|
|
1038
|
+
* @name delete
|
|
1039
|
+
* @memberOf Hash
|
|
1040
|
+
* @param {Object} hash The hash to modify.
|
|
1041
|
+
* @param {string} key The key of the value to remove.
|
|
1042
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1043
|
+
*/
|
|
1044
|
+
function hashDelete(key) {
|
|
1045
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
1046
|
+
this.size -= result ? 1 : 0;
|
|
1047
|
+
return result;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
1051
|
+
var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
|
|
1052
|
+
|
|
1053
|
+
/** Used for built-in method references. */
|
|
1054
|
+
var objectProto$4 = Object.prototype;
|
|
1055
|
+
|
|
1056
|
+
/** Used to check objects for own properties. */
|
|
1057
|
+
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Gets the hash value for `key`.
|
|
1061
|
+
*
|
|
1062
|
+
* @private
|
|
1063
|
+
* @name get
|
|
1064
|
+
* @memberOf Hash
|
|
1065
|
+
* @param {string} key The key of the value to get.
|
|
1066
|
+
* @returns {*} Returns the entry value.
|
|
1067
|
+
*/
|
|
1068
|
+
function hashGet(key) {
|
|
1069
|
+
var data = this.__data__;
|
|
1070
|
+
if (nativeCreate) {
|
|
1071
|
+
var result = data[key];
|
|
1072
|
+
return result === HASH_UNDEFINED$2 ? undefined : result;
|
|
1073
|
+
}
|
|
1074
|
+
return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/** Used for built-in method references. */
|
|
1078
|
+
var objectProto$3 = Object.prototype;
|
|
1079
|
+
|
|
1080
|
+
/** Used to check objects for own properties. */
|
|
1081
|
+
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* Checks if a hash value for `key` exists.
|
|
1085
|
+
*
|
|
1086
|
+
* @private
|
|
1087
|
+
* @name has
|
|
1088
|
+
* @memberOf Hash
|
|
1089
|
+
* @param {string} key The key of the entry to check.
|
|
1090
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1091
|
+
*/
|
|
1092
|
+
function hashHas(key) {
|
|
1093
|
+
var data = this.__data__;
|
|
1094
|
+
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$2.call(data, key);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
1098
|
+
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Sets the hash `key` to `value`.
|
|
1102
|
+
*
|
|
1103
|
+
* @private
|
|
1104
|
+
* @name set
|
|
1105
|
+
* @memberOf Hash
|
|
1106
|
+
* @param {string} key The key of the value to set.
|
|
1107
|
+
* @param {*} value The value to set.
|
|
1108
|
+
* @returns {Object} Returns the hash instance.
|
|
1109
|
+
*/
|
|
1110
|
+
function hashSet(key, value) {
|
|
1111
|
+
var data = this.__data__;
|
|
1112
|
+
this.size += this.has(key) ? 0 : 1;
|
|
1113
|
+
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
|
|
1114
|
+
return this;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Creates a hash object.
|
|
1119
|
+
*
|
|
1120
|
+
* @private
|
|
1121
|
+
* @constructor
|
|
1122
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1123
|
+
*/
|
|
1124
|
+
function Hash(entries) {
|
|
1125
|
+
var index = -1,
|
|
1126
|
+
length = entries == null ? 0 : entries.length;
|
|
1127
|
+
|
|
1128
|
+
this.clear();
|
|
1129
|
+
while (++index < length) {
|
|
1130
|
+
var entry = entries[index];
|
|
1131
|
+
this.set(entry[0], entry[1]);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
// Add methods to `Hash`.
|
|
1136
|
+
Hash.prototype.clear = hashClear;
|
|
1137
|
+
Hash.prototype['delete'] = hashDelete;
|
|
1138
|
+
Hash.prototype.get = hashGet;
|
|
1139
|
+
Hash.prototype.has = hashHas;
|
|
1140
|
+
Hash.prototype.set = hashSet;
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* Removes all key-value entries from the list cache.
|
|
1144
|
+
*
|
|
1145
|
+
* @private
|
|
1146
|
+
* @name clear
|
|
1147
|
+
* @memberOf ListCache
|
|
1148
|
+
*/
|
|
1149
|
+
function listCacheClear() {
|
|
1150
|
+
this.__data__ = [];
|
|
1151
|
+
this.size = 0;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
1156
|
+
*
|
|
1157
|
+
* @private
|
|
1158
|
+
* @param {Array} array The array to inspect.
|
|
1159
|
+
* @param {*} key The key to search for.
|
|
1160
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
1161
|
+
*/
|
|
1162
|
+
function assocIndexOf(array, key) {
|
|
1163
|
+
var length = array.length;
|
|
1164
|
+
while (length--) {
|
|
1165
|
+
if (eq(array[length][0], key)) {
|
|
1166
|
+
return length;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
return -1;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
/** Used for built-in method references. */
|
|
1173
|
+
var arrayProto = Array.prototype;
|
|
1174
|
+
|
|
1175
|
+
/** Built-in value references. */
|
|
1176
|
+
var splice = arrayProto.splice;
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Removes `key` and its value from the list cache.
|
|
1180
|
+
*
|
|
1181
|
+
* @private
|
|
1182
|
+
* @name delete
|
|
1183
|
+
* @memberOf ListCache
|
|
1184
|
+
* @param {string} key The key of the value to remove.
|
|
1185
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1186
|
+
*/
|
|
1187
|
+
function listCacheDelete(key) {
|
|
1188
|
+
var data = this.__data__,
|
|
1189
|
+
index = assocIndexOf(data, key);
|
|
1190
|
+
|
|
1191
|
+
if (index < 0) {
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
var lastIndex = data.length - 1;
|
|
1195
|
+
if (index == lastIndex) {
|
|
1196
|
+
data.pop();
|
|
1197
|
+
} else {
|
|
1198
|
+
splice.call(data, index, 1);
|
|
1199
|
+
}
|
|
1200
|
+
--this.size;
|
|
1201
|
+
return true;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* Gets the list cache value for `key`.
|
|
1206
|
+
*
|
|
1207
|
+
* @private
|
|
1208
|
+
* @name get
|
|
1209
|
+
* @memberOf ListCache
|
|
1210
|
+
* @param {string} key The key of the value to get.
|
|
1211
|
+
* @returns {*} Returns the entry value.
|
|
1212
|
+
*/
|
|
1213
|
+
function listCacheGet(key) {
|
|
1214
|
+
var data = this.__data__,
|
|
1215
|
+
index = assocIndexOf(data, key);
|
|
1216
|
+
|
|
1217
|
+
return index < 0 ? undefined : data[index][1];
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Checks if a list cache value for `key` exists.
|
|
1222
|
+
*
|
|
1223
|
+
* @private
|
|
1224
|
+
* @name has
|
|
1225
|
+
* @memberOf ListCache
|
|
1226
|
+
* @param {string} key The key of the entry to check.
|
|
1227
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1228
|
+
*/
|
|
1229
|
+
function listCacheHas(key) {
|
|
1230
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Sets the list cache `key` to `value`.
|
|
1235
|
+
*
|
|
1236
|
+
* @private
|
|
1237
|
+
* @name set
|
|
1238
|
+
* @memberOf ListCache
|
|
1239
|
+
* @param {string} key The key of the value to set.
|
|
1240
|
+
* @param {*} value The value to set.
|
|
1241
|
+
* @returns {Object} Returns the list cache instance.
|
|
1242
|
+
*/
|
|
1243
|
+
function listCacheSet(key, value) {
|
|
1244
|
+
var data = this.__data__,
|
|
1245
|
+
index = assocIndexOf(data, key);
|
|
1246
|
+
|
|
1247
|
+
if (index < 0) {
|
|
1248
|
+
++this.size;
|
|
1249
|
+
data.push([key, value]);
|
|
1250
|
+
} else {
|
|
1251
|
+
data[index][1] = value;
|
|
1252
|
+
}
|
|
1253
|
+
return this;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* Creates an list cache object.
|
|
1258
|
+
*
|
|
1259
|
+
* @private
|
|
1260
|
+
* @constructor
|
|
1261
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1262
|
+
*/
|
|
1263
|
+
function ListCache(entries) {
|
|
1264
|
+
var index = -1,
|
|
1265
|
+
length = entries == null ? 0 : entries.length;
|
|
1266
|
+
|
|
1267
|
+
this.clear();
|
|
1268
|
+
while (++index < length) {
|
|
1269
|
+
var entry = entries[index];
|
|
1270
|
+
this.set(entry[0], entry[1]);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
// Add methods to `ListCache`.
|
|
1275
|
+
ListCache.prototype.clear = listCacheClear;
|
|
1276
|
+
ListCache.prototype['delete'] = listCacheDelete;
|
|
1277
|
+
ListCache.prototype.get = listCacheGet;
|
|
1278
|
+
ListCache.prototype.has = listCacheHas;
|
|
1279
|
+
ListCache.prototype.set = listCacheSet;
|
|
1280
|
+
|
|
1281
|
+
/* Built-in method references that are verified to be native. */
|
|
1282
|
+
var Map$1 = getNative(root, 'Map');
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Removes all key-value entries from the map.
|
|
1286
|
+
*
|
|
1287
|
+
* @private
|
|
1288
|
+
* @name clear
|
|
1289
|
+
* @memberOf MapCache
|
|
1290
|
+
*/
|
|
1291
|
+
function mapCacheClear() {
|
|
1292
|
+
this.size = 0;
|
|
1293
|
+
this.__data__ = {
|
|
1294
|
+
'hash': new Hash,
|
|
1295
|
+
'map': new (Map$1 || ListCache),
|
|
1296
|
+
'string': new Hash
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
1302
|
+
*
|
|
1303
|
+
* @private
|
|
1304
|
+
* @param {*} value The value to check.
|
|
1305
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
1306
|
+
*/
|
|
1307
|
+
function isKeyable(value) {
|
|
1308
|
+
var type = typeof value;
|
|
1309
|
+
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
1310
|
+
? (value !== '__proto__')
|
|
1311
|
+
: (value === null);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
/**
|
|
1315
|
+
* Gets the data for `map`.
|
|
1316
|
+
*
|
|
1317
|
+
* @private
|
|
1318
|
+
* @param {Object} map The map to query.
|
|
1319
|
+
* @param {string} key The reference key.
|
|
1320
|
+
* @returns {*} Returns the map data.
|
|
1321
|
+
*/
|
|
1322
|
+
function getMapData(map, key) {
|
|
1323
|
+
var data = map.__data__;
|
|
1324
|
+
return isKeyable(key)
|
|
1325
|
+
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
1326
|
+
: data.map;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* Removes `key` and its value from the map.
|
|
1331
|
+
*
|
|
1332
|
+
* @private
|
|
1333
|
+
* @name delete
|
|
1334
|
+
* @memberOf MapCache
|
|
1335
|
+
* @param {string} key The key of the value to remove.
|
|
1336
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1337
|
+
*/
|
|
1338
|
+
function mapCacheDelete(key) {
|
|
1339
|
+
var result = getMapData(this, key)['delete'](key);
|
|
1340
|
+
this.size -= result ? 1 : 0;
|
|
1341
|
+
return result;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Gets the map value for `key`.
|
|
1346
|
+
*
|
|
1347
|
+
* @private
|
|
1348
|
+
* @name get
|
|
1349
|
+
* @memberOf MapCache
|
|
1350
|
+
* @param {string} key The key of the value to get.
|
|
1351
|
+
* @returns {*} Returns the entry value.
|
|
1352
|
+
*/
|
|
1353
|
+
function mapCacheGet(key) {
|
|
1354
|
+
return getMapData(this, key).get(key);
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* Checks if a map value for `key` exists.
|
|
1359
|
+
*
|
|
1360
|
+
* @private
|
|
1361
|
+
* @name has
|
|
1362
|
+
* @memberOf MapCache
|
|
1363
|
+
* @param {string} key The key of the entry to check.
|
|
1364
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1365
|
+
*/
|
|
1366
|
+
function mapCacheHas(key) {
|
|
1367
|
+
return getMapData(this, key).has(key);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* Sets the map `key` to `value`.
|
|
1372
|
+
*
|
|
1373
|
+
* @private
|
|
1374
|
+
* @name set
|
|
1375
|
+
* @memberOf MapCache
|
|
1376
|
+
* @param {string} key The key of the value to set.
|
|
1377
|
+
* @param {*} value The value to set.
|
|
1378
|
+
* @returns {Object} Returns the map cache instance.
|
|
1379
|
+
*/
|
|
1380
|
+
function mapCacheSet(key, value) {
|
|
1381
|
+
var data = getMapData(this, key),
|
|
1382
|
+
size = data.size;
|
|
1383
|
+
|
|
1384
|
+
data.set(key, value);
|
|
1385
|
+
this.size += data.size == size ? 0 : 1;
|
|
1386
|
+
return this;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Creates a map cache object to store key-value pairs.
|
|
1391
|
+
*
|
|
1392
|
+
* @private
|
|
1393
|
+
* @constructor
|
|
1394
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1395
|
+
*/
|
|
1396
|
+
function MapCache(entries) {
|
|
1397
|
+
var index = -1,
|
|
1398
|
+
length = entries == null ? 0 : entries.length;
|
|
1399
|
+
|
|
1400
|
+
this.clear();
|
|
1401
|
+
while (++index < length) {
|
|
1402
|
+
var entry = entries[index];
|
|
1403
|
+
this.set(entry[0], entry[1]);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
// Add methods to `MapCache`.
|
|
1408
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
1409
|
+
MapCache.prototype['delete'] = mapCacheDelete;
|
|
1410
|
+
MapCache.prototype.get = mapCacheGet;
|
|
1411
|
+
MapCache.prototype.has = mapCacheHas;
|
|
1412
|
+
MapCache.prototype.set = mapCacheSet;
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* Appends the elements of `values` to `array`.
|
|
1416
|
+
*
|
|
1417
|
+
* @private
|
|
1418
|
+
* @param {Array} array The array to modify.
|
|
1419
|
+
* @param {Array} values The values to append.
|
|
1420
|
+
* @returns {Array} Returns `array`.
|
|
1421
|
+
*/
|
|
1422
|
+
function arrayPush(array, values) {
|
|
1423
|
+
var index = -1,
|
|
1424
|
+
length = values.length,
|
|
1425
|
+
offset = array.length;
|
|
1426
|
+
|
|
1427
|
+
while (++index < length) {
|
|
1428
|
+
array[offset + index] = values[index];
|
|
1429
|
+
}
|
|
1430
|
+
return array;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* Removes all key-value entries from the stack.
|
|
1435
|
+
*
|
|
1436
|
+
* @private
|
|
1437
|
+
* @name clear
|
|
1438
|
+
* @memberOf Stack
|
|
1439
|
+
*/
|
|
1440
|
+
function stackClear() {
|
|
1441
|
+
this.__data__ = new ListCache;
|
|
1442
|
+
this.size = 0;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* Removes `key` and its value from the stack.
|
|
1447
|
+
*
|
|
1448
|
+
* @private
|
|
1449
|
+
* @name delete
|
|
1450
|
+
* @memberOf Stack
|
|
1451
|
+
* @param {string} key The key of the value to remove.
|
|
1452
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1453
|
+
*/
|
|
1454
|
+
function stackDelete(key) {
|
|
1455
|
+
var data = this.__data__,
|
|
1456
|
+
result = data['delete'](key);
|
|
1457
|
+
|
|
1458
|
+
this.size = data.size;
|
|
1459
|
+
return result;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Gets the stack value for `key`.
|
|
1464
|
+
*
|
|
1465
|
+
* @private
|
|
1466
|
+
* @name get
|
|
1467
|
+
* @memberOf Stack
|
|
1468
|
+
* @param {string} key The key of the value to get.
|
|
1469
|
+
* @returns {*} Returns the entry value.
|
|
1470
|
+
*/
|
|
1471
|
+
function stackGet(key) {
|
|
1472
|
+
return this.__data__.get(key);
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* Checks if a stack value for `key` exists.
|
|
1477
|
+
*
|
|
1478
|
+
* @private
|
|
1479
|
+
* @name has
|
|
1480
|
+
* @memberOf Stack
|
|
1481
|
+
* @param {string} key The key of the entry to check.
|
|
1482
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1483
|
+
*/
|
|
1484
|
+
function stackHas(key) {
|
|
1485
|
+
return this.__data__.has(key);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
/** Used as the size to enable large array optimizations. */
|
|
1489
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
1490
|
+
|
|
1491
|
+
/**
|
|
1492
|
+
* Sets the stack `key` to `value`.
|
|
1493
|
+
*
|
|
1494
|
+
* @private
|
|
1495
|
+
* @name set
|
|
1496
|
+
* @memberOf Stack
|
|
1497
|
+
* @param {string} key The key of the value to set.
|
|
1498
|
+
* @param {*} value The value to set.
|
|
1499
|
+
* @returns {Object} Returns the stack cache instance.
|
|
1500
|
+
*/
|
|
1501
|
+
function stackSet(key, value) {
|
|
1502
|
+
var data = this.__data__;
|
|
1503
|
+
if (data instanceof ListCache) {
|
|
1504
|
+
var pairs = data.__data__;
|
|
1505
|
+
if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
|
1506
|
+
pairs.push([key, value]);
|
|
1507
|
+
this.size = ++data.size;
|
|
1508
|
+
return this;
|
|
1509
|
+
}
|
|
1510
|
+
data = this.__data__ = new MapCache(pairs);
|
|
1511
|
+
}
|
|
1512
|
+
data.set(key, value);
|
|
1513
|
+
this.size = data.size;
|
|
1514
|
+
return this;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* Creates a stack cache object to store key-value pairs.
|
|
1519
|
+
*
|
|
1520
|
+
* @private
|
|
1521
|
+
* @constructor
|
|
1522
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1523
|
+
*/
|
|
1524
|
+
function Stack(entries) {
|
|
1525
|
+
var data = this.__data__ = new ListCache(entries);
|
|
1526
|
+
this.size = data.size;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
// Add methods to `Stack`.
|
|
1530
|
+
Stack.prototype.clear = stackClear;
|
|
1531
|
+
Stack.prototype['delete'] = stackDelete;
|
|
1532
|
+
Stack.prototype.get = stackGet;
|
|
1533
|
+
Stack.prototype.has = stackHas;
|
|
1534
|
+
Stack.prototype.set = stackSet;
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* A specialized version of `_.filter` for arrays without support for
|
|
1538
|
+
* iteratee shorthands.
|
|
1539
|
+
*
|
|
1540
|
+
* @private
|
|
1541
|
+
* @param {Array} [array] The array to iterate over.
|
|
1542
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
1543
|
+
* @returns {Array} Returns the new filtered array.
|
|
1544
|
+
*/
|
|
1545
|
+
function arrayFilter(array, predicate) {
|
|
1546
|
+
var index = -1,
|
|
1547
|
+
length = array == null ? 0 : array.length,
|
|
1548
|
+
resIndex = 0,
|
|
1549
|
+
result = [];
|
|
1550
|
+
|
|
1551
|
+
while (++index < length) {
|
|
1552
|
+
var value = array[index];
|
|
1553
|
+
if (predicate(value, index, array)) {
|
|
1554
|
+
result[resIndex++] = value;
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
return result;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* This method returns a new empty array.
|
|
1562
|
+
*
|
|
1563
|
+
* @static
|
|
1564
|
+
* @memberOf _
|
|
1565
|
+
* @since 4.13.0
|
|
1566
|
+
* @category Util
|
|
1567
|
+
* @returns {Array} Returns the new empty array.
|
|
1568
|
+
* @example
|
|
1569
|
+
*
|
|
1570
|
+
* var arrays = _.times(2, _.stubArray);
|
|
1571
|
+
*
|
|
1572
|
+
* console.log(arrays);
|
|
1573
|
+
* // => [[], []]
|
|
1574
|
+
*
|
|
1575
|
+
* console.log(arrays[0] === arrays[1]);
|
|
1576
|
+
* // => false
|
|
1577
|
+
*/
|
|
1578
|
+
function stubArray() {
|
|
1579
|
+
return [];
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
/** Used for built-in method references. */
|
|
1583
|
+
var objectProto$2 = Object.prototype;
|
|
1584
|
+
|
|
1585
|
+
/** Built-in value references. */
|
|
1586
|
+
var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
|
|
1587
|
+
|
|
1588
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
1589
|
+
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
1590
|
+
|
|
1591
|
+
/**
|
|
1592
|
+
* Creates an array of the own enumerable symbols of `object`.
|
|
1593
|
+
*
|
|
1594
|
+
* @private
|
|
1595
|
+
* @param {Object} object The object to query.
|
|
1596
|
+
* @returns {Array} Returns the array of symbols.
|
|
1597
|
+
*/
|
|
1598
|
+
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
|
|
1599
|
+
if (object == null) {
|
|
1600
|
+
return [];
|
|
1601
|
+
}
|
|
1602
|
+
object = Object(object);
|
|
1603
|
+
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
|
1604
|
+
return propertyIsEnumerable.call(object, symbol);
|
|
1605
|
+
});
|
|
1606
|
+
};
|
|
1607
|
+
|
|
1608
|
+
/**
|
|
1609
|
+
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
|
1610
|
+
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
|
1611
|
+
* symbols of `object`.
|
|
1612
|
+
*
|
|
1613
|
+
* @private
|
|
1614
|
+
* @param {Object} object The object to query.
|
|
1615
|
+
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
1616
|
+
* @param {Function} symbolsFunc The function to get the symbols of `object`.
|
|
1617
|
+
* @returns {Array} Returns the array of property names and symbols.
|
|
1618
|
+
*/
|
|
1619
|
+
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
1620
|
+
var result = keysFunc(object);
|
|
1621
|
+
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* Creates an array of own enumerable property names and symbols of `object`.
|
|
1626
|
+
*
|
|
1627
|
+
* @private
|
|
1628
|
+
* @param {Object} object The object to query.
|
|
1629
|
+
* @returns {Array} Returns the array of property names and symbols.
|
|
1630
|
+
*/
|
|
1631
|
+
function getAllKeys(object) {
|
|
1632
|
+
return baseGetAllKeys(object, keys, getSymbols);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
/* Built-in method references that are verified to be native. */
|
|
1636
|
+
var DataView = getNative(root, 'DataView');
|
|
1637
|
+
|
|
1638
|
+
/* Built-in method references that are verified to be native. */
|
|
1639
|
+
var Promise$1 = getNative(root, 'Promise');
|
|
1640
|
+
|
|
1641
|
+
/* Built-in method references that are verified to be native. */
|
|
1642
|
+
var Set$1 = getNative(root, 'Set');
|
|
1643
|
+
|
|
1644
|
+
/** `Object#toString` result references. */
|
|
1645
|
+
var mapTag$1 = '[object Map]',
|
|
1646
|
+
objectTag$1 = '[object Object]',
|
|
1647
|
+
promiseTag = '[object Promise]',
|
|
1648
|
+
setTag$1 = '[object Set]',
|
|
1649
|
+
weakMapTag = '[object WeakMap]';
|
|
1650
|
+
|
|
1651
|
+
var dataViewTag$1 = '[object DataView]';
|
|
1652
|
+
|
|
1653
|
+
/** Used to detect maps, sets, and weakmaps. */
|
|
1654
|
+
var dataViewCtorString = toSource(DataView),
|
|
1655
|
+
mapCtorString = toSource(Map$1),
|
|
1656
|
+
promiseCtorString = toSource(Promise$1),
|
|
1657
|
+
setCtorString = toSource(Set$1),
|
|
1658
|
+
weakMapCtorString = toSource(WeakMap);
|
|
1659
|
+
|
|
1660
|
+
/**
|
|
1661
|
+
* Gets the `toStringTag` of `value`.
|
|
1662
|
+
*
|
|
1663
|
+
* @private
|
|
1664
|
+
* @param {*} value The value to query.
|
|
1665
|
+
* @returns {string} Returns the `toStringTag`.
|
|
1666
|
+
*/
|
|
1667
|
+
var getTag = baseGetTag;
|
|
1668
|
+
|
|
1669
|
+
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
1670
|
+
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
|
|
1671
|
+
(Map$1 && getTag(new Map$1) != mapTag$1) ||
|
|
1672
|
+
(Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
|
|
1673
|
+
(Set$1 && getTag(new Set$1) != setTag$1) ||
|
|
1674
|
+
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
|
1675
|
+
getTag = function(value) {
|
|
1676
|
+
var result = baseGetTag(value),
|
|
1677
|
+
Ctor = result == objectTag$1 ? value.constructor : undefined,
|
|
1678
|
+
ctorString = Ctor ? toSource(Ctor) : '';
|
|
1679
|
+
|
|
1680
|
+
if (ctorString) {
|
|
1681
|
+
switch (ctorString) {
|
|
1682
|
+
case dataViewCtorString: return dataViewTag$1;
|
|
1683
|
+
case mapCtorString: return mapTag$1;
|
|
1684
|
+
case promiseCtorString: return promiseTag;
|
|
1685
|
+
case setCtorString: return setTag$1;
|
|
1686
|
+
case weakMapCtorString: return weakMapTag;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
return result;
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
var getTag$1 = getTag;
|
|
1694
|
+
|
|
1695
|
+
/** Built-in value references. */
|
|
1696
|
+
var Uint8Array = root.Uint8Array;
|
|
1697
|
+
|
|
1698
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
1699
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* Adds `value` to the array cache.
|
|
1703
|
+
*
|
|
1704
|
+
* @private
|
|
1705
|
+
* @name add
|
|
1706
|
+
* @memberOf SetCache
|
|
1707
|
+
* @alias push
|
|
1708
|
+
* @param {*} value The value to cache.
|
|
1709
|
+
* @returns {Object} Returns the cache instance.
|
|
1710
|
+
*/
|
|
1711
|
+
function setCacheAdd(value) {
|
|
1712
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
1713
|
+
return this;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Checks if `value` is in the array cache.
|
|
1718
|
+
*
|
|
1719
|
+
* @private
|
|
1720
|
+
* @name has
|
|
1721
|
+
* @memberOf SetCache
|
|
1722
|
+
* @param {*} value The value to search for.
|
|
1723
|
+
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|
1724
|
+
*/
|
|
1725
|
+
function setCacheHas(value) {
|
|
1726
|
+
return this.__data__.has(value);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
/**
|
|
1730
|
+
*
|
|
1731
|
+
* Creates an array cache object to store unique values.
|
|
1732
|
+
*
|
|
1733
|
+
* @private
|
|
1734
|
+
* @constructor
|
|
1735
|
+
* @param {Array} [values] The values to cache.
|
|
1736
|
+
*/
|
|
1737
|
+
function SetCache(values) {
|
|
1738
|
+
var index = -1,
|
|
1739
|
+
length = values == null ? 0 : values.length;
|
|
1740
|
+
|
|
1741
|
+
this.__data__ = new MapCache;
|
|
1742
|
+
while (++index < length) {
|
|
1743
|
+
this.add(values[index]);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
// Add methods to `SetCache`.
|
|
1748
|
+
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
1749
|
+
SetCache.prototype.has = setCacheHas;
|
|
1750
|
+
|
|
1751
|
+
/**
|
|
1752
|
+
* A specialized version of `_.some` for arrays without support for iteratee
|
|
1753
|
+
* shorthands.
|
|
1754
|
+
*
|
|
1755
|
+
* @private
|
|
1756
|
+
* @param {Array} [array] The array to iterate over.
|
|
1757
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
1758
|
+
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
1759
|
+
* else `false`.
|
|
1760
|
+
*/
|
|
1761
|
+
function arraySome(array, predicate) {
|
|
1762
|
+
var index = -1,
|
|
1763
|
+
length = array == null ? 0 : array.length;
|
|
1764
|
+
|
|
1765
|
+
while (++index < length) {
|
|
1766
|
+
if (predicate(array[index], index, array)) {
|
|
1767
|
+
return true;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
return false;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
/**
|
|
1774
|
+
* Checks if a `cache` value for `key` exists.
|
|
1775
|
+
*
|
|
1776
|
+
* @private
|
|
1777
|
+
* @param {Object} cache The cache to query.
|
|
1778
|
+
* @param {string} key The key of the entry to check.
|
|
1779
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1780
|
+
*/
|
|
1781
|
+
function cacheHas(cache, key) {
|
|
1782
|
+
return cache.has(key);
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
1786
|
+
var COMPARE_PARTIAL_FLAG$3 = 1,
|
|
1787
|
+
COMPARE_UNORDERED_FLAG$1 = 2;
|
|
1788
|
+
|
|
1789
|
+
/**
|
|
1790
|
+
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
1791
|
+
* partial deep comparisons.
|
|
1792
|
+
*
|
|
1793
|
+
* @private
|
|
1794
|
+
* @param {Array} array The array to compare.
|
|
1795
|
+
* @param {Array} other The other array to compare.
|
|
1796
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1797
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1798
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1799
|
+
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
|
1800
|
+
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
1801
|
+
*/
|
|
1802
|
+
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
1803
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
|
|
1804
|
+
arrLength = array.length,
|
|
1805
|
+
othLength = other.length;
|
|
1806
|
+
|
|
1807
|
+
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
1808
|
+
return false;
|
|
1809
|
+
}
|
|
1810
|
+
// Check that cyclic values are equal.
|
|
1811
|
+
var arrStacked = stack.get(array);
|
|
1812
|
+
var othStacked = stack.get(other);
|
|
1813
|
+
if (arrStacked && othStacked) {
|
|
1814
|
+
return arrStacked == other && othStacked == array;
|
|
1815
|
+
}
|
|
1816
|
+
var index = -1,
|
|
1817
|
+
result = true,
|
|
1818
|
+
seen = (bitmask & COMPARE_UNORDERED_FLAG$1) ? new SetCache : undefined;
|
|
1819
|
+
|
|
1820
|
+
stack.set(array, other);
|
|
1821
|
+
stack.set(other, array);
|
|
1822
|
+
|
|
1823
|
+
// Ignore non-index properties.
|
|
1824
|
+
while (++index < arrLength) {
|
|
1825
|
+
var arrValue = array[index],
|
|
1826
|
+
othValue = other[index];
|
|
1827
|
+
|
|
1828
|
+
if (customizer) {
|
|
1829
|
+
var compared = isPartial
|
|
1830
|
+
? customizer(othValue, arrValue, index, other, array, stack)
|
|
1831
|
+
: customizer(arrValue, othValue, index, array, other, stack);
|
|
1832
|
+
}
|
|
1833
|
+
if (compared !== undefined) {
|
|
1834
|
+
if (compared) {
|
|
1835
|
+
continue;
|
|
1836
|
+
}
|
|
1837
|
+
result = false;
|
|
1838
|
+
break;
|
|
1839
|
+
}
|
|
1840
|
+
// Recursively compare arrays (susceptible to call stack limits).
|
|
1841
|
+
if (seen) {
|
|
1842
|
+
if (!arraySome(other, function(othValue, othIndex) {
|
|
1843
|
+
if (!cacheHas(seen, othIndex) &&
|
|
1844
|
+
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
|
1845
|
+
return seen.push(othIndex);
|
|
1846
|
+
}
|
|
1847
|
+
})) {
|
|
1848
|
+
result = false;
|
|
1849
|
+
break;
|
|
1850
|
+
}
|
|
1851
|
+
} else if (!(
|
|
1852
|
+
arrValue === othValue ||
|
|
1853
|
+
equalFunc(arrValue, othValue, bitmask, customizer, stack)
|
|
1854
|
+
)) {
|
|
1855
|
+
result = false;
|
|
1856
|
+
break;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
stack['delete'](array);
|
|
1860
|
+
stack['delete'](other);
|
|
1861
|
+
return result;
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
/**
|
|
1865
|
+
* Converts `map` to its key-value pairs.
|
|
1866
|
+
*
|
|
1867
|
+
* @private
|
|
1868
|
+
* @param {Object} map The map to convert.
|
|
1869
|
+
* @returns {Array} Returns the key-value pairs.
|
|
1870
|
+
*/
|
|
1871
|
+
function mapToArray(map) {
|
|
1872
|
+
var index = -1,
|
|
1873
|
+
result = Array(map.size);
|
|
1874
|
+
|
|
1875
|
+
map.forEach(function(value, key) {
|
|
1876
|
+
result[++index] = [key, value];
|
|
1877
|
+
});
|
|
1878
|
+
return result;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* Converts `set` to an array of its values.
|
|
1883
|
+
*
|
|
1884
|
+
* @private
|
|
1885
|
+
* @param {Object} set The set to convert.
|
|
1886
|
+
* @returns {Array} Returns the values.
|
|
1887
|
+
*/
|
|
1888
|
+
function setToArray(set) {
|
|
1889
|
+
var index = -1,
|
|
1890
|
+
result = Array(set.size);
|
|
1891
|
+
|
|
1892
|
+
set.forEach(function(value) {
|
|
1893
|
+
result[++index] = value;
|
|
1894
|
+
});
|
|
1895
|
+
return result;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
1899
|
+
var COMPARE_PARTIAL_FLAG$2 = 1,
|
|
1900
|
+
COMPARE_UNORDERED_FLAG = 2;
|
|
1901
|
+
|
|
1902
|
+
/** `Object#toString` result references. */
|
|
1903
|
+
var boolTag = '[object Boolean]',
|
|
1904
|
+
dateTag = '[object Date]',
|
|
1905
|
+
errorTag = '[object Error]',
|
|
1906
|
+
mapTag = '[object Map]',
|
|
1907
|
+
numberTag = '[object Number]',
|
|
1908
|
+
regexpTag = '[object RegExp]',
|
|
1909
|
+
setTag = '[object Set]',
|
|
1910
|
+
stringTag = '[object String]',
|
|
1911
|
+
symbolTag = '[object Symbol]';
|
|
1912
|
+
|
|
1913
|
+
var arrayBufferTag = '[object ArrayBuffer]',
|
|
1914
|
+
dataViewTag = '[object DataView]';
|
|
1915
|
+
|
|
1916
|
+
/** Used to convert symbols to primitives and strings. */
|
|
1917
|
+
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
1918
|
+
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
1919
|
+
|
|
1920
|
+
/**
|
|
1921
|
+
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
1922
|
+
* the same `toStringTag`.
|
|
1923
|
+
*
|
|
1924
|
+
* **Note:** This function only supports comparing values with tags of
|
|
1925
|
+
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|
1926
|
+
*
|
|
1927
|
+
* @private
|
|
1928
|
+
* @param {Object} object The object to compare.
|
|
1929
|
+
* @param {Object} other The other object to compare.
|
|
1930
|
+
* @param {string} tag The `toStringTag` of the objects to compare.
|
|
1931
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
1932
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
1933
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
1934
|
+
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
1935
|
+
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
1936
|
+
*/
|
|
1937
|
+
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
1938
|
+
switch (tag) {
|
|
1939
|
+
case dataViewTag:
|
|
1940
|
+
if ((object.byteLength != other.byteLength) ||
|
|
1941
|
+
(object.byteOffset != other.byteOffset)) {
|
|
1942
|
+
return false;
|
|
1943
|
+
}
|
|
1944
|
+
object = object.buffer;
|
|
1945
|
+
other = other.buffer;
|
|
1946
|
+
|
|
1947
|
+
case arrayBufferTag:
|
|
1948
|
+
if ((object.byteLength != other.byteLength) ||
|
|
1949
|
+
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
|
1950
|
+
return false;
|
|
1951
|
+
}
|
|
1952
|
+
return true;
|
|
1953
|
+
|
|
1954
|
+
case boolTag:
|
|
1955
|
+
case dateTag:
|
|
1956
|
+
case numberTag:
|
|
1957
|
+
// Coerce booleans to `1` or `0` and dates to milliseconds.
|
|
1958
|
+
// Invalid dates are coerced to `NaN`.
|
|
1959
|
+
return eq(+object, +other);
|
|
1960
|
+
|
|
1961
|
+
case errorTag:
|
|
1962
|
+
return object.name == other.name && object.message == other.message;
|
|
1963
|
+
|
|
1964
|
+
case regexpTag:
|
|
1965
|
+
case stringTag:
|
|
1966
|
+
// Coerce regexes to strings and treat strings, primitives and objects,
|
|
1967
|
+
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
|
1968
|
+
// for more details.
|
|
1969
|
+
return object == (other + '');
|
|
1970
|
+
|
|
1971
|
+
case mapTag:
|
|
1972
|
+
var convert = mapToArray;
|
|
1973
|
+
|
|
1974
|
+
case setTag:
|
|
1975
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2;
|
|
1976
|
+
convert || (convert = setToArray);
|
|
1977
|
+
|
|
1978
|
+
if (object.size != other.size && !isPartial) {
|
|
1979
|
+
return false;
|
|
1980
|
+
}
|
|
1981
|
+
// Assume cyclic values are equal.
|
|
1982
|
+
var stacked = stack.get(object);
|
|
1983
|
+
if (stacked) {
|
|
1984
|
+
return stacked == other;
|
|
1985
|
+
}
|
|
1986
|
+
bitmask |= COMPARE_UNORDERED_FLAG;
|
|
1987
|
+
|
|
1988
|
+
// Recursively compare objects (susceptible to call stack limits).
|
|
1989
|
+
stack.set(object, other);
|
|
1990
|
+
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
1991
|
+
stack['delete'](object);
|
|
1992
|
+
return result;
|
|
1993
|
+
|
|
1994
|
+
case symbolTag:
|
|
1995
|
+
if (symbolValueOf) {
|
|
1996
|
+
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
return false;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
2003
|
+
var COMPARE_PARTIAL_FLAG$1 = 1;
|
|
2004
|
+
|
|
2005
|
+
/** Used for built-in method references. */
|
|
2006
|
+
var objectProto$1 = Object.prototype;
|
|
2007
|
+
|
|
2008
|
+
/** Used to check objects for own properties. */
|
|
2009
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|
2013
|
+
* partial deep comparisons.
|
|
2014
|
+
*
|
|
2015
|
+
* @private
|
|
2016
|
+
* @param {Object} object The object to compare.
|
|
2017
|
+
* @param {Object} other The other object to compare.
|
|
2018
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
2019
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
2020
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
2021
|
+
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
2022
|
+
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
2023
|
+
*/
|
|
2024
|
+
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
2025
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1,
|
|
2026
|
+
objProps = getAllKeys(object),
|
|
2027
|
+
objLength = objProps.length,
|
|
2028
|
+
othProps = getAllKeys(other),
|
|
2029
|
+
othLength = othProps.length;
|
|
2030
|
+
|
|
2031
|
+
if (objLength != othLength && !isPartial) {
|
|
2032
|
+
return false;
|
|
2033
|
+
}
|
|
2034
|
+
var index = objLength;
|
|
2035
|
+
while (index--) {
|
|
2036
|
+
var key = objProps[index];
|
|
2037
|
+
if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
|
|
2038
|
+
return false;
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
// Check that cyclic values are equal.
|
|
2042
|
+
var objStacked = stack.get(object);
|
|
2043
|
+
var othStacked = stack.get(other);
|
|
2044
|
+
if (objStacked && othStacked) {
|
|
2045
|
+
return objStacked == other && othStacked == object;
|
|
2046
|
+
}
|
|
2047
|
+
var result = true;
|
|
2048
|
+
stack.set(object, other);
|
|
2049
|
+
stack.set(other, object);
|
|
2050
|
+
|
|
2051
|
+
var skipCtor = isPartial;
|
|
2052
|
+
while (++index < objLength) {
|
|
2053
|
+
key = objProps[index];
|
|
2054
|
+
var objValue = object[key],
|
|
2055
|
+
othValue = other[key];
|
|
2056
|
+
|
|
2057
|
+
if (customizer) {
|
|
2058
|
+
var compared = isPartial
|
|
2059
|
+
? customizer(othValue, objValue, key, other, object, stack)
|
|
2060
|
+
: customizer(objValue, othValue, key, object, other, stack);
|
|
2061
|
+
}
|
|
2062
|
+
// Recursively compare objects (susceptible to call stack limits).
|
|
2063
|
+
if (!(compared === undefined
|
|
2064
|
+
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
|
|
2065
|
+
: compared
|
|
2066
|
+
)) {
|
|
2067
|
+
result = false;
|
|
2068
|
+
break;
|
|
2069
|
+
}
|
|
2070
|
+
skipCtor || (skipCtor = key == 'constructor');
|
|
2071
|
+
}
|
|
2072
|
+
if (result && !skipCtor) {
|
|
2073
|
+
var objCtor = object.constructor,
|
|
2074
|
+
othCtor = other.constructor;
|
|
2075
|
+
|
|
2076
|
+
// Non `Object` object instances with different constructors are not equal.
|
|
2077
|
+
if (objCtor != othCtor &&
|
|
2078
|
+
('constructor' in object && 'constructor' in other) &&
|
|
2079
|
+
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
|
2080
|
+
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
|
2081
|
+
result = false;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
stack['delete'](object);
|
|
2085
|
+
stack['delete'](other);
|
|
2086
|
+
return result;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
/** Used to compose bitmasks for value comparisons. */
|
|
2090
|
+
var COMPARE_PARTIAL_FLAG = 1;
|
|
2091
|
+
|
|
2092
|
+
/** `Object#toString` result references. */
|
|
2093
|
+
var argsTag = '[object Arguments]',
|
|
2094
|
+
arrayTag = '[object Array]',
|
|
2095
|
+
objectTag = '[object Object]';
|
|
2096
|
+
|
|
2097
|
+
/** Used for built-in method references. */
|
|
2098
|
+
var objectProto = Object.prototype;
|
|
2099
|
+
|
|
2100
|
+
/** Used to check objects for own properties. */
|
|
2101
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
2102
|
+
|
|
2103
|
+
/**
|
|
2104
|
+
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|
2105
|
+
* deep comparisons and tracks traversed objects enabling objects with circular
|
|
2106
|
+
* references to be compared.
|
|
2107
|
+
*
|
|
2108
|
+
* @private
|
|
2109
|
+
* @param {Object} object The object to compare.
|
|
2110
|
+
* @param {Object} other The other object to compare.
|
|
2111
|
+
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
2112
|
+
* @param {Function} customizer The function to customize comparisons.
|
|
2113
|
+
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
2114
|
+
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
|
2115
|
+
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
2116
|
+
*/
|
|
2117
|
+
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
2118
|
+
var objIsArr = isArray(object),
|
|
2119
|
+
othIsArr = isArray(other),
|
|
2120
|
+
objTag = objIsArr ? arrayTag : getTag$1(object),
|
|
2121
|
+
othTag = othIsArr ? arrayTag : getTag$1(other);
|
|
2122
|
+
|
|
2123
|
+
objTag = objTag == argsTag ? objectTag : objTag;
|
|
2124
|
+
othTag = othTag == argsTag ? objectTag : othTag;
|
|
2125
|
+
|
|
2126
|
+
var objIsObj = objTag == objectTag,
|
|
2127
|
+
othIsObj = othTag == objectTag,
|
|
2128
|
+
isSameTag = objTag == othTag;
|
|
2129
|
+
|
|
2130
|
+
if (isSameTag && isBuffer(object)) {
|
|
2131
|
+
if (!isBuffer(other)) {
|
|
2132
|
+
return false;
|
|
2133
|
+
}
|
|
2134
|
+
objIsArr = true;
|
|
2135
|
+
objIsObj = false;
|
|
2136
|
+
}
|
|
2137
|
+
if (isSameTag && !objIsObj) {
|
|
2138
|
+
stack || (stack = new Stack);
|
|
2139
|
+
return (objIsArr || isTypedArray(object))
|
|
2140
|
+
? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
|
2141
|
+
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
2142
|
+
}
|
|
2143
|
+
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
|
|
2144
|
+
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
|
2145
|
+
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|
2146
|
+
|
|
2147
|
+
if (objIsWrapped || othIsWrapped) {
|
|
2148
|
+
var objUnwrapped = objIsWrapped ? object.value() : object,
|
|
2149
|
+
othUnwrapped = othIsWrapped ? other.value() : other;
|
|
2150
|
+
|
|
2151
|
+
stack || (stack = new Stack);
|
|
2152
|
+
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
if (!isSameTag) {
|
|
2156
|
+
return false;
|
|
2157
|
+
}
|
|
2158
|
+
stack || (stack = new Stack);
|
|
2159
|
+
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
/**
|
|
2163
|
+
* The base implementation of `_.isEqual` which supports partial comparisons
|
|
2164
|
+
* and tracks traversed objects.
|
|
2165
|
+
*
|
|
2166
|
+
* @private
|
|
2167
|
+
* @param {*} value The value to compare.
|
|
2168
|
+
* @param {*} other The other value to compare.
|
|
2169
|
+
* @param {boolean} bitmask The bitmask flags.
|
|
2170
|
+
* 1 - Unordered comparison
|
|
2171
|
+
* 2 - Partial comparison
|
|
2172
|
+
* @param {Function} [customizer] The function to customize comparisons.
|
|
2173
|
+
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
|
|
2174
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
2175
|
+
*/
|
|
2176
|
+
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
2177
|
+
if (value === other) {
|
|
2178
|
+
return true;
|
|
2179
|
+
}
|
|
2180
|
+
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
|
|
2181
|
+
return value !== value && other !== other;
|
|
2182
|
+
}
|
|
2183
|
+
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
/**
|
|
2187
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
2188
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
2189
|
+
*
|
|
2190
|
+
* @static
|
|
2191
|
+
* @memberOf _
|
|
2192
|
+
* @since 2.4.0
|
|
2193
|
+
* @category Date
|
|
2194
|
+
* @returns {number} Returns the timestamp.
|
|
2195
|
+
* @example
|
|
2196
|
+
*
|
|
2197
|
+
* _.defer(function(stamp) {
|
|
2198
|
+
* console.log(_.now() - stamp);
|
|
2199
|
+
* }, _.now());
|
|
2200
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
2201
|
+
*/
|
|
2202
|
+
var now = function() {
|
|
2203
|
+
return root.Date.now();
|
|
2204
|
+
};
|
|
2205
|
+
|
|
2206
|
+
/** Error message constants. */
|
|
2207
|
+
var FUNC_ERROR_TEXT$1 = 'Expected a function';
|
|
2208
|
+
|
|
2209
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
2210
|
+
var nativeMax = Math.max,
|
|
2211
|
+
nativeMin = Math.min;
|
|
2212
|
+
|
|
2213
|
+
/**
|
|
2214
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
2215
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
2216
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
2217
|
+
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
2218
|
+
* Provide `options` to indicate whether `func` should be invoked on the
|
|
2219
|
+
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
2220
|
+
* with the last arguments provided to the debounced function. Subsequent
|
|
2221
|
+
* calls to the debounced function return the result of the last `func`
|
|
2222
|
+
* invocation.
|
|
2223
|
+
*
|
|
2224
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
2225
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
2226
|
+
* is invoked more than once during the `wait` timeout.
|
|
2227
|
+
*
|
|
2228
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
2229
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
2230
|
+
*
|
|
2231
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
2232
|
+
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
2233
|
+
*
|
|
2234
|
+
* @static
|
|
2235
|
+
* @memberOf _
|
|
2236
|
+
* @since 0.1.0
|
|
2237
|
+
* @category Function
|
|
2238
|
+
* @param {Function} func The function to debounce.
|
|
2239
|
+
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
2240
|
+
* @param {Object} [options={}] The options object.
|
|
2241
|
+
* @param {boolean} [options.leading=false]
|
|
2242
|
+
* Specify invoking on the leading edge of the timeout.
|
|
2243
|
+
* @param {number} [options.maxWait]
|
|
2244
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
2245
|
+
* @param {boolean} [options.trailing=true]
|
|
2246
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
2247
|
+
* @returns {Function} Returns the new debounced function.
|
|
2248
|
+
* @example
|
|
2249
|
+
*
|
|
2250
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
2251
|
+
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
2252
|
+
*
|
|
2253
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
2254
|
+
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
2255
|
+
* 'leading': true,
|
|
2256
|
+
* 'trailing': false
|
|
2257
|
+
* }));
|
|
2258
|
+
*
|
|
2259
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
2260
|
+
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
2261
|
+
* var source = new EventSource('/stream');
|
|
2262
|
+
* jQuery(source).on('message', debounced);
|
|
2263
|
+
*
|
|
2264
|
+
* // Cancel the trailing debounced invocation.
|
|
2265
|
+
* jQuery(window).on('popstate', debounced.cancel);
|
|
2266
|
+
*/
|
|
2267
|
+
function debounce(func, wait, options) {
|
|
2268
|
+
var lastArgs,
|
|
2269
|
+
lastThis,
|
|
2270
|
+
maxWait,
|
|
2271
|
+
result,
|
|
2272
|
+
timerId,
|
|
2273
|
+
lastCallTime,
|
|
2274
|
+
lastInvokeTime = 0,
|
|
2275
|
+
leading = false,
|
|
2276
|
+
maxing = false,
|
|
2277
|
+
trailing = true;
|
|
2278
|
+
|
|
2279
|
+
if (typeof func != 'function') {
|
|
2280
|
+
throw new TypeError(FUNC_ERROR_TEXT$1);
|
|
2281
|
+
}
|
|
2282
|
+
wait = toNumber(wait) || 0;
|
|
2283
|
+
if (isObject(options)) {
|
|
2284
|
+
leading = !!options.leading;
|
|
2285
|
+
maxing = 'maxWait' in options;
|
|
2286
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
2287
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
function invokeFunc(time) {
|
|
2291
|
+
var args = lastArgs,
|
|
2292
|
+
thisArg = lastThis;
|
|
2293
|
+
|
|
2294
|
+
lastArgs = lastThis = undefined;
|
|
2295
|
+
lastInvokeTime = time;
|
|
2296
|
+
result = func.apply(thisArg, args);
|
|
2297
|
+
return result;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
function leadingEdge(time) {
|
|
2301
|
+
// Reset any `maxWait` timer.
|
|
2302
|
+
lastInvokeTime = time;
|
|
2303
|
+
// Start the timer for the trailing edge.
|
|
2304
|
+
timerId = setTimeout(timerExpired, wait);
|
|
2305
|
+
// Invoke the leading edge.
|
|
2306
|
+
return leading ? invokeFunc(time) : result;
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
function remainingWait(time) {
|
|
2310
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
2311
|
+
timeSinceLastInvoke = time - lastInvokeTime,
|
|
2312
|
+
timeWaiting = wait - timeSinceLastCall;
|
|
2313
|
+
|
|
2314
|
+
return maxing
|
|
2315
|
+
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
|
|
2316
|
+
: timeWaiting;
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
function shouldInvoke(time) {
|
|
2320
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
2321
|
+
timeSinceLastInvoke = time - lastInvokeTime;
|
|
2322
|
+
|
|
2323
|
+
// Either this is the first call, activity has stopped and we're at the
|
|
2324
|
+
// trailing edge, the system time has gone backwards and we're treating
|
|
2325
|
+
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
2326
|
+
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
|
2327
|
+
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
function timerExpired() {
|
|
2331
|
+
var time = now();
|
|
2332
|
+
if (shouldInvoke(time)) {
|
|
2333
|
+
return trailingEdge(time);
|
|
2334
|
+
}
|
|
2335
|
+
// Restart the timer.
|
|
2336
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
function trailingEdge(time) {
|
|
2340
|
+
timerId = undefined;
|
|
2341
|
+
|
|
2342
|
+
// Only invoke if we have `lastArgs` which means `func` has been
|
|
2343
|
+
// debounced at least once.
|
|
2344
|
+
if (trailing && lastArgs) {
|
|
2345
|
+
return invokeFunc(time);
|
|
2346
|
+
}
|
|
2347
|
+
lastArgs = lastThis = undefined;
|
|
2348
|
+
return result;
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
function cancel() {
|
|
2352
|
+
if (timerId !== undefined) {
|
|
2353
|
+
clearTimeout(timerId);
|
|
2354
|
+
}
|
|
2355
|
+
lastInvokeTime = 0;
|
|
2356
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
function flush() {
|
|
2360
|
+
return timerId === undefined ? result : trailingEdge(now());
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
function debounced() {
|
|
2364
|
+
var time = now(),
|
|
2365
|
+
isInvoking = shouldInvoke(time);
|
|
2366
|
+
|
|
2367
|
+
lastArgs = arguments;
|
|
2368
|
+
lastThis = this;
|
|
2369
|
+
lastCallTime = time;
|
|
2370
|
+
|
|
2371
|
+
if (isInvoking) {
|
|
2372
|
+
if (timerId === undefined) {
|
|
2373
|
+
return leadingEdge(lastCallTime);
|
|
2374
|
+
}
|
|
2375
|
+
if (maxing) {
|
|
2376
|
+
// Handle invocations in a tight loop.
|
|
2377
|
+
clearTimeout(timerId);
|
|
2378
|
+
timerId = setTimeout(timerExpired, wait);
|
|
2379
|
+
return invokeFunc(lastCallTime);
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
if (timerId === undefined) {
|
|
2383
|
+
timerId = setTimeout(timerExpired, wait);
|
|
2384
|
+
}
|
|
2385
|
+
return result;
|
|
2386
|
+
}
|
|
2387
|
+
debounced.cancel = cancel;
|
|
2388
|
+
debounced.flush = flush;
|
|
2389
|
+
return debounced;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
/**
|
|
2393
|
+
* Performs a deep comparison between two values to determine if they are
|
|
2394
|
+
* equivalent.
|
|
2395
|
+
*
|
|
2396
|
+
* **Note:** This method supports comparing arrays, array buffers, booleans,
|
|
2397
|
+
* date objects, error objects, maps, numbers, `Object` objects, regexes,
|
|
2398
|
+
* sets, strings, symbols, and typed arrays. `Object` objects are compared
|
|
2399
|
+
* by their own, not inherited, enumerable properties. Functions and DOM
|
|
2400
|
+
* nodes are compared by strict equality, i.e. `===`.
|
|
2401
|
+
*
|
|
2402
|
+
* @static
|
|
2403
|
+
* @memberOf _
|
|
2404
|
+
* @since 0.1.0
|
|
2405
|
+
* @category Lang
|
|
2406
|
+
* @param {*} value The value to compare.
|
|
2407
|
+
* @param {*} other The other value to compare.
|
|
2408
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
2409
|
+
* @example
|
|
2410
|
+
*
|
|
2411
|
+
* var object = { 'a': 1 };
|
|
2412
|
+
* var other = { 'a': 1 };
|
|
2413
|
+
*
|
|
2414
|
+
* _.isEqual(object, other);
|
|
2415
|
+
* // => true
|
|
2416
|
+
*
|
|
2417
|
+
* object === other;
|
|
2418
|
+
* // => false
|
|
2419
|
+
*/
|
|
2420
|
+
function isEqual(value, other) {
|
|
2421
|
+
return baseIsEqual(value, other);
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
/** Error message constants. */
|
|
2425
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
2426
|
+
|
|
2427
|
+
/**
|
|
2428
|
+
* Creates a throttled function that only invokes `func` at most once per
|
|
2429
|
+
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
|
2430
|
+
* method to cancel delayed `func` invocations and a `flush` method to
|
|
2431
|
+
* immediately invoke them. Provide `options` to indicate whether `func`
|
|
2432
|
+
* should be invoked on the leading and/or trailing edge of the `wait`
|
|
2433
|
+
* timeout. The `func` is invoked with the last arguments provided to the
|
|
2434
|
+
* throttled function. Subsequent calls to the throttled function return the
|
|
2435
|
+
* result of the last `func` invocation.
|
|
2436
|
+
*
|
|
2437
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
2438
|
+
* invoked on the trailing edge of the timeout only if the throttled function
|
|
2439
|
+
* is invoked more than once during the `wait` timeout.
|
|
2440
|
+
*
|
|
2441
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
2442
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
2443
|
+
*
|
|
2444
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
2445
|
+
* for details over the differences between `_.throttle` and `_.debounce`.
|
|
2446
|
+
*
|
|
2447
|
+
* @static
|
|
2448
|
+
* @memberOf _
|
|
2449
|
+
* @since 0.1.0
|
|
2450
|
+
* @category Function
|
|
2451
|
+
* @param {Function} func The function to throttle.
|
|
2452
|
+
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
|
|
2453
|
+
* @param {Object} [options={}] The options object.
|
|
2454
|
+
* @param {boolean} [options.leading=true]
|
|
2455
|
+
* Specify invoking on the leading edge of the timeout.
|
|
2456
|
+
* @param {boolean} [options.trailing=true]
|
|
2457
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
2458
|
+
* @returns {Function} Returns the new throttled function.
|
|
2459
|
+
* @example
|
|
2460
|
+
*
|
|
2461
|
+
* // Avoid excessively updating the position while scrolling.
|
|
2462
|
+
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
|
|
2463
|
+
*
|
|
2464
|
+
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
|
2465
|
+
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
|
|
2466
|
+
* jQuery(element).on('click', throttled);
|
|
2467
|
+
*
|
|
2468
|
+
* // Cancel the trailing throttled invocation.
|
|
2469
|
+
* jQuery(window).on('popstate', throttled.cancel);
|
|
2470
|
+
*/
|
|
2471
|
+
function throttle(func, wait, options) {
|
|
2472
|
+
var leading = true,
|
|
2473
|
+
trailing = true;
|
|
2474
|
+
|
|
2475
|
+
if (typeof func != 'function') {
|
|
2476
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
2477
|
+
}
|
|
2478
|
+
if (isObject(options)) {
|
|
2479
|
+
leading = 'leading' in options ? !!options.leading : leading;
|
|
2480
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
2481
|
+
}
|
|
2482
|
+
return debounce(func, wait, {
|
|
2483
|
+
'leading': leading,
|
|
2484
|
+
'maxWait': wait,
|
|
2485
|
+
'trailing': trailing
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
|
|
84
2489
|
const isPrimitive$1 = (val) => val !== Object(val);
|
|
85
2490
|
function useCustomCompareEffect(effect, deps, depsEqual) {
|
|
86
2491
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -121,7 +2526,7 @@ function useDeepCompareEffect(effect, deps) {
|
|
|
121
2526
|
);
|
|
122
2527
|
}
|
|
123
2528
|
}
|
|
124
|
-
useCustomCompareEffect(effect, deps,
|
|
2529
|
+
useCustomCompareEffect(effect, deps, isEqual);
|
|
125
2530
|
}
|
|
126
2531
|
|
|
127
2532
|
const StorageSerializers = {
|
|
@@ -176,7 +2581,7 @@ function useStorage(key, defaults, getStorage, options = {}) {
|
|
|
176
2581
|
}, [options.serializer, type]);
|
|
177
2582
|
const [state, setState] = React.useState(defaults);
|
|
178
2583
|
useDeepCompareEffect(() => {
|
|
179
|
-
const data = csrData ? isFunction(csrData) ? csrData() : csrData : defaults;
|
|
2584
|
+
const data = csrData ? isFunction$1(csrData) ? csrData() : csrData : defaults;
|
|
180
2585
|
const getStoredValue = () => {
|
|
181
2586
|
try {
|
|
182
2587
|
const raw = storage == null ? void 0 : storage.getItem(key);
|
|
@@ -194,7 +2599,7 @@ function useStorage(key, defaults, getStorage, options = {}) {
|
|
|
194
2599
|
}, [key, defaults, serializer, storage, onError]);
|
|
195
2600
|
const updateState = useEvent(
|
|
196
2601
|
(valOrFunc) => {
|
|
197
|
-
const currentState = isFunction(valOrFunc) ? valOrFunc(state) : valOrFunc;
|
|
2602
|
+
const currentState = isFunction$1(valOrFunc) ? valOrFunc(state) : valOrFunc;
|
|
198
2603
|
setState(currentState);
|
|
199
2604
|
if (currentState === null) {
|
|
200
2605
|
storage == null ? void 0 : storage.removeItem(key);
|
|
@@ -348,7 +2753,7 @@ function usePreferredDark(defaultState) {
|
|
|
348
2753
|
|
|
349
2754
|
function useMount(fn) {
|
|
350
2755
|
if (isDev) {
|
|
351
|
-
if (!isFunction(fn)) {
|
|
2756
|
+
if (!isFunction$1(fn)) {
|
|
352
2757
|
console.error(
|
|
353
2758
|
`useMount: parameter \`fn\` expected to be a function, but got "${typeof fn}".`
|
|
354
2759
|
);
|
|
@@ -361,7 +2766,7 @@ function useMount(fn) {
|
|
|
361
2766
|
|
|
362
2767
|
function useUnmount(fn) {
|
|
363
2768
|
if (isDev) {
|
|
364
|
-
if (!isFunction(fn)) {
|
|
2769
|
+
if (!isFunction$1(fn)) {
|
|
365
2770
|
console.error(
|
|
366
2771
|
`useUnmount expected parameter is a function, got ${typeof fn}`
|
|
367
2772
|
);
|
|
@@ -378,7 +2783,7 @@ function useUnmount(fn) {
|
|
|
378
2783
|
|
|
379
2784
|
function useThrottleFn(fn, wait, options) {
|
|
380
2785
|
if (isDev) {
|
|
381
|
-
if (!isFunction(fn)) {
|
|
2786
|
+
if (!isFunction$1(fn)) {
|
|
382
2787
|
console.error(
|
|
383
2788
|
`useThrottleFn expected parameter is a function, got ${typeof fn}`
|
|
384
2789
|
);
|
|
@@ -386,7 +2791,7 @@ function useThrottleFn(fn, wait, options) {
|
|
|
386
2791
|
}
|
|
387
2792
|
const fnRef = useLatest(fn);
|
|
388
2793
|
const throttled = React.useMemo(
|
|
389
|
-
() =>
|
|
2794
|
+
() => throttle(
|
|
390
2795
|
(...args) => {
|
|
391
2796
|
return fnRef.current(...args);
|
|
392
2797
|
},
|
|
@@ -423,7 +2828,7 @@ function useThrottle(value, wait, options) {
|
|
|
423
2828
|
|
|
424
2829
|
function useDebounceFn(fn, wait, options) {
|
|
425
2830
|
if (isDev) {
|
|
426
|
-
if (!isFunction(fn)) {
|
|
2831
|
+
if (!isFunction$1(fn)) {
|
|
427
2832
|
console.error(
|
|
428
2833
|
`useDebounceFn expected parameter is a function, got ${typeof fn}`
|
|
429
2834
|
);
|
|
@@ -431,7 +2836,7 @@ function useDebounceFn(fn, wait, options) {
|
|
|
431
2836
|
}
|
|
432
2837
|
const fnRef = useLatest(fn);
|
|
433
2838
|
const debounced = React.useMemo(
|
|
434
|
-
() =>
|
|
2839
|
+
() => debounce(
|
|
435
2840
|
(...args) => {
|
|
436
2841
|
return fnRef.current(...args);
|
|
437
2842
|
},
|
|
@@ -558,7 +2963,7 @@ function getTargetElement(target, defaultElement) {
|
|
|
558
2963
|
return defaultElement;
|
|
559
2964
|
}
|
|
560
2965
|
let targetElement;
|
|
561
|
-
if (isFunction(target)) {
|
|
2966
|
+
if (isFunction$1(target)) {
|
|
562
2967
|
targetElement = target();
|
|
563
2968
|
} else if ("current" in target) {
|
|
564
2969
|
targetElement = target.current;
|
|
@@ -977,7 +3382,7 @@ function useIdle(ms = oneMinute, initialState = false, events = defaultEvents$1)
|
|
|
977
3382
|
setState(newState);
|
|
978
3383
|
}
|
|
979
3384
|
};
|
|
980
|
-
const onEvent =
|
|
3385
|
+
const onEvent = throttle(() => {
|
|
981
3386
|
if (localState) {
|
|
982
3387
|
set(false);
|
|
983
3388
|
}
|
|
@@ -1033,7 +3438,7 @@ function useMediaDevices() {
|
|
|
1033
3438
|
return state;
|
|
1034
3439
|
}
|
|
1035
3440
|
const useMediaDevicesMock = () => ({ devices: [] });
|
|
1036
|
-
var
|
|
3441
|
+
var index$3 = isNavigator && !!navigator.mediaDevices ? useMediaDevices : useMediaDevicesMock;
|
|
1037
3442
|
|
|
1038
3443
|
function useTextDirection(options = {}) {
|
|
1039
3444
|
const { selector = "html", initialValue = "ltr" } = options;
|
|
@@ -1131,7 +3536,7 @@ function useFps(options) {
|
|
|
1131
3536
|
return fps;
|
|
1132
3537
|
}
|
|
1133
3538
|
const useFpsMock = (options) => 0;
|
|
1134
|
-
var
|
|
3539
|
+
var index$2 = typeof performance === "undefined" ? useFpsMock : useFps;
|
|
1135
3540
|
|
|
1136
3541
|
const initCoord = {
|
|
1137
3542
|
accuracy: 0,
|
|
@@ -2509,9 +4914,9 @@ const createOnceEffect = (hook) => (effect, deps) => {
|
|
|
2509
4914
|
}, deps);
|
|
2510
4915
|
};
|
|
2511
4916
|
|
|
2512
|
-
var
|
|
4917
|
+
var index$1 = createOnceEffect(React.useEffect);
|
|
2513
4918
|
|
|
2514
|
-
var
|
|
4919
|
+
var index = createOnceEffect(React.useLayoutEffect);
|
|
2515
4920
|
|
|
2516
4921
|
function useReducedMotion(defaultState) {
|
|
2517
4922
|
return useMediaQuery("(prefers-reduced-motion: reduce)", defaultState);
|
|
@@ -2907,7 +5312,7 @@ exports.useFavicon = useFavicon;
|
|
|
2907
5312
|
exports.useFileDialog = useFileDialog;
|
|
2908
5313
|
exports.useFirstMountState = useFirstMountState;
|
|
2909
5314
|
exports.useFocus = useFocus;
|
|
2910
|
-
exports.useFps =
|
|
5315
|
+
exports.useFps = index$2;
|
|
2911
5316
|
exports.useFullscreen = useFullscreen;
|
|
2912
5317
|
exports.useGeolocation = useGeolocation;
|
|
2913
5318
|
exports.useIdle = useIdle;
|
|
@@ -2919,7 +5324,7 @@ exports.useKeyModifier = useKeyModifier;
|
|
|
2919
5324
|
exports.useLatest = useLatest;
|
|
2920
5325
|
exports.useLocalStorage = useLocalStorage;
|
|
2921
5326
|
exports.useLongPress = useLongPress;
|
|
2922
|
-
exports.useMediaDevices =
|
|
5327
|
+
exports.useMediaDevices = index$3;
|
|
2923
5328
|
exports.useMediaQuery = useMediaQuery;
|
|
2924
5329
|
exports.useMount = useMount;
|
|
2925
5330
|
exports.useMountedState = useMountedState;
|
|
@@ -2928,8 +5333,8 @@ exports.useMousePressed = useMousePressed;
|
|
|
2928
5333
|
exports.useMutationObserver = useMutationObserver;
|
|
2929
5334
|
exports.useNetwork = useNetwork;
|
|
2930
5335
|
exports.useObjectUrl = useObjectUrl;
|
|
2931
|
-
exports.useOnceEffect =
|
|
2932
|
-
exports.useOnceLayoutEffect =
|
|
5336
|
+
exports.useOnceEffect = index$1;
|
|
5337
|
+
exports.useOnceLayoutEffect = index;
|
|
2933
5338
|
exports.useOnline = useOnline;
|
|
2934
5339
|
exports.useOrientation = useOrientation;
|
|
2935
5340
|
exports.usePageLeave = usePageLeave;
|
|
@@ -2960,7 +5365,7 @@ exports.useToggle = useToggle;
|
|
|
2960
5365
|
exports.useUnmount = useUnmount;
|
|
2961
5366
|
exports.useUpdate = useUpdate;
|
|
2962
5367
|
exports.useUpdateEffect = useUpdateEffect;
|
|
2963
|
-
exports.useUpdateLayoutEffect =
|
|
5368
|
+
exports.useUpdateLayoutEffect = index$4;
|
|
2964
5369
|
exports.useVirtualList = useVirtualList;
|
|
2965
5370
|
exports.useWindowScroll = useWindowScroll;
|
|
2966
5371
|
exports.useWindowSize = useWindowSize;
|