check-types-mini 6.1.0 → 7.0.3

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.
@@ -1,4432 +0,0 @@
1
- /**
2
- * @name check-types-mini
3
- * @fileoverview Validate options object
4
- * @version 6.1.0
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/check-types-mini/}
8
- */
9
-
10
- (function (global, factory) {
11
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
12
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
13
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.checkTypesMini = {}));
14
- }(this, (function (exports) { 'use strict';
15
-
16
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
17
-
18
- var typeDetect = {exports: {}};
19
-
20
- (function (module, exports) {
21
- (function (global, factory) {
22
- module.exports = factory() ;
23
- }(commonjsGlobal, (function () {
24
- /* !
25
- * type-detect
26
- * Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
27
- * MIT Licensed
28
- */
29
- var promiseExists = typeof Promise === 'function';
30
-
31
- /* eslint-disable no-undef */
32
- var globalObject = typeof self === 'object' ? self : commonjsGlobal; // eslint-disable-line id-blacklist
33
-
34
- var symbolExists = typeof Symbol !== 'undefined';
35
- var mapExists = typeof Map !== 'undefined';
36
- var setExists = typeof Set !== 'undefined';
37
- var weakMapExists = typeof WeakMap !== 'undefined';
38
- var weakSetExists = typeof WeakSet !== 'undefined';
39
- var dataViewExists = typeof DataView !== 'undefined';
40
- var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
41
- var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
42
- var setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
43
- var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
44
- var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
45
- var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
46
- var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
47
- var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
48
- var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function';
49
- var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
50
- var toStringLeftSliceLength = 8;
51
- var toStringRightSliceLength = -1;
52
- /**
53
- * ### typeOf (obj)
54
- *
55
- * Uses `Object.prototype.toString` to determine the type of an object,
56
- * normalising behaviour across engine versions & well optimised.
57
- *
58
- * @param {Mixed} object
59
- * @return {String} object type
60
- * @api public
61
- */
62
- function typeDetect(obj) {
63
- /* ! Speed optimisation
64
- * Pre:
65
- * string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
66
- * boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled)
67
- * number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled)
68
- * undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled)
69
- * function x 2,556,769 ops/sec ±1.73% (77 runs sampled)
70
- * Post:
71
- * string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled)
72
- * boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled)
73
- * number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled)
74
- * undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled)
75
- * function x 31,296,870 ops/sec ±0.96% (83 runs sampled)
76
- */
77
- var typeofObj = typeof obj;
78
- if (typeofObj !== 'object') {
79
- return typeofObj;
80
- }
81
-
82
- /* ! Speed optimisation
83
- * Pre:
84
- * null x 28,645,765 ops/sec ±1.17% (82 runs sampled)
85
- * Post:
86
- * null x 36,428,962 ops/sec ±1.37% (84 runs sampled)
87
- */
88
- if (obj === null) {
89
- return 'null';
90
- }
91
-
92
- /* ! Spec Conformance
93
- * Test: `Object.prototype.toString.call(window)``
94
- * - Node === "[object global]"
95
- * - Chrome === "[object global]"
96
- * - Firefox === "[object Window]"
97
- * - PhantomJS === "[object Window]"
98
- * - Safari === "[object Window]"
99
- * - IE 11 === "[object Window]"
100
- * - IE Edge === "[object Window]"
101
- * Test: `Object.prototype.toString.call(this)``
102
- * - Chrome Worker === "[object global]"
103
- * - Firefox Worker === "[object DedicatedWorkerGlobalScope]"
104
- * - Safari Worker === "[object DedicatedWorkerGlobalScope]"
105
- * - IE 11 Worker === "[object WorkerGlobalScope]"
106
- * - IE Edge Worker === "[object WorkerGlobalScope]"
107
- */
108
- if (obj === globalObject) {
109
- return 'global';
110
- }
111
-
112
- /* ! Speed optimisation
113
- * Pre:
114
- * array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled)
115
- * Post:
116
- * array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
117
- */
118
- if (
119
- Array.isArray(obj) &&
120
- (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))
121
- ) {
122
- return 'Array';
123
- }
124
-
125
- // Not caching existence of `window` and related properties due to potential
126
- // for `window` to be unset before tests in quasi-browser environments.
127
- if (typeof window === 'object' && window !== null) {
128
- /* ! Spec Conformance
129
- * (https://html.spec.whatwg.org/multipage/browsers.html#location)
130
- * WhatWG HTML$7.7.3 - The `Location` interface
131
- * Test: `Object.prototype.toString.call(window.location)``
132
- * - IE <=11 === "[object Object]"
133
- * - IE Edge <=13 === "[object Object]"
134
- */
135
- if (typeof window.location === 'object' && obj === window.location) {
136
- return 'Location';
137
- }
138
-
139
- /* ! Spec Conformance
140
- * (https://html.spec.whatwg.org/#document)
141
- * WhatWG HTML$3.1.1 - The `Document` object
142
- * Note: Most browsers currently adher to the W3C DOM Level 2 spec
143
- * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)
144
- * which suggests that browsers should use HTMLTableCellElement for
145
- * both TD and TH elements. WhatWG separates these.
146
- * WhatWG HTML states:
147
- * > For historical reasons, Window objects must also have a
148
- * > writable, configurable, non-enumerable property named
149
- * > HTMLDocument whose value is the Document interface object.
150
- * Test: `Object.prototype.toString.call(document)``
151
- * - Chrome === "[object HTMLDocument]"
152
- * - Firefox === "[object HTMLDocument]"
153
- * - Safari === "[object HTMLDocument]"
154
- * - IE <=10 === "[object Document]"
155
- * - IE 11 === "[object HTMLDocument]"
156
- * - IE Edge <=13 === "[object HTMLDocument]"
157
- */
158
- if (typeof window.document === 'object' && obj === window.document) {
159
- return 'Document';
160
- }
161
-
162
- if (typeof window.navigator === 'object') {
163
- /* ! Spec Conformance
164
- * (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
165
- * WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
166
- * Test: `Object.prototype.toString.call(navigator.mimeTypes)``
167
- * - IE <=10 === "[object MSMimeTypesCollection]"
168
- */
169
- if (typeof window.navigator.mimeTypes === 'object' &&
170
- obj === window.navigator.mimeTypes) {
171
- return 'MimeTypeArray';
172
- }
173
-
174
- /* ! Spec Conformance
175
- * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
176
- * WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
177
- * Test: `Object.prototype.toString.call(navigator.plugins)``
178
- * - IE <=10 === "[object MSPluginsCollection]"
179
- */
180
- if (typeof window.navigator.plugins === 'object' &&
181
- obj === window.navigator.plugins) {
182
- return 'PluginArray';
183
- }
184
- }
185
-
186
- if ((typeof window.HTMLElement === 'function' ||
187
- typeof window.HTMLElement === 'object') &&
188
- obj instanceof window.HTMLElement) {
189
- /* ! Spec Conformance
190
- * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
191
- * WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
192
- * Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
193
- * - IE <=10 === "[object HTMLBlockElement]"
194
- */
195
- if (obj.tagName === 'BLOCKQUOTE') {
196
- return 'HTMLQuoteElement';
197
- }
198
-
199
- /* ! Spec Conformance
200
- * (https://html.spec.whatwg.org/#htmltabledatacellelement)
201
- * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
202
- * Note: Most browsers currently adher to the W3C DOM Level 2 spec
203
- * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
204
- * which suggests that browsers should use HTMLTableCellElement for
205
- * both TD and TH elements. WhatWG separates these.
206
- * Test: Object.prototype.toString.call(document.createElement('td'))
207
- * - Chrome === "[object HTMLTableCellElement]"
208
- * - Firefox === "[object HTMLTableCellElement]"
209
- * - Safari === "[object HTMLTableCellElement]"
210
- */
211
- if (obj.tagName === 'TD') {
212
- return 'HTMLTableDataCellElement';
213
- }
214
-
215
- /* ! Spec Conformance
216
- * (https://html.spec.whatwg.org/#htmltableheadercellelement)
217
- * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
218
- * Note: Most browsers currently adher to the W3C DOM Level 2 spec
219
- * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
220
- * which suggests that browsers should use HTMLTableCellElement for
221
- * both TD and TH elements. WhatWG separates these.
222
- * Test: Object.prototype.toString.call(document.createElement('th'))
223
- * - Chrome === "[object HTMLTableCellElement]"
224
- * - Firefox === "[object HTMLTableCellElement]"
225
- * - Safari === "[object HTMLTableCellElement]"
226
- */
227
- if (obj.tagName === 'TH') {
228
- return 'HTMLTableHeaderCellElement';
229
- }
230
- }
231
- }
232
-
233
- /* ! Speed optimisation
234
- * Pre:
235
- * Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled)
236
- * Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled)
237
- * Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled)
238
- * Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled)
239
- * Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled)
240
- * Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled)
241
- * Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled)
242
- * Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled)
243
- * Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled)
244
- * Post:
245
- * Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled)
246
- * Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled)
247
- * Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled)
248
- * Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled)
249
- * Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled)
250
- * Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled)
251
- * Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled)
252
- * Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled)
253
- * Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled)
254
- */
255
- var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]);
256
- if (typeof stringTag === 'string') {
257
- return stringTag;
258
- }
259
-
260
- var objPrototype = Object.getPrototypeOf(obj);
261
- /* ! Speed optimisation
262
- * Pre:
263
- * regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled)
264
- * regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled)
265
- * Post:
266
- * regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled)
267
- * regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled)
268
- */
269
- if (objPrototype === RegExp.prototype) {
270
- return 'RegExp';
271
- }
272
-
273
- /* ! Speed optimisation
274
- * Pre:
275
- * date x 2,130,074 ops/sec ±4.42% (68 runs sampled)
276
- * Post:
277
- * date x 3,953,779 ops/sec ±1.35% (77 runs sampled)
278
- */
279
- if (objPrototype === Date.prototype) {
280
- return 'Date';
281
- }
282
-
283
- /* ! Spec Conformance
284
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag)
285
- * ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise":
286
- * Test: `Object.prototype.toString.call(Promise.resolve())``
287
- * - Chrome <=47 === "[object Object]"
288
- * - Edge <=20 === "[object Object]"
289
- * - Firefox 29-Latest === "[object Promise]"
290
- * - Safari 7.1-Latest === "[object Promise]"
291
- */
292
- if (promiseExists && objPrototype === Promise.prototype) {
293
- return 'Promise';
294
- }
295
-
296
- /* ! Speed optimisation
297
- * Pre:
298
- * set x 2,222,186 ops/sec ±1.31% (82 runs sampled)
299
- * Post:
300
- * set x 4,545,879 ops/sec ±1.13% (83 runs sampled)
301
- */
302
- if (setExists && objPrototype === Set.prototype) {
303
- return 'Set';
304
- }
305
-
306
- /* ! Speed optimisation
307
- * Pre:
308
- * map x 2,396,842 ops/sec ±1.59% (81 runs sampled)
309
- * Post:
310
- * map x 4,183,945 ops/sec ±6.59% (82 runs sampled)
311
- */
312
- if (mapExists && objPrototype === Map.prototype) {
313
- return 'Map';
314
- }
315
-
316
- /* ! Speed optimisation
317
- * Pre:
318
- * weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled)
319
- * Post:
320
- * weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled)
321
- */
322
- if (weakSetExists && objPrototype === WeakSet.prototype) {
323
- return 'WeakSet';
324
- }
325
-
326
- /* ! Speed optimisation
327
- * Pre:
328
- * weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled)
329
- * Post:
330
- * weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled)
331
- */
332
- if (weakMapExists && objPrototype === WeakMap.prototype) {
333
- return 'WeakMap';
334
- }
335
-
336
- /* ! Spec Conformance
337
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag)
338
- * ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView":
339
- * Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))``
340
- * - Edge <=13 === "[object Object]"
341
- */
342
- if (dataViewExists && objPrototype === DataView.prototype) {
343
- return 'DataView';
344
- }
345
-
346
- /* ! Spec Conformance
347
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag)
348
- * ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator":
349
- * Test: `Object.prototype.toString.call(new Map().entries())``
350
- * - Edge <=13 === "[object Object]"
351
- */
352
- if (mapExists && objPrototype === mapIteratorPrototype) {
353
- return 'Map Iterator';
354
- }
355
-
356
- /* ! Spec Conformance
357
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag)
358
- * ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator":
359
- * Test: `Object.prototype.toString.call(new Set().entries())``
360
- * - Edge <=13 === "[object Object]"
361
- */
362
- if (setExists && objPrototype === setIteratorPrototype) {
363
- return 'Set Iterator';
364
- }
365
-
366
- /* ! Spec Conformance
367
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag)
368
- * ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator":
369
- * Test: `Object.prototype.toString.call([][Symbol.iterator]())``
370
- * - Edge <=13 === "[object Object]"
371
- */
372
- if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
373
- return 'Array Iterator';
374
- }
375
-
376
- /* ! Spec Conformance
377
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag)
378
- * ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator":
379
- * Test: `Object.prototype.toString.call(''[Symbol.iterator]())``
380
- * - Edge <=13 === "[object Object]"
381
- */
382
- if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
383
- return 'String Iterator';
384
- }
385
-
386
- /* ! Speed optimisation
387
- * Pre:
388
- * object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled)
389
- * Post:
390
- * object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled)
391
- */
392
- if (objPrototype === null) {
393
- return 'Object';
394
- }
395
-
396
- return Object
397
- .prototype
398
- .toString
399
- .call(obj)
400
- .slice(toStringLeftSliceLength, toStringRightSliceLength);
401
- }
402
-
403
- return typeDetect;
404
-
405
- })));
406
- }(typeDetect));
407
-
408
- var typ = typeDetect.exports;
409
-
410
- /**
411
- * lodash (Custom Build) <https://lodash.com/>
412
- * Build: `lodash modularize exports="npm" -o ./`
413
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
414
- * Released under MIT license <https://lodash.com/license>
415
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
416
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
417
- */
418
-
419
- /**
420
- * A specialized version of `_.map` for arrays without support for iteratee
421
- * shorthands.
422
- *
423
- * @private
424
- * @param {Array} [array] The array to iterate over.
425
- * @param {Function} iteratee The function invoked per iteration.
426
- * @returns {Array} Returns the new mapped array.
427
- */
428
- function arrayMap$1(array, iteratee) {
429
- var index = -1,
430
- length = array ? array.length : 0,
431
- result = Array(length);
432
-
433
- while (++index < length) {
434
- result[index] = iteratee(array[index], index, array);
435
- }
436
- return result;
437
- }
438
-
439
- /**
440
- * The base implementation of `_.findIndex` and `_.findLastIndex` without
441
- * support for iteratee shorthands.
442
- *
443
- * @private
444
- * @param {Array} array The array to search.
445
- * @param {Function} predicate The function invoked per iteration.
446
- * @param {number} fromIndex The index to search from.
447
- * @param {boolean} [fromRight] Specify iterating from right to left.
448
- * @returns {number} Returns the index of the matched value, else `-1`.
449
- */
450
- function baseFindIndex$1(array, predicate, fromIndex, fromRight) {
451
- var length = array.length,
452
- index = fromIndex + (fromRight ? 1 : -1);
453
-
454
- while ((fromRight ? index-- : ++index < length)) {
455
- if (predicate(array[index], index, array)) {
456
- return index;
457
- }
458
- }
459
- return -1;
460
- }
461
-
462
- /**
463
- * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
464
- *
465
- * @private
466
- * @param {Array} array The array to search.
467
- * @param {*} value The value to search for.
468
- * @param {number} fromIndex The index to search from.
469
- * @returns {number} Returns the index of the matched value, else `-1`.
470
- */
471
- function baseIndexOf$1(array, value, fromIndex) {
472
- if (value !== value) {
473
- return baseFindIndex$1(array, baseIsNaN$1, fromIndex);
474
- }
475
- var index = fromIndex - 1,
476
- length = array.length;
477
-
478
- while (++index < length) {
479
- if (array[index] === value) {
480
- return index;
481
- }
482
- }
483
- return -1;
484
- }
485
-
486
- /**
487
- * This function is like `baseIndexOf` except that it accepts a comparator.
488
- *
489
- * @private
490
- * @param {Array} array The array to search.
491
- * @param {*} value The value to search for.
492
- * @param {number} fromIndex The index to search from.
493
- * @param {Function} comparator The comparator invoked per element.
494
- * @returns {number} Returns the index of the matched value, else `-1`.
495
- */
496
- function baseIndexOfWith(array, value, fromIndex, comparator) {
497
- var index = fromIndex - 1,
498
- length = array.length;
499
-
500
- while (++index < length) {
501
- if (comparator(array[index], value)) {
502
- return index;
503
- }
504
- }
505
- return -1;
506
- }
507
-
508
- /**
509
- * The base implementation of `_.isNaN` without support for number objects.
510
- *
511
- * @private
512
- * @param {*} value The value to check.
513
- * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
514
- */
515
- function baseIsNaN$1(value) {
516
- return value !== value;
517
- }
518
-
519
- /**
520
- * The base implementation of `_.unary` without support for storing metadata.
521
- *
522
- * @private
523
- * @param {Function} func The function to cap arguments for.
524
- * @returns {Function} Returns the new capped function.
525
- */
526
- function baseUnary$1(func) {
527
- return function(value) {
528
- return func(value);
529
- };
530
- }
531
-
532
- /** Used for built-in method references. */
533
- var arrayProto$1 = Array.prototype;
534
-
535
- /** Built-in value references. */
536
- var splice$1 = arrayProto$1.splice;
537
-
538
- /**
539
- * The base implementation of `_.pullAllBy` without support for iteratee
540
- * shorthands.
541
- *
542
- * @private
543
- * @param {Array} array The array to modify.
544
- * @param {Array} values The values to remove.
545
- * @param {Function} [iteratee] The iteratee invoked per element.
546
- * @param {Function} [comparator] The comparator invoked per element.
547
- * @returns {Array} Returns `array`.
548
- */
549
- function basePullAll(array, values, iteratee, comparator) {
550
- var indexOf = comparator ? baseIndexOfWith : baseIndexOf$1,
551
- index = -1,
552
- length = values.length,
553
- seen = array;
554
-
555
- if (array === values) {
556
- values = copyArray(values);
557
- }
558
- if (iteratee) {
559
- seen = arrayMap$1(array, baseUnary$1(iteratee));
560
- }
561
- while (++index < length) {
562
- var fromIndex = 0,
563
- value = values[index],
564
- computed = iteratee ? iteratee(value) : value;
565
-
566
- while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
567
- if (seen !== array) {
568
- splice$1.call(seen, fromIndex, 1);
569
- }
570
- splice$1.call(array, fromIndex, 1);
571
- }
572
- }
573
- return array;
574
- }
575
-
576
- /**
577
- * Copies the values of `source` to `array`.
578
- *
579
- * @private
580
- * @param {Array} source The array to copy values from.
581
- * @param {Array} [array=[]] The array to copy values to.
582
- * @returns {Array} Returns `array`.
583
- */
584
- function copyArray(source, array) {
585
- var index = -1,
586
- length = source.length;
587
-
588
- array || (array = Array(length));
589
- while (++index < length) {
590
- array[index] = source[index];
591
- }
592
- return array;
593
- }
594
-
595
- /**
596
- * This method is like `_.pull` except that it accepts an array of values to remove.
597
- *
598
- * **Note:** Unlike `_.difference`, this method mutates `array`.
599
- *
600
- * @static
601
- * @memberOf _
602
- * @since 4.0.0
603
- * @category Array
604
- * @param {Array} array The array to modify.
605
- * @param {Array} values The values to remove.
606
- * @returns {Array} Returns `array`.
607
- * @example
608
- *
609
- * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
610
- *
611
- * _.pullAll(array, ['a', 'c']);
612
- * console.log(array);
613
- * // => ['b', 'b']
614
- */
615
- function pullAll(array, values) {
616
- return (array && array.length && values && values.length)
617
- ? basePullAll(array, values)
618
- : array;
619
- }
620
-
621
- var lodash_pullall = pullAll;
622
-
623
- var lodash_clonedeep = {exports: {}};
624
-
625
- /**
626
- * lodash (Custom Build) <https://lodash.com/>
627
- * Build: `lodash modularize exports="npm" -o ./`
628
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
629
- * Released under MIT license <https://lodash.com/license>
630
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
631
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
632
- */
633
-
634
- (function (module, exports) {
635
- /** Used as the size to enable large array optimizations. */
636
- var LARGE_ARRAY_SIZE = 200;
637
-
638
- /** Used to stand-in for `undefined` hash values. */
639
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
640
-
641
- /** Used as references for various `Number` constants. */
642
- var MAX_SAFE_INTEGER = 9007199254740991;
643
-
644
- /** `Object#toString` result references. */
645
- var argsTag = '[object Arguments]',
646
- arrayTag = '[object Array]',
647
- boolTag = '[object Boolean]',
648
- dateTag = '[object Date]',
649
- errorTag = '[object Error]',
650
- funcTag = '[object Function]',
651
- genTag = '[object GeneratorFunction]',
652
- mapTag = '[object Map]',
653
- numberTag = '[object Number]',
654
- objectTag = '[object Object]',
655
- promiseTag = '[object Promise]',
656
- regexpTag = '[object RegExp]',
657
- setTag = '[object Set]',
658
- stringTag = '[object String]',
659
- symbolTag = '[object Symbol]',
660
- weakMapTag = '[object WeakMap]';
661
-
662
- var arrayBufferTag = '[object ArrayBuffer]',
663
- dataViewTag = '[object DataView]',
664
- float32Tag = '[object Float32Array]',
665
- float64Tag = '[object Float64Array]',
666
- int8Tag = '[object Int8Array]',
667
- int16Tag = '[object Int16Array]',
668
- int32Tag = '[object Int32Array]',
669
- uint8Tag = '[object Uint8Array]',
670
- uint8ClampedTag = '[object Uint8ClampedArray]',
671
- uint16Tag = '[object Uint16Array]',
672
- uint32Tag = '[object Uint32Array]';
673
-
674
- /**
675
- * Used to match `RegExp`
676
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
677
- */
678
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
679
-
680
- /** Used to match `RegExp` flags from their coerced string values. */
681
- var reFlags = /\w*$/;
682
-
683
- /** Used to detect host constructors (Safari). */
684
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
685
-
686
- /** Used to detect unsigned integer values. */
687
- var reIsUint = /^(?:0|[1-9]\d*)$/;
688
-
689
- /** Used to identify `toStringTag` values supported by `_.clone`. */
690
- var cloneableTags = {};
691
- cloneableTags[argsTag] = cloneableTags[arrayTag] =
692
- cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
693
- cloneableTags[boolTag] = cloneableTags[dateTag] =
694
- cloneableTags[float32Tag] = cloneableTags[float64Tag] =
695
- cloneableTags[int8Tag] = cloneableTags[int16Tag] =
696
- cloneableTags[int32Tag] = cloneableTags[mapTag] =
697
- cloneableTags[numberTag] = cloneableTags[objectTag] =
698
- cloneableTags[regexpTag] = cloneableTags[setTag] =
699
- cloneableTags[stringTag] = cloneableTags[symbolTag] =
700
- cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
701
- cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
702
- cloneableTags[errorTag] = cloneableTags[funcTag] =
703
- cloneableTags[weakMapTag] = false;
704
-
705
- /** Detect free variable `global` from Node.js. */
706
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
707
-
708
- /** Detect free variable `self`. */
709
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
710
-
711
- /** Used as a reference to the global object. */
712
- var root = freeGlobal || freeSelf || Function('return this')();
713
-
714
- /** Detect free variable `exports`. */
715
- var freeExports = exports && !exports.nodeType && exports;
716
-
717
- /** Detect free variable `module`. */
718
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
719
-
720
- /** Detect the popular CommonJS extension `module.exports`. */
721
- var moduleExports = freeModule && freeModule.exports === freeExports;
722
-
723
- /**
724
- * Adds the key-value `pair` to `map`.
725
- *
726
- * @private
727
- * @param {Object} map The map to modify.
728
- * @param {Array} pair The key-value pair to add.
729
- * @returns {Object} Returns `map`.
730
- */
731
- function addMapEntry(map, pair) {
732
- // Don't return `map.set` because it's not chainable in IE 11.
733
- map.set(pair[0], pair[1]);
734
- return map;
735
- }
736
-
737
- /**
738
- * Adds `value` to `set`.
739
- *
740
- * @private
741
- * @param {Object} set The set to modify.
742
- * @param {*} value The value to add.
743
- * @returns {Object} Returns `set`.
744
- */
745
- function addSetEntry(set, value) {
746
- // Don't return `set.add` because it's not chainable in IE 11.
747
- set.add(value);
748
- return set;
749
- }
750
-
751
- /**
752
- * A specialized version of `_.forEach` for arrays without support for
753
- * iteratee shorthands.
754
- *
755
- * @private
756
- * @param {Array} [array] The array to iterate over.
757
- * @param {Function} iteratee The function invoked per iteration.
758
- * @returns {Array} Returns `array`.
759
- */
760
- function arrayEach(array, iteratee) {
761
- var index = -1,
762
- length = array ? array.length : 0;
763
-
764
- while (++index < length) {
765
- if (iteratee(array[index], index, array) === false) {
766
- break;
767
- }
768
- }
769
- return array;
770
- }
771
-
772
- /**
773
- * Appends the elements of `values` to `array`.
774
- *
775
- * @private
776
- * @param {Array} array The array to modify.
777
- * @param {Array} values The values to append.
778
- * @returns {Array} Returns `array`.
779
- */
780
- function arrayPush(array, values) {
781
- var index = -1,
782
- length = values.length,
783
- offset = array.length;
784
-
785
- while (++index < length) {
786
- array[offset + index] = values[index];
787
- }
788
- return array;
789
- }
790
-
791
- /**
792
- * A specialized version of `_.reduce` for arrays without support for
793
- * iteratee shorthands.
794
- *
795
- * @private
796
- * @param {Array} [array] The array to iterate over.
797
- * @param {Function} iteratee The function invoked per iteration.
798
- * @param {*} [accumulator] The initial value.
799
- * @param {boolean} [initAccum] Specify using the first element of `array` as
800
- * the initial value.
801
- * @returns {*} Returns the accumulated value.
802
- */
803
- function arrayReduce(array, iteratee, accumulator, initAccum) {
804
- var index = -1,
805
- length = array ? array.length : 0;
806
-
807
- if (initAccum && length) {
808
- accumulator = array[++index];
809
- }
810
- while (++index < length) {
811
- accumulator = iteratee(accumulator, array[index], index, array);
812
- }
813
- return accumulator;
814
- }
815
-
816
- /**
817
- * The base implementation of `_.times` without support for iteratee shorthands
818
- * or max array length checks.
819
- *
820
- * @private
821
- * @param {number} n The number of times to invoke `iteratee`.
822
- * @param {Function} iteratee The function invoked per iteration.
823
- * @returns {Array} Returns the array of results.
824
- */
825
- function baseTimes(n, iteratee) {
826
- var index = -1,
827
- result = Array(n);
828
-
829
- while (++index < n) {
830
- result[index] = iteratee(index);
831
- }
832
- return result;
833
- }
834
-
835
- /**
836
- * Gets the value at `key` of `object`.
837
- *
838
- * @private
839
- * @param {Object} [object] The object to query.
840
- * @param {string} key The key of the property to get.
841
- * @returns {*} Returns the property value.
842
- */
843
- function getValue(object, key) {
844
- return object == null ? undefined : object[key];
845
- }
846
-
847
- /**
848
- * Checks if `value` is a host object in IE < 9.
849
- *
850
- * @private
851
- * @param {*} value The value to check.
852
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
853
- */
854
- function isHostObject(value) {
855
- // Many host objects are `Object` objects that can coerce to strings
856
- // despite having improperly defined `toString` methods.
857
- var result = false;
858
- if (value != null && typeof value.toString != 'function') {
859
- try {
860
- result = !!(value + '');
861
- } catch (e) {}
862
- }
863
- return result;
864
- }
865
-
866
- /**
867
- * Converts `map` to its key-value pairs.
868
- *
869
- * @private
870
- * @param {Object} map The map to convert.
871
- * @returns {Array} Returns the key-value pairs.
872
- */
873
- function mapToArray(map) {
874
- var index = -1,
875
- result = Array(map.size);
876
-
877
- map.forEach(function(value, key) {
878
- result[++index] = [key, value];
879
- });
880
- return result;
881
- }
882
-
883
- /**
884
- * Creates a unary function that invokes `func` with its argument transformed.
885
- *
886
- * @private
887
- * @param {Function} func The function to wrap.
888
- * @param {Function} transform The argument transform.
889
- * @returns {Function} Returns the new function.
890
- */
891
- function overArg(func, transform) {
892
- return function(arg) {
893
- return func(transform(arg));
894
- };
895
- }
896
-
897
- /**
898
- * Converts `set` to an array of its values.
899
- *
900
- * @private
901
- * @param {Object} set The set to convert.
902
- * @returns {Array} Returns the values.
903
- */
904
- function setToArray(set) {
905
- var index = -1,
906
- result = Array(set.size);
907
-
908
- set.forEach(function(value) {
909
- result[++index] = value;
910
- });
911
- return result;
912
- }
913
-
914
- /** Used for built-in method references. */
915
- var arrayProto = Array.prototype,
916
- funcProto = Function.prototype,
917
- objectProto = Object.prototype;
918
-
919
- /** Used to detect overreaching core-js shims. */
920
- var coreJsData = root['__core-js_shared__'];
921
-
922
- /** Used to detect methods masquerading as native. */
923
- var maskSrcKey = (function() {
924
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
925
- return uid ? ('Symbol(src)_1.' + uid) : '';
926
- }());
927
-
928
- /** Used to resolve the decompiled source of functions. */
929
- var funcToString = funcProto.toString;
930
-
931
- /** Used to check objects for own properties. */
932
- var hasOwnProperty = objectProto.hasOwnProperty;
933
-
934
- /**
935
- * Used to resolve the
936
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
937
- * of values.
938
- */
939
- var objectToString = objectProto.toString;
940
-
941
- /** Used to detect if a method is native. */
942
- var reIsNative = RegExp('^' +
943
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
944
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
945
- );
946
-
947
- /** Built-in value references. */
948
- var Buffer = moduleExports ? root.Buffer : undefined,
949
- Symbol = root.Symbol,
950
- Uint8Array = root.Uint8Array,
951
- getPrototype = overArg(Object.getPrototypeOf, Object),
952
- objectCreate = Object.create,
953
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
954
- splice = arrayProto.splice;
955
-
956
- /* Built-in method references for those with the same name as other `lodash` methods. */
957
- var nativeGetSymbols = Object.getOwnPropertySymbols,
958
- nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
959
- nativeKeys = overArg(Object.keys, Object);
960
-
961
- /* Built-in method references that are verified to be native. */
962
- var DataView = getNative(root, 'DataView'),
963
- Map = getNative(root, 'Map'),
964
- Promise = getNative(root, 'Promise'),
965
- Set = getNative(root, 'Set'),
966
- WeakMap = getNative(root, 'WeakMap'),
967
- nativeCreate = getNative(Object, 'create');
968
-
969
- /** Used to detect maps, sets, and weakmaps. */
970
- var dataViewCtorString = toSource(DataView),
971
- mapCtorString = toSource(Map),
972
- promiseCtorString = toSource(Promise),
973
- setCtorString = toSource(Set),
974
- weakMapCtorString = toSource(WeakMap);
975
-
976
- /** Used to convert symbols to primitives and strings. */
977
- var symbolProto = Symbol ? Symbol.prototype : undefined,
978
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
979
-
980
- /**
981
- * Creates a hash object.
982
- *
983
- * @private
984
- * @constructor
985
- * @param {Array} [entries] The key-value pairs to cache.
986
- */
987
- function Hash(entries) {
988
- var index = -1,
989
- length = entries ? entries.length : 0;
990
-
991
- this.clear();
992
- while (++index < length) {
993
- var entry = entries[index];
994
- this.set(entry[0], entry[1]);
995
- }
996
- }
997
-
998
- /**
999
- * Removes all key-value entries from the hash.
1000
- *
1001
- * @private
1002
- * @name clear
1003
- * @memberOf Hash
1004
- */
1005
- function hashClear() {
1006
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
1007
- }
1008
-
1009
- /**
1010
- * Removes `key` and its value from the hash.
1011
- *
1012
- * @private
1013
- * @name delete
1014
- * @memberOf Hash
1015
- * @param {Object} hash The hash to modify.
1016
- * @param {string} key The key of the value to remove.
1017
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1018
- */
1019
- function hashDelete(key) {
1020
- return this.has(key) && delete this.__data__[key];
1021
- }
1022
-
1023
- /**
1024
- * Gets the hash value for `key`.
1025
- *
1026
- * @private
1027
- * @name get
1028
- * @memberOf Hash
1029
- * @param {string} key The key of the value to get.
1030
- * @returns {*} Returns the entry value.
1031
- */
1032
- function hashGet(key) {
1033
- var data = this.__data__;
1034
- if (nativeCreate) {
1035
- var result = data[key];
1036
- return result === HASH_UNDEFINED ? undefined : result;
1037
- }
1038
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
1039
- }
1040
-
1041
- /**
1042
- * Checks if a hash value for `key` exists.
1043
- *
1044
- * @private
1045
- * @name has
1046
- * @memberOf Hash
1047
- * @param {string} key The key of the entry to check.
1048
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1049
- */
1050
- function hashHas(key) {
1051
- var data = this.__data__;
1052
- return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
1053
- }
1054
-
1055
- /**
1056
- * Sets the hash `key` to `value`.
1057
- *
1058
- * @private
1059
- * @name set
1060
- * @memberOf Hash
1061
- * @param {string} key The key of the value to set.
1062
- * @param {*} value The value to set.
1063
- * @returns {Object} Returns the hash instance.
1064
- */
1065
- function hashSet(key, value) {
1066
- var data = this.__data__;
1067
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1068
- return this;
1069
- }
1070
-
1071
- // Add methods to `Hash`.
1072
- Hash.prototype.clear = hashClear;
1073
- Hash.prototype['delete'] = hashDelete;
1074
- Hash.prototype.get = hashGet;
1075
- Hash.prototype.has = hashHas;
1076
- Hash.prototype.set = hashSet;
1077
-
1078
- /**
1079
- * Creates an list cache object.
1080
- *
1081
- * @private
1082
- * @constructor
1083
- * @param {Array} [entries] The key-value pairs to cache.
1084
- */
1085
- function ListCache(entries) {
1086
- var index = -1,
1087
- length = entries ? entries.length : 0;
1088
-
1089
- this.clear();
1090
- while (++index < length) {
1091
- var entry = entries[index];
1092
- this.set(entry[0], entry[1]);
1093
- }
1094
- }
1095
-
1096
- /**
1097
- * Removes all key-value entries from the list cache.
1098
- *
1099
- * @private
1100
- * @name clear
1101
- * @memberOf ListCache
1102
- */
1103
- function listCacheClear() {
1104
- this.__data__ = [];
1105
- }
1106
-
1107
- /**
1108
- * Removes `key` and its value from the list cache.
1109
- *
1110
- * @private
1111
- * @name delete
1112
- * @memberOf ListCache
1113
- * @param {string} key The key of the value to remove.
1114
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1115
- */
1116
- function listCacheDelete(key) {
1117
- var data = this.__data__,
1118
- index = assocIndexOf(data, key);
1119
-
1120
- if (index < 0) {
1121
- return false;
1122
- }
1123
- var lastIndex = data.length - 1;
1124
- if (index == lastIndex) {
1125
- data.pop();
1126
- } else {
1127
- splice.call(data, index, 1);
1128
- }
1129
- return true;
1130
- }
1131
-
1132
- /**
1133
- * Gets the list cache value for `key`.
1134
- *
1135
- * @private
1136
- * @name get
1137
- * @memberOf ListCache
1138
- * @param {string} key The key of the value to get.
1139
- * @returns {*} Returns the entry value.
1140
- */
1141
- function listCacheGet(key) {
1142
- var data = this.__data__,
1143
- index = assocIndexOf(data, key);
1144
-
1145
- return index < 0 ? undefined : data[index][1];
1146
- }
1147
-
1148
- /**
1149
- * Checks if a list cache value for `key` exists.
1150
- *
1151
- * @private
1152
- * @name has
1153
- * @memberOf ListCache
1154
- * @param {string} key The key of the entry to check.
1155
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1156
- */
1157
- function listCacheHas(key) {
1158
- return assocIndexOf(this.__data__, key) > -1;
1159
- }
1160
-
1161
- /**
1162
- * Sets the list cache `key` to `value`.
1163
- *
1164
- * @private
1165
- * @name set
1166
- * @memberOf ListCache
1167
- * @param {string} key The key of the value to set.
1168
- * @param {*} value The value to set.
1169
- * @returns {Object} Returns the list cache instance.
1170
- */
1171
- function listCacheSet(key, value) {
1172
- var data = this.__data__,
1173
- index = assocIndexOf(data, key);
1174
-
1175
- if (index < 0) {
1176
- data.push([key, value]);
1177
- } else {
1178
- data[index][1] = value;
1179
- }
1180
- return this;
1181
- }
1182
-
1183
- // Add methods to `ListCache`.
1184
- ListCache.prototype.clear = listCacheClear;
1185
- ListCache.prototype['delete'] = listCacheDelete;
1186
- ListCache.prototype.get = listCacheGet;
1187
- ListCache.prototype.has = listCacheHas;
1188
- ListCache.prototype.set = listCacheSet;
1189
-
1190
- /**
1191
- * Creates a map cache object to store key-value pairs.
1192
- *
1193
- * @private
1194
- * @constructor
1195
- * @param {Array} [entries] The key-value pairs to cache.
1196
- */
1197
- function MapCache(entries) {
1198
- var index = -1,
1199
- length = entries ? entries.length : 0;
1200
-
1201
- this.clear();
1202
- while (++index < length) {
1203
- var entry = entries[index];
1204
- this.set(entry[0], entry[1]);
1205
- }
1206
- }
1207
-
1208
- /**
1209
- * Removes all key-value entries from the map.
1210
- *
1211
- * @private
1212
- * @name clear
1213
- * @memberOf MapCache
1214
- */
1215
- function mapCacheClear() {
1216
- this.__data__ = {
1217
- 'hash': new Hash,
1218
- 'map': new (Map || ListCache),
1219
- 'string': new Hash
1220
- };
1221
- }
1222
-
1223
- /**
1224
- * Removes `key` and its value from the map.
1225
- *
1226
- * @private
1227
- * @name delete
1228
- * @memberOf MapCache
1229
- * @param {string} key The key of the value to remove.
1230
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1231
- */
1232
- function mapCacheDelete(key) {
1233
- return getMapData(this, key)['delete'](key);
1234
- }
1235
-
1236
- /**
1237
- * Gets the map value for `key`.
1238
- *
1239
- * @private
1240
- * @name get
1241
- * @memberOf MapCache
1242
- * @param {string} key The key of the value to get.
1243
- * @returns {*} Returns the entry value.
1244
- */
1245
- function mapCacheGet(key) {
1246
- return getMapData(this, key).get(key);
1247
- }
1248
-
1249
- /**
1250
- * Checks if a map value for `key` exists.
1251
- *
1252
- * @private
1253
- * @name has
1254
- * @memberOf MapCache
1255
- * @param {string} key The key of the entry to check.
1256
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1257
- */
1258
- function mapCacheHas(key) {
1259
- return getMapData(this, key).has(key);
1260
- }
1261
-
1262
- /**
1263
- * Sets the map `key` to `value`.
1264
- *
1265
- * @private
1266
- * @name set
1267
- * @memberOf MapCache
1268
- * @param {string} key The key of the value to set.
1269
- * @param {*} value The value to set.
1270
- * @returns {Object} Returns the map cache instance.
1271
- */
1272
- function mapCacheSet(key, value) {
1273
- getMapData(this, key).set(key, value);
1274
- return this;
1275
- }
1276
-
1277
- // Add methods to `MapCache`.
1278
- MapCache.prototype.clear = mapCacheClear;
1279
- MapCache.prototype['delete'] = mapCacheDelete;
1280
- MapCache.prototype.get = mapCacheGet;
1281
- MapCache.prototype.has = mapCacheHas;
1282
- MapCache.prototype.set = mapCacheSet;
1283
-
1284
- /**
1285
- * Creates a stack cache object to store key-value pairs.
1286
- *
1287
- * @private
1288
- * @constructor
1289
- * @param {Array} [entries] The key-value pairs to cache.
1290
- */
1291
- function Stack(entries) {
1292
- this.__data__ = new ListCache(entries);
1293
- }
1294
-
1295
- /**
1296
- * Removes all key-value entries from the stack.
1297
- *
1298
- * @private
1299
- * @name clear
1300
- * @memberOf Stack
1301
- */
1302
- function stackClear() {
1303
- this.__data__ = new ListCache;
1304
- }
1305
-
1306
- /**
1307
- * Removes `key` and its value from the stack.
1308
- *
1309
- * @private
1310
- * @name delete
1311
- * @memberOf Stack
1312
- * @param {string} key The key of the value to remove.
1313
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1314
- */
1315
- function stackDelete(key) {
1316
- return this.__data__['delete'](key);
1317
- }
1318
-
1319
- /**
1320
- * Gets the stack value for `key`.
1321
- *
1322
- * @private
1323
- * @name get
1324
- * @memberOf Stack
1325
- * @param {string} key The key of the value to get.
1326
- * @returns {*} Returns the entry value.
1327
- */
1328
- function stackGet(key) {
1329
- return this.__data__.get(key);
1330
- }
1331
-
1332
- /**
1333
- * Checks if a stack value for `key` exists.
1334
- *
1335
- * @private
1336
- * @name has
1337
- * @memberOf Stack
1338
- * @param {string} key The key of the entry to check.
1339
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1340
- */
1341
- function stackHas(key) {
1342
- return this.__data__.has(key);
1343
- }
1344
-
1345
- /**
1346
- * Sets the stack `key` to `value`.
1347
- *
1348
- * @private
1349
- * @name set
1350
- * @memberOf Stack
1351
- * @param {string} key The key of the value to set.
1352
- * @param {*} value The value to set.
1353
- * @returns {Object} Returns the stack cache instance.
1354
- */
1355
- function stackSet(key, value) {
1356
- var cache = this.__data__;
1357
- if (cache instanceof ListCache) {
1358
- var pairs = cache.__data__;
1359
- if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
1360
- pairs.push([key, value]);
1361
- return this;
1362
- }
1363
- cache = this.__data__ = new MapCache(pairs);
1364
- }
1365
- cache.set(key, value);
1366
- return this;
1367
- }
1368
-
1369
- // Add methods to `Stack`.
1370
- Stack.prototype.clear = stackClear;
1371
- Stack.prototype['delete'] = stackDelete;
1372
- Stack.prototype.get = stackGet;
1373
- Stack.prototype.has = stackHas;
1374
- Stack.prototype.set = stackSet;
1375
-
1376
- /**
1377
- * Creates an array of the enumerable property names of the array-like `value`.
1378
- *
1379
- * @private
1380
- * @param {*} value The value to query.
1381
- * @param {boolean} inherited Specify returning inherited property names.
1382
- * @returns {Array} Returns the array of property names.
1383
- */
1384
- function arrayLikeKeys(value, inherited) {
1385
- // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1386
- // Safari 9 makes `arguments.length` enumerable in strict mode.
1387
- var result = (isArray(value) || isArguments(value))
1388
- ? baseTimes(value.length, String)
1389
- : [];
1390
-
1391
- var length = result.length,
1392
- skipIndexes = !!length;
1393
-
1394
- for (var key in value) {
1395
- if ((inherited || hasOwnProperty.call(value, key)) &&
1396
- !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
1397
- result.push(key);
1398
- }
1399
- }
1400
- return result;
1401
- }
1402
-
1403
- /**
1404
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
1405
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1406
- * for equality comparisons.
1407
- *
1408
- * @private
1409
- * @param {Object} object The object to modify.
1410
- * @param {string} key The key of the property to assign.
1411
- * @param {*} value The value to assign.
1412
- */
1413
- function assignValue(object, key, value) {
1414
- var objValue = object[key];
1415
- if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
1416
- (value === undefined && !(key in object))) {
1417
- object[key] = value;
1418
- }
1419
- }
1420
-
1421
- /**
1422
- * Gets the index at which the `key` is found in `array` of key-value pairs.
1423
- *
1424
- * @private
1425
- * @param {Array} array The array to inspect.
1426
- * @param {*} key The key to search for.
1427
- * @returns {number} Returns the index of the matched value, else `-1`.
1428
- */
1429
- function assocIndexOf(array, key) {
1430
- var length = array.length;
1431
- while (length--) {
1432
- if (eq(array[length][0], key)) {
1433
- return length;
1434
- }
1435
- }
1436
- return -1;
1437
- }
1438
-
1439
- /**
1440
- * The base implementation of `_.assign` without support for multiple sources
1441
- * or `customizer` functions.
1442
- *
1443
- * @private
1444
- * @param {Object} object The destination object.
1445
- * @param {Object} source The source object.
1446
- * @returns {Object} Returns `object`.
1447
- */
1448
- function baseAssign(object, source) {
1449
- return object && copyObject(source, keys(source), object);
1450
- }
1451
-
1452
- /**
1453
- * The base implementation of `_.clone` and `_.cloneDeep` which tracks
1454
- * traversed objects.
1455
- *
1456
- * @private
1457
- * @param {*} value The value to clone.
1458
- * @param {boolean} [isDeep] Specify a deep clone.
1459
- * @param {boolean} [isFull] Specify a clone including symbols.
1460
- * @param {Function} [customizer] The function to customize cloning.
1461
- * @param {string} [key] The key of `value`.
1462
- * @param {Object} [object] The parent object of `value`.
1463
- * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
1464
- * @returns {*} Returns the cloned value.
1465
- */
1466
- function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
1467
- var result;
1468
- if (customizer) {
1469
- result = object ? customizer(value, key, object, stack) : customizer(value);
1470
- }
1471
- if (result !== undefined) {
1472
- return result;
1473
- }
1474
- if (!isObject(value)) {
1475
- return value;
1476
- }
1477
- var isArr = isArray(value);
1478
- if (isArr) {
1479
- result = initCloneArray(value);
1480
- if (!isDeep) {
1481
- return copyArray(value, result);
1482
- }
1483
- } else {
1484
- var tag = getTag(value),
1485
- isFunc = tag == funcTag || tag == genTag;
1486
-
1487
- if (isBuffer(value)) {
1488
- return cloneBuffer(value, isDeep);
1489
- }
1490
- if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
1491
- if (isHostObject(value)) {
1492
- return object ? value : {};
1493
- }
1494
- result = initCloneObject(isFunc ? {} : value);
1495
- if (!isDeep) {
1496
- return copySymbols(value, baseAssign(result, value));
1497
- }
1498
- } else {
1499
- if (!cloneableTags[tag]) {
1500
- return object ? value : {};
1501
- }
1502
- result = initCloneByTag(value, tag, baseClone, isDeep);
1503
- }
1504
- }
1505
- // Check for circular references and return its corresponding clone.
1506
- stack || (stack = new Stack);
1507
- var stacked = stack.get(value);
1508
- if (stacked) {
1509
- return stacked;
1510
- }
1511
- stack.set(value, result);
1512
-
1513
- if (!isArr) {
1514
- var props = isFull ? getAllKeys(value) : keys(value);
1515
- }
1516
- arrayEach(props || value, function(subValue, key) {
1517
- if (props) {
1518
- key = subValue;
1519
- subValue = value[key];
1520
- }
1521
- // Recursively populate clone (susceptible to call stack limits).
1522
- assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
1523
- });
1524
- return result;
1525
- }
1526
-
1527
- /**
1528
- * The base implementation of `_.create` without support for assigning
1529
- * properties to the created object.
1530
- *
1531
- * @private
1532
- * @param {Object} prototype The object to inherit from.
1533
- * @returns {Object} Returns the new object.
1534
- */
1535
- function baseCreate(proto) {
1536
- return isObject(proto) ? objectCreate(proto) : {};
1537
- }
1538
-
1539
- /**
1540
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
1541
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
1542
- * symbols of `object`.
1543
- *
1544
- * @private
1545
- * @param {Object} object The object to query.
1546
- * @param {Function} keysFunc The function to get the keys of `object`.
1547
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
1548
- * @returns {Array} Returns the array of property names and symbols.
1549
- */
1550
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1551
- var result = keysFunc(object);
1552
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
1553
- }
1554
-
1555
- /**
1556
- * The base implementation of `getTag`.
1557
- *
1558
- * @private
1559
- * @param {*} value The value to query.
1560
- * @returns {string} Returns the `toStringTag`.
1561
- */
1562
- function baseGetTag(value) {
1563
- return objectToString.call(value);
1564
- }
1565
-
1566
- /**
1567
- * The base implementation of `_.isNative` without bad shim checks.
1568
- *
1569
- * @private
1570
- * @param {*} value The value to check.
1571
- * @returns {boolean} Returns `true` if `value` is a native function,
1572
- * else `false`.
1573
- */
1574
- function baseIsNative(value) {
1575
- if (!isObject(value) || isMasked(value)) {
1576
- return false;
1577
- }
1578
- var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
1579
- return pattern.test(toSource(value));
1580
- }
1581
-
1582
- /**
1583
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1584
- *
1585
- * @private
1586
- * @param {Object} object The object to query.
1587
- * @returns {Array} Returns the array of property names.
1588
- */
1589
- function baseKeys(object) {
1590
- if (!isPrototype(object)) {
1591
- return nativeKeys(object);
1592
- }
1593
- var result = [];
1594
- for (var key in Object(object)) {
1595
- if (hasOwnProperty.call(object, key) && key != 'constructor') {
1596
- result.push(key);
1597
- }
1598
- }
1599
- return result;
1600
- }
1601
-
1602
- /**
1603
- * Creates a clone of `buffer`.
1604
- *
1605
- * @private
1606
- * @param {Buffer} buffer The buffer to clone.
1607
- * @param {boolean} [isDeep] Specify a deep clone.
1608
- * @returns {Buffer} Returns the cloned buffer.
1609
- */
1610
- function cloneBuffer(buffer, isDeep) {
1611
- if (isDeep) {
1612
- return buffer.slice();
1613
- }
1614
- var result = new buffer.constructor(buffer.length);
1615
- buffer.copy(result);
1616
- return result;
1617
- }
1618
-
1619
- /**
1620
- * Creates a clone of `arrayBuffer`.
1621
- *
1622
- * @private
1623
- * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
1624
- * @returns {ArrayBuffer} Returns the cloned array buffer.
1625
- */
1626
- function cloneArrayBuffer(arrayBuffer) {
1627
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1628
- new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1629
- return result;
1630
- }
1631
-
1632
- /**
1633
- * Creates a clone of `dataView`.
1634
- *
1635
- * @private
1636
- * @param {Object} dataView The data view to clone.
1637
- * @param {boolean} [isDeep] Specify a deep clone.
1638
- * @returns {Object} Returns the cloned data view.
1639
- */
1640
- function cloneDataView(dataView, isDeep) {
1641
- var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
1642
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
1643
- }
1644
-
1645
- /**
1646
- * Creates a clone of `map`.
1647
- *
1648
- * @private
1649
- * @param {Object} map The map to clone.
1650
- * @param {Function} cloneFunc The function to clone values.
1651
- * @param {boolean} [isDeep] Specify a deep clone.
1652
- * @returns {Object} Returns the cloned map.
1653
- */
1654
- function cloneMap(map, isDeep, cloneFunc) {
1655
- var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
1656
- return arrayReduce(array, addMapEntry, new map.constructor);
1657
- }
1658
-
1659
- /**
1660
- * Creates a clone of `regexp`.
1661
- *
1662
- * @private
1663
- * @param {Object} regexp The regexp to clone.
1664
- * @returns {Object} Returns the cloned regexp.
1665
- */
1666
- function cloneRegExp(regexp) {
1667
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
1668
- result.lastIndex = regexp.lastIndex;
1669
- return result;
1670
- }
1671
-
1672
- /**
1673
- * Creates a clone of `set`.
1674
- *
1675
- * @private
1676
- * @param {Object} set The set to clone.
1677
- * @param {Function} cloneFunc The function to clone values.
1678
- * @param {boolean} [isDeep] Specify a deep clone.
1679
- * @returns {Object} Returns the cloned set.
1680
- */
1681
- function cloneSet(set, isDeep, cloneFunc) {
1682
- var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
1683
- return arrayReduce(array, addSetEntry, new set.constructor);
1684
- }
1685
-
1686
- /**
1687
- * Creates a clone of the `symbol` object.
1688
- *
1689
- * @private
1690
- * @param {Object} symbol The symbol object to clone.
1691
- * @returns {Object} Returns the cloned symbol object.
1692
- */
1693
- function cloneSymbol(symbol) {
1694
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
1695
- }
1696
-
1697
- /**
1698
- * Creates a clone of `typedArray`.
1699
- *
1700
- * @private
1701
- * @param {Object} typedArray The typed array to clone.
1702
- * @param {boolean} [isDeep] Specify a deep clone.
1703
- * @returns {Object} Returns the cloned typed array.
1704
- */
1705
- function cloneTypedArray(typedArray, isDeep) {
1706
- var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1707
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1708
- }
1709
-
1710
- /**
1711
- * Copies the values of `source` to `array`.
1712
- *
1713
- * @private
1714
- * @param {Array} source The array to copy values from.
1715
- * @param {Array} [array=[]] The array to copy values to.
1716
- * @returns {Array} Returns `array`.
1717
- */
1718
- function copyArray(source, array) {
1719
- var index = -1,
1720
- length = source.length;
1721
-
1722
- array || (array = Array(length));
1723
- while (++index < length) {
1724
- array[index] = source[index];
1725
- }
1726
- return array;
1727
- }
1728
-
1729
- /**
1730
- * Copies properties of `source` to `object`.
1731
- *
1732
- * @private
1733
- * @param {Object} source The object to copy properties from.
1734
- * @param {Array} props The property identifiers to copy.
1735
- * @param {Object} [object={}] The object to copy properties to.
1736
- * @param {Function} [customizer] The function to customize copied values.
1737
- * @returns {Object} Returns `object`.
1738
- */
1739
- function copyObject(source, props, object, customizer) {
1740
- object || (object = {});
1741
-
1742
- var index = -1,
1743
- length = props.length;
1744
-
1745
- while (++index < length) {
1746
- var key = props[index];
1747
-
1748
- var newValue = customizer
1749
- ? customizer(object[key], source[key], key, object, source)
1750
- : undefined;
1751
-
1752
- assignValue(object, key, newValue === undefined ? source[key] : newValue);
1753
- }
1754
- return object;
1755
- }
1756
-
1757
- /**
1758
- * Copies own symbol properties of `source` to `object`.
1759
- *
1760
- * @private
1761
- * @param {Object} source The object to copy symbols from.
1762
- * @param {Object} [object={}] The object to copy symbols to.
1763
- * @returns {Object} Returns `object`.
1764
- */
1765
- function copySymbols(source, object) {
1766
- return copyObject(source, getSymbols(source), object);
1767
- }
1768
-
1769
- /**
1770
- * Creates an array of own enumerable property names and symbols of `object`.
1771
- *
1772
- * @private
1773
- * @param {Object} object The object to query.
1774
- * @returns {Array} Returns the array of property names and symbols.
1775
- */
1776
- function getAllKeys(object) {
1777
- return baseGetAllKeys(object, keys, getSymbols);
1778
- }
1779
-
1780
- /**
1781
- * Gets the data for `map`.
1782
- *
1783
- * @private
1784
- * @param {Object} map The map to query.
1785
- * @param {string} key The reference key.
1786
- * @returns {*} Returns the map data.
1787
- */
1788
- function getMapData(map, key) {
1789
- var data = map.__data__;
1790
- return isKeyable(key)
1791
- ? data[typeof key == 'string' ? 'string' : 'hash']
1792
- : data.map;
1793
- }
1794
-
1795
- /**
1796
- * Gets the native function at `key` of `object`.
1797
- *
1798
- * @private
1799
- * @param {Object} object The object to query.
1800
- * @param {string} key The key of the method to get.
1801
- * @returns {*} Returns the function if it's native, else `undefined`.
1802
- */
1803
- function getNative(object, key) {
1804
- var value = getValue(object, key);
1805
- return baseIsNative(value) ? value : undefined;
1806
- }
1807
-
1808
- /**
1809
- * Creates an array of the own enumerable symbol properties of `object`.
1810
- *
1811
- * @private
1812
- * @param {Object} object The object to query.
1813
- * @returns {Array} Returns the array of symbols.
1814
- */
1815
- var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
1816
-
1817
- /**
1818
- * Gets the `toStringTag` of `value`.
1819
- *
1820
- * @private
1821
- * @param {*} value The value to query.
1822
- * @returns {string} Returns the `toStringTag`.
1823
- */
1824
- var getTag = baseGetTag;
1825
-
1826
- // Fallback for data views, maps, sets, and weak maps in IE 11,
1827
- // for data views in Edge < 14, and promises in Node.js.
1828
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1829
- (Map && getTag(new Map) != mapTag) ||
1830
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
1831
- (Set && getTag(new Set) != setTag) ||
1832
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1833
- getTag = function(value) {
1834
- var result = objectToString.call(value),
1835
- Ctor = result == objectTag ? value.constructor : undefined,
1836
- ctorString = Ctor ? toSource(Ctor) : undefined;
1837
-
1838
- if (ctorString) {
1839
- switch (ctorString) {
1840
- case dataViewCtorString: return dataViewTag;
1841
- case mapCtorString: return mapTag;
1842
- case promiseCtorString: return promiseTag;
1843
- case setCtorString: return setTag;
1844
- case weakMapCtorString: return weakMapTag;
1845
- }
1846
- }
1847
- return result;
1848
- };
1849
- }
1850
-
1851
- /**
1852
- * Initializes an array clone.
1853
- *
1854
- * @private
1855
- * @param {Array} array The array to clone.
1856
- * @returns {Array} Returns the initialized clone.
1857
- */
1858
- function initCloneArray(array) {
1859
- var length = array.length,
1860
- result = array.constructor(length);
1861
-
1862
- // Add properties assigned by `RegExp#exec`.
1863
- if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
1864
- result.index = array.index;
1865
- result.input = array.input;
1866
- }
1867
- return result;
1868
- }
1869
-
1870
- /**
1871
- * Initializes an object clone.
1872
- *
1873
- * @private
1874
- * @param {Object} object The object to clone.
1875
- * @returns {Object} Returns the initialized clone.
1876
- */
1877
- function initCloneObject(object) {
1878
- return (typeof object.constructor == 'function' && !isPrototype(object))
1879
- ? baseCreate(getPrototype(object))
1880
- : {};
1881
- }
1882
-
1883
- /**
1884
- * Initializes an object clone based on its `toStringTag`.
1885
- *
1886
- * **Note:** This function only supports cloning values with tags of
1887
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1888
- *
1889
- * @private
1890
- * @param {Object} object The object to clone.
1891
- * @param {string} tag The `toStringTag` of the object to clone.
1892
- * @param {Function} cloneFunc The function to clone values.
1893
- * @param {boolean} [isDeep] Specify a deep clone.
1894
- * @returns {Object} Returns the initialized clone.
1895
- */
1896
- function initCloneByTag(object, tag, cloneFunc, isDeep) {
1897
- var Ctor = object.constructor;
1898
- switch (tag) {
1899
- case arrayBufferTag:
1900
- return cloneArrayBuffer(object);
1901
-
1902
- case boolTag:
1903
- case dateTag:
1904
- return new Ctor(+object);
1905
-
1906
- case dataViewTag:
1907
- return cloneDataView(object, isDeep);
1908
-
1909
- case float32Tag: case float64Tag:
1910
- case int8Tag: case int16Tag: case int32Tag:
1911
- case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
1912
- return cloneTypedArray(object, isDeep);
1913
-
1914
- case mapTag:
1915
- return cloneMap(object, isDeep, cloneFunc);
1916
-
1917
- case numberTag:
1918
- case stringTag:
1919
- return new Ctor(object);
1920
-
1921
- case regexpTag:
1922
- return cloneRegExp(object);
1923
-
1924
- case setTag:
1925
- return cloneSet(object, isDeep, cloneFunc);
1926
-
1927
- case symbolTag:
1928
- return cloneSymbol(object);
1929
- }
1930
- }
1931
-
1932
- /**
1933
- * Checks if `value` is a valid array-like index.
1934
- *
1935
- * @private
1936
- * @param {*} value The value to check.
1937
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1938
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1939
- */
1940
- function isIndex(value, length) {
1941
- length = length == null ? MAX_SAFE_INTEGER : length;
1942
- return !!length &&
1943
- (typeof value == 'number' || reIsUint.test(value)) &&
1944
- (value > -1 && value % 1 == 0 && value < length);
1945
- }
1946
-
1947
- /**
1948
- * Checks if `value` is suitable for use as unique object key.
1949
- *
1950
- * @private
1951
- * @param {*} value The value to check.
1952
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1953
- */
1954
- function isKeyable(value) {
1955
- var type = typeof value;
1956
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1957
- ? (value !== '__proto__')
1958
- : (value === null);
1959
- }
1960
-
1961
- /**
1962
- * Checks if `func` has its source masked.
1963
- *
1964
- * @private
1965
- * @param {Function} func The function to check.
1966
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1967
- */
1968
- function isMasked(func) {
1969
- return !!maskSrcKey && (maskSrcKey in func);
1970
- }
1971
-
1972
- /**
1973
- * Checks if `value` is likely a prototype object.
1974
- *
1975
- * @private
1976
- * @param {*} value The value to check.
1977
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1978
- */
1979
- function isPrototype(value) {
1980
- var Ctor = value && value.constructor,
1981
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1982
-
1983
- return value === proto;
1984
- }
1985
-
1986
- /**
1987
- * Converts `func` to its source code.
1988
- *
1989
- * @private
1990
- * @param {Function} func The function to process.
1991
- * @returns {string} Returns the source code.
1992
- */
1993
- function toSource(func) {
1994
- if (func != null) {
1995
- try {
1996
- return funcToString.call(func);
1997
- } catch (e) {}
1998
- try {
1999
- return (func + '');
2000
- } catch (e) {}
2001
- }
2002
- return '';
2003
- }
2004
-
2005
- /**
2006
- * This method is like `_.clone` except that it recursively clones `value`.
2007
- *
2008
- * @static
2009
- * @memberOf _
2010
- * @since 1.0.0
2011
- * @category Lang
2012
- * @param {*} value The value to recursively clone.
2013
- * @returns {*} Returns the deep cloned value.
2014
- * @see _.clone
2015
- * @example
2016
- *
2017
- * var objects = [{ 'a': 1 }, { 'b': 2 }];
2018
- *
2019
- * var deep = _.cloneDeep(objects);
2020
- * console.log(deep[0] === objects[0]);
2021
- * // => false
2022
- */
2023
- function cloneDeep(value) {
2024
- return baseClone(value, true, true);
2025
- }
2026
-
2027
- /**
2028
- * Performs a
2029
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2030
- * comparison between two values to determine if they are equivalent.
2031
- *
2032
- * @static
2033
- * @memberOf _
2034
- * @since 4.0.0
2035
- * @category Lang
2036
- * @param {*} value The value to compare.
2037
- * @param {*} other The other value to compare.
2038
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2039
- * @example
2040
- *
2041
- * var object = { 'a': 1 };
2042
- * var other = { 'a': 1 };
2043
- *
2044
- * _.eq(object, object);
2045
- * // => true
2046
- *
2047
- * _.eq(object, other);
2048
- * // => false
2049
- *
2050
- * _.eq('a', 'a');
2051
- * // => true
2052
- *
2053
- * _.eq('a', Object('a'));
2054
- * // => false
2055
- *
2056
- * _.eq(NaN, NaN);
2057
- * // => true
2058
- */
2059
- function eq(value, other) {
2060
- return value === other || (value !== value && other !== other);
2061
- }
2062
-
2063
- /**
2064
- * Checks if `value` is likely an `arguments` object.
2065
- *
2066
- * @static
2067
- * @memberOf _
2068
- * @since 0.1.0
2069
- * @category Lang
2070
- * @param {*} value The value to check.
2071
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2072
- * else `false`.
2073
- * @example
2074
- *
2075
- * _.isArguments(function() { return arguments; }());
2076
- * // => true
2077
- *
2078
- * _.isArguments([1, 2, 3]);
2079
- * // => false
2080
- */
2081
- function isArguments(value) {
2082
- // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
2083
- return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
2084
- (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
2085
- }
2086
-
2087
- /**
2088
- * Checks if `value` is classified as an `Array` object.
2089
- *
2090
- * @static
2091
- * @memberOf _
2092
- * @since 0.1.0
2093
- * @category Lang
2094
- * @param {*} value The value to check.
2095
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
2096
- * @example
2097
- *
2098
- * _.isArray([1, 2, 3]);
2099
- * // => true
2100
- *
2101
- * _.isArray(document.body.children);
2102
- * // => false
2103
- *
2104
- * _.isArray('abc');
2105
- * // => false
2106
- *
2107
- * _.isArray(_.noop);
2108
- * // => false
2109
- */
2110
- var isArray = Array.isArray;
2111
-
2112
- /**
2113
- * Checks if `value` is array-like. A value is considered array-like if it's
2114
- * not a function and has a `value.length` that's an integer greater than or
2115
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2116
- *
2117
- * @static
2118
- * @memberOf _
2119
- * @since 4.0.0
2120
- * @category Lang
2121
- * @param {*} value The value to check.
2122
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2123
- * @example
2124
- *
2125
- * _.isArrayLike([1, 2, 3]);
2126
- * // => true
2127
- *
2128
- * _.isArrayLike(document.body.children);
2129
- * // => true
2130
- *
2131
- * _.isArrayLike('abc');
2132
- * // => true
2133
- *
2134
- * _.isArrayLike(_.noop);
2135
- * // => false
2136
- */
2137
- function isArrayLike(value) {
2138
- return value != null && isLength(value.length) && !isFunction(value);
2139
- }
2140
-
2141
- /**
2142
- * This method is like `_.isArrayLike` except that it also checks if `value`
2143
- * is an object.
2144
- *
2145
- * @static
2146
- * @memberOf _
2147
- * @since 4.0.0
2148
- * @category Lang
2149
- * @param {*} value The value to check.
2150
- * @returns {boolean} Returns `true` if `value` is an array-like object,
2151
- * else `false`.
2152
- * @example
2153
- *
2154
- * _.isArrayLikeObject([1, 2, 3]);
2155
- * // => true
2156
- *
2157
- * _.isArrayLikeObject(document.body.children);
2158
- * // => true
2159
- *
2160
- * _.isArrayLikeObject('abc');
2161
- * // => false
2162
- *
2163
- * _.isArrayLikeObject(_.noop);
2164
- * // => false
2165
- */
2166
- function isArrayLikeObject(value) {
2167
- return isObjectLike(value) && isArrayLike(value);
2168
- }
2169
-
2170
- /**
2171
- * Checks if `value` is a buffer.
2172
- *
2173
- * @static
2174
- * @memberOf _
2175
- * @since 4.3.0
2176
- * @category Lang
2177
- * @param {*} value The value to check.
2178
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
2179
- * @example
2180
- *
2181
- * _.isBuffer(new Buffer(2));
2182
- * // => true
2183
- *
2184
- * _.isBuffer(new Uint8Array(2));
2185
- * // => false
2186
- */
2187
- var isBuffer = nativeIsBuffer || stubFalse;
2188
-
2189
- /**
2190
- * Checks if `value` is classified as a `Function` object.
2191
- *
2192
- * @static
2193
- * @memberOf _
2194
- * @since 0.1.0
2195
- * @category Lang
2196
- * @param {*} value The value to check.
2197
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2198
- * @example
2199
- *
2200
- * _.isFunction(_);
2201
- * // => true
2202
- *
2203
- * _.isFunction(/abc/);
2204
- * // => false
2205
- */
2206
- function isFunction(value) {
2207
- // The use of `Object#toString` avoids issues with the `typeof` operator
2208
- // in Safari 8-9 which returns 'object' for typed array and other constructors.
2209
- var tag = isObject(value) ? objectToString.call(value) : '';
2210
- return tag == funcTag || tag == genTag;
2211
- }
2212
-
2213
- /**
2214
- * Checks if `value` is a valid array-like length.
2215
- *
2216
- * **Note:** This method is loosely based on
2217
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2218
- *
2219
- * @static
2220
- * @memberOf _
2221
- * @since 4.0.0
2222
- * @category Lang
2223
- * @param {*} value The value to check.
2224
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2225
- * @example
2226
- *
2227
- * _.isLength(3);
2228
- * // => true
2229
- *
2230
- * _.isLength(Number.MIN_VALUE);
2231
- * // => false
2232
- *
2233
- * _.isLength(Infinity);
2234
- * // => false
2235
- *
2236
- * _.isLength('3');
2237
- * // => false
2238
- */
2239
- function isLength(value) {
2240
- return typeof value == 'number' &&
2241
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2242
- }
2243
-
2244
- /**
2245
- * Checks if `value` is the
2246
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2247
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2248
- *
2249
- * @static
2250
- * @memberOf _
2251
- * @since 0.1.0
2252
- * @category Lang
2253
- * @param {*} value The value to check.
2254
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2255
- * @example
2256
- *
2257
- * _.isObject({});
2258
- * // => true
2259
- *
2260
- * _.isObject([1, 2, 3]);
2261
- * // => true
2262
- *
2263
- * _.isObject(_.noop);
2264
- * // => true
2265
- *
2266
- * _.isObject(null);
2267
- * // => false
2268
- */
2269
- function isObject(value) {
2270
- var type = typeof value;
2271
- return !!value && (type == 'object' || type == 'function');
2272
- }
2273
-
2274
- /**
2275
- * Checks if `value` is object-like. A value is object-like if it's not `null`
2276
- * and has a `typeof` result of "object".
2277
- *
2278
- * @static
2279
- * @memberOf _
2280
- * @since 4.0.0
2281
- * @category Lang
2282
- * @param {*} value The value to check.
2283
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2284
- * @example
2285
- *
2286
- * _.isObjectLike({});
2287
- * // => true
2288
- *
2289
- * _.isObjectLike([1, 2, 3]);
2290
- * // => true
2291
- *
2292
- * _.isObjectLike(_.noop);
2293
- * // => false
2294
- *
2295
- * _.isObjectLike(null);
2296
- * // => false
2297
- */
2298
- function isObjectLike(value) {
2299
- return !!value && typeof value == 'object';
2300
- }
2301
-
2302
- /**
2303
- * Creates an array of the own enumerable property names of `object`.
2304
- *
2305
- * **Note:** Non-object values are coerced to objects. See the
2306
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2307
- * for more details.
2308
- *
2309
- * @static
2310
- * @since 0.1.0
2311
- * @memberOf _
2312
- * @category Object
2313
- * @param {Object} object The object to query.
2314
- * @returns {Array} Returns the array of property names.
2315
- * @example
2316
- *
2317
- * function Foo() {
2318
- * this.a = 1;
2319
- * this.b = 2;
2320
- * }
2321
- *
2322
- * Foo.prototype.c = 3;
2323
- *
2324
- * _.keys(new Foo);
2325
- * // => ['a', 'b'] (iteration order is not guaranteed)
2326
- *
2327
- * _.keys('hi');
2328
- * // => ['0', '1']
2329
- */
2330
- function keys(object) {
2331
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
2332
- }
2333
-
2334
- /**
2335
- * This method returns a new empty array.
2336
- *
2337
- * @static
2338
- * @memberOf _
2339
- * @since 4.13.0
2340
- * @category Util
2341
- * @returns {Array} Returns the new empty array.
2342
- * @example
2343
- *
2344
- * var arrays = _.times(2, _.stubArray);
2345
- *
2346
- * console.log(arrays);
2347
- * // => [[], []]
2348
- *
2349
- * console.log(arrays[0] === arrays[1]);
2350
- * // => false
2351
- */
2352
- function stubArray() {
2353
- return [];
2354
- }
2355
-
2356
- /**
2357
- * This method returns `false`.
2358
- *
2359
- * @static
2360
- * @memberOf _
2361
- * @since 4.13.0
2362
- * @category Util
2363
- * @returns {boolean} Returns `false`.
2364
- * @example
2365
- *
2366
- * _.times(2, _.stubFalse);
2367
- * // => [false, false]
2368
- */
2369
- function stubFalse() {
2370
- return false;
2371
- }
2372
-
2373
- module.exports = cloneDeep;
2374
- }(lodash_clonedeep, lodash_clonedeep.exports));
2375
-
2376
- var clone = lodash_clonedeep.exports;
2377
-
2378
- /**
2379
- * lodash (Custom Build) <https://lodash.com/>
2380
- * Build: `lodash modularize exports="npm" -o ./`
2381
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
2382
- * Released under MIT license <https://lodash.com/license>
2383
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
2384
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2385
- */
2386
-
2387
- /** `Object#toString` result references. */
2388
- var objectTag = '[object Object]';
2389
-
2390
- /**
2391
- * Checks if `value` is a host object in IE < 9.
2392
- *
2393
- * @private
2394
- * @param {*} value The value to check.
2395
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
2396
- */
2397
- function isHostObject$1(value) {
2398
- // Many host objects are `Object` objects that can coerce to strings
2399
- // despite having improperly defined `toString` methods.
2400
- var result = false;
2401
- if (value != null && typeof value.toString != 'function') {
2402
- try {
2403
- result = !!(value + '');
2404
- } catch (e) {}
2405
- }
2406
- return result;
2407
- }
2408
-
2409
- /**
2410
- * Creates a unary function that invokes `func` with its argument transformed.
2411
- *
2412
- * @private
2413
- * @param {Function} func The function to wrap.
2414
- * @param {Function} transform The argument transform.
2415
- * @returns {Function} Returns the new function.
2416
- */
2417
- function overArg(func, transform) {
2418
- return function(arg) {
2419
- return func(transform(arg));
2420
- };
2421
- }
2422
-
2423
- /** Used for built-in method references. */
2424
- var funcProto$1 = Function.prototype,
2425
- objectProto$1 = Object.prototype;
2426
-
2427
- /** Used to resolve the decompiled source of functions. */
2428
- var funcToString$1 = funcProto$1.toString;
2429
-
2430
- /** Used to check objects for own properties. */
2431
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
2432
-
2433
- /** Used to infer the `Object` constructor. */
2434
- var objectCtorString = funcToString$1.call(Object);
2435
-
2436
- /**
2437
- * Used to resolve the
2438
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2439
- * of values.
2440
- */
2441
- var objectToString$1 = objectProto$1.toString;
2442
-
2443
- /** Built-in value references. */
2444
- var getPrototype = overArg(Object.getPrototypeOf, Object);
2445
-
2446
- /**
2447
- * Checks if `value` is object-like. A value is object-like if it's not `null`
2448
- * and has a `typeof` result of "object".
2449
- *
2450
- * @static
2451
- * @memberOf _
2452
- * @since 4.0.0
2453
- * @category Lang
2454
- * @param {*} value The value to check.
2455
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2456
- * @example
2457
- *
2458
- * _.isObjectLike({});
2459
- * // => true
2460
- *
2461
- * _.isObjectLike([1, 2, 3]);
2462
- * // => true
2463
- *
2464
- * _.isObjectLike(_.noop);
2465
- * // => false
2466
- *
2467
- * _.isObjectLike(null);
2468
- * // => false
2469
- */
2470
- function isObjectLike$1(value) {
2471
- return !!value && typeof value == 'object';
2472
- }
2473
-
2474
- /**
2475
- * Checks if `value` is a plain object, that is, an object created by the
2476
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
2477
- *
2478
- * @static
2479
- * @memberOf _
2480
- * @since 0.8.0
2481
- * @category Lang
2482
- * @param {*} value The value to check.
2483
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
2484
- * @example
2485
- *
2486
- * function Foo() {
2487
- * this.a = 1;
2488
- * }
2489
- *
2490
- * _.isPlainObject(new Foo);
2491
- * // => false
2492
- *
2493
- * _.isPlainObject([1, 2, 3]);
2494
- * // => false
2495
- *
2496
- * _.isPlainObject({ 'x': 0, 'y': 0 });
2497
- * // => true
2498
- *
2499
- * _.isPlainObject(Object.create(null));
2500
- * // => true
2501
- */
2502
- function isPlainObject(value) {
2503
- if (!isObjectLike$1(value) ||
2504
- objectToString$1.call(value) != objectTag || isHostObject$1(value)) {
2505
- return false;
2506
- }
2507
- var proto = getPrototype(value);
2508
- if (proto === null) {
2509
- return true;
2510
- }
2511
- var Ctor = hasOwnProperty$1.call(proto, 'constructor') && proto.constructor;
2512
- return (typeof Ctor == 'function' &&
2513
- Ctor instanceof Ctor && funcToString$1.call(Ctor) == objectCtorString);
2514
- }
2515
-
2516
- var lodash_isplainobject = isPlainObject;
2517
-
2518
- /**
2519
- * @name ast-monkey-util
2520
- * @fileoverview Utility library of AST helper functions
2521
- * @version 1.4.0
2522
- * @author Roy Revelt, Codsen Ltd
2523
- * @license MIT
2524
- * {@link https://codsen.com/os/ast-monkey-util/}
2525
- */
2526
-
2527
- function parent(str) {
2528
- if (str.includes(".")) {
2529
- const lastDotAt = str.lastIndexOf(".");
2530
- if (!str.slice(0, lastDotAt).includes(".")) {
2531
- return str.slice(0, lastDotAt);
2532
- }
2533
- for (let i = lastDotAt - 1; i--;) {
2534
- if (str[i] === ".") {
2535
- return str.slice(i + 1, lastDotAt);
2536
- }
2537
- }
2538
- }
2539
- return null;
2540
- }
2541
-
2542
- /**
2543
- * @name ast-monkey-traverse
2544
- * @fileoverview Utility library to traverse AST
2545
- * @version 2.1.0
2546
- * @author Roy Revelt, Codsen Ltd
2547
- * @license MIT
2548
- * {@link https://codsen.com/os/ast-monkey-traverse/}
2549
- */
2550
- function traverse(tree1, cb1) {
2551
- const stop2 = {
2552
- now: false
2553
- };
2554
- function traverseInner(treeOriginal, callback, originalInnerObj, stop) {
2555
- const tree = clone(treeOriginal);
2556
- let res;
2557
- const innerObj = {
2558
- depth: -1,
2559
- path: "",
2560
- ...originalInnerObj
2561
- };
2562
- innerObj.depth += 1;
2563
- if (Array.isArray(tree)) {
2564
- for (let i = 0, len = tree.length; i < len; i++) {
2565
- if (stop.now) {
2566
- break;
2567
- }
2568
- const path = innerObj.path ? `${innerObj.path}.${i}` : `${i}`;
2569
- if (tree[i] !== undefined) {
2570
- innerObj.parent = clone(tree);
2571
- innerObj.parentType = "array";
2572
- innerObj.parentKey = parent(path);
2573
- res = traverseInner(callback(tree[i], undefined, { ...innerObj,
2574
- path
2575
- }, stop), callback, { ...innerObj,
2576
- path
2577
- }, stop);
2578
- if (Number.isNaN(res) && i < tree.length) {
2579
- tree.splice(i, 1);
2580
- i -= 1;
2581
- } else {
2582
- tree[i] = res;
2583
- }
2584
- } else {
2585
- tree.splice(i, 1);
2586
- }
2587
- }
2588
- } else if (lodash_isplainobject(tree)) {
2589
- for (const key in tree) {
2590
- if (stop.now && key != null) {
2591
- break;
2592
- }
2593
- const path = innerObj.path ? `${innerObj.path}.${key}` : key;
2594
- if (innerObj.depth === 0 && key != null) {
2595
- innerObj.topmostKey = key;
2596
- }
2597
- innerObj.parent = clone(tree);
2598
- innerObj.parentType = "object";
2599
- innerObj.parentKey = parent(path);
2600
- res = traverseInner(callback(key, tree[key], { ...innerObj,
2601
- path
2602
- }, stop), callback, { ...innerObj,
2603
- path
2604
- }, stop);
2605
- if (Number.isNaN(res)) {
2606
- delete tree[key];
2607
- } else {
2608
- tree[key] = res;
2609
- }
2610
- }
2611
- }
2612
- return tree;
2613
- }
2614
- return traverseInner(tree1, cb1, {}, stop2);
2615
- }
2616
-
2617
- /**
2618
- * lodash (Custom Build) <https://lodash.com/>
2619
- * Build: `lodash modularize exports="npm" -o ./`
2620
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
2621
- * Released under MIT license <https://lodash.com/license>
2622
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
2623
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2624
- */
2625
-
2626
- /** Used to stand-in for `undefined` hash values. */
2627
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
2628
-
2629
- /** Used as references for various `Number` constants. */
2630
- var MAX_SAFE_INTEGER = 9007199254740991;
2631
-
2632
- /** `Object#toString` result references. */
2633
- var funcTag = '[object Function]',
2634
- genTag = '[object GeneratorFunction]';
2635
-
2636
- /**
2637
- * Used to match `RegExp`
2638
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
2639
- */
2640
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
2641
-
2642
- /** Used to detect host constructors (Safari). */
2643
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
2644
-
2645
- /** Detect free variable `global` from Node.js. */
2646
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2647
-
2648
- /** Detect free variable `self`. */
2649
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
2650
-
2651
- /** Used as a reference to the global object. */
2652
- var root = freeGlobal || freeSelf || Function('return this')();
2653
-
2654
- /**
2655
- * A faster alternative to `Function#apply`, this function invokes `func`
2656
- * with the `this` binding of `thisArg` and the arguments of `args`.
2657
- *
2658
- * @private
2659
- * @param {Function} func The function to invoke.
2660
- * @param {*} thisArg The `this` binding of `func`.
2661
- * @param {Array} args The arguments to invoke `func` with.
2662
- * @returns {*} Returns the result of `func`.
2663
- */
2664
- function apply(func, thisArg, args) {
2665
- switch (args.length) {
2666
- case 0: return func.call(thisArg);
2667
- case 1: return func.call(thisArg, args[0]);
2668
- case 2: return func.call(thisArg, args[0], args[1]);
2669
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
2670
- }
2671
- return func.apply(thisArg, args);
2672
- }
2673
-
2674
- /**
2675
- * A specialized version of `_.includes` for arrays without support for
2676
- * specifying an index to search from.
2677
- *
2678
- * @private
2679
- * @param {Array} [array] The array to inspect.
2680
- * @param {*} target The value to search for.
2681
- * @returns {boolean} Returns `true` if `target` is found, else `false`.
2682
- */
2683
- function arrayIncludes(array, value) {
2684
- var length = array ? array.length : 0;
2685
- return !!length && baseIndexOf(array, value, 0) > -1;
2686
- }
2687
-
2688
- /**
2689
- * This function is like `arrayIncludes` except that it accepts a comparator.
2690
- *
2691
- * @private
2692
- * @param {Array} [array] The array to inspect.
2693
- * @param {*} target The value to search for.
2694
- * @param {Function} comparator The comparator invoked per element.
2695
- * @returns {boolean} Returns `true` if `target` is found, else `false`.
2696
- */
2697
- function arrayIncludesWith(array, value, comparator) {
2698
- var index = -1,
2699
- length = array ? array.length : 0;
2700
-
2701
- while (++index < length) {
2702
- if (comparator(value, array[index])) {
2703
- return true;
2704
- }
2705
- }
2706
- return false;
2707
- }
2708
-
2709
- /**
2710
- * A specialized version of `_.map` for arrays without support for iteratee
2711
- * shorthands.
2712
- *
2713
- * @private
2714
- * @param {Array} [array] The array to iterate over.
2715
- * @param {Function} iteratee The function invoked per iteration.
2716
- * @returns {Array} Returns the new mapped array.
2717
- */
2718
- function arrayMap(array, iteratee) {
2719
- var index = -1,
2720
- length = array ? array.length : 0,
2721
- result = Array(length);
2722
-
2723
- while (++index < length) {
2724
- result[index] = iteratee(array[index], index, array);
2725
- }
2726
- return result;
2727
- }
2728
-
2729
- /**
2730
- * The base implementation of `_.findIndex` and `_.findLastIndex` without
2731
- * support for iteratee shorthands.
2732
- *
2733
- * @private
2734
- * @param {Array} array The array to inspect.
2735
- * @param {Function} predicate The function invoked per iteration.
2736
- * @param {number} fromIndex The index to search from.
2737
- * @param {boolean} [fromRight] Specify iterating from right to left.
2738
- * @returns {number} Returns the index of the matched value, else `-1`.
2739
- */
2740
- function baseFindIndex(array, predicate, fromIndex, fromRight) {
2741
- var length = array.length,
2742
- index = fromIndex + (fromRight ? 1 : -1);
2743
-
2744
- while ((fromRight ? index-- : ++index < length)) {
2745
- if (predicate(array[index], index, array)) {
2746
- return index;
2747
- }
2748
- }
2749
- return -1;
2750
- }
2751
-
2752
- /**
2753
- * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
2754
- *
2755
- * @private
2756
- * @param {Array} array The array to inspect.
2757
- * @param {*} value The value to search for.
2758
- * @param {number} fromIndex The index to search from.
2759
- * @returns {number} Returns the index of the matched value, else `-1`.
2760
- */
2761
- function baseIndexOf(array, value, fromIndex) {
2762
- if (value !== value) {
2763
- return baseFindIndex(array, baseIsNaN, fromIndex);
2764
- }
2765
- var index = fromIndex - 1,
2766
- length = array.length;
2767
-
2768
- while (++index < length) {
2769
- if (array[index] === value) {
2770
- return index;
2771
- }
2772
- }
2773
- return -1;
2774
- }
2775
-
2776
- /**
2777
- * The base implementation of `_.isNaN` without support for number objects.
2778
- *
2779
- * @private
2780
- * @param {*} value The value to check.
2781
- * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
2782
- */
2783
- function baseIsNaN(value) {
2784
- return value !== value;
2785
- }
2786
-
2787
- /**
2788
- * The base implementation of `_.unary` without support for storing metadata.
2789
- *
2790
- * @private
2791
- * @param {Function} func The function to cap arguments for.
2792
- * @returns {Function} Returns the new capped function.
2793
- */
2794
- function baseUnary(func) {
2795
- return function(value) {
2796
- return func(value);
2797
- };
2798
- }
2799
-
2800
- /**
2801
- * Checks if a cache value for `key` exists.
2802
- *
2803
- * @private
2804
- * @param {Object} cache The cache to query.
2805
- * @param {string} key The key of the entry to check.
2806
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2807
- */
2808
- function cacheHas(cache, key) {
2809
- return cache.has(key);
2810
- }
2811
-
2812
- /**
2813
- * Gets the value at `key` of `object`.
2814
- *
2815
- * @private
2816
- * @param {Object} [object] The object to query.
2817
- * @param {string} key The key of the property to get.
2818
- * @returns {*} Returns the property value.
2819
- */
2820
- function getValue(object, key) {
2821
- return object == null ? undefined : object[key];
2822
- }
2823
-
2824
- /**
2825
- * Checks if `value` is a host object in IE < 9.
2826
- *
2827
- * @private
2828
- * @param {*} value The value to check.
2829
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
2830
- */
2831
- function isHostObject(value) {
2832
- // Many host objects are `Object` objects that can coerce to strings
2833
- // despite having improperly defined `toString` methods.
2834
- var result = false;
2835
- if (value != null && typeof value.toString != 'function') {
2836
- try {
2837
- result = !!(value + '');
2838
- } catch (e) {}
2839
- }
2840
- return result;
2841
- }
2842
-
2843
- /** Used for built-in method references. */
2844
- var arrayProto = Array.prototype,
2845
- funcProto = Function.prototype,
2846
- objectProto = Object.prototype;
2847
-
2848
- /** Used to detect overreaching core-js shims. */
2849
- var coreJsData = root['__core-js_shared__'];
2850
-
2851
- /** Used to detect methods masquerading as native. */
2852
- var maskSrcKey = (function() {
2853
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
2854
- return uid ? ('Symbol(src)_1.' + uid) : '';
2855
- }());
2856
-
2857
- /** Used to resolve the decompiled source of functions. */
2858
- var funcToString = funcProto.toString;
2859
-
2860
- /** Used to check objects for own properties. */
2861
- var hasOwnProperty = objectProto.hasOwnProperty;
2862
-
2863
- /**
2864
- * Used to resolve the
2865
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2866
- * of values.
2867
- */
2868
- var objectToString = objectProto.toString;
2869
-
2870
- /** Used to detect if a method is native. */
2871
- var reIsNative = RegExp('^' +
2872
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
2873
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
2874
- );
2875
-
2876
- /** Built-in value references. */
2877
- var splice = arrayProto.splice;
2878
-
2879
- /* Built-in method references for those with the same name as other `lodash` methods. */
2880
- var nativeMax = Math.max,
2881
- nativeMin = Math.min;
2882
-
2883
- /* Built-in method references that are verified to be native. */
2884
- var Map$1 = getNative(root, 'Map'),
2885
- nativeCreate = getNative(Object, 'create');
2886
-
2887
- /**
2888
- * Creates a hash object.
2889
- *
2890
- * @private
2891
- * @constructor
2892
- * @param {Array} [entries] The key-value pairs to cache.
2893
- */
2894
- function Hash(entries) {
2895
- var index = -1,
2896
- length = entries ? entries.length : 0;
2897
-
2898
- this.clear();
2899
- while (++index < length) {
2900
- var entry = entries[index];
2901
- this.set(entry[0], entry[1]);
2902
- }
2903
- }
2904
-
2905
- /**
2906
- * Removes all key-value entries from the hash.
2907
- *
2908
- * @private
2909
- * @name clear
2910
- * @memberOf Hash
2911
- */
2912
- function hashClear() {
2913
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
2914
- }
2915
-
2916
- /**
2917
- * Removes `key` and its value from the hash.
2918
- *
2919
- * @private
2920
- * @name delete
2921
- * @memberOf Hash
2922
- * @param {Object} hash The hash to modify.
2923
- * @param {string} key The key of the value to remove.
2924
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2925
- */
2926
- function hashDelete(key) {
2927
- return this.has(key) && delete this.__data__[key];
2928
- }
2929
-
2930
- /**
2931
- * Gets the hash value for `key`.
2932
- *
2933
- * @private
2934
- * @name get
2935
- * @memberOf Hash
2936
- * @param {string} key The key of the value to get.
2937
- * @returns {*} Returns the entry value.
2938
- */
2939
- function hashGet(key) {
2940
- var data = this.__data__;
2941
- if (nativeCreate) {
2942
- var result = data[key];
2943
- return result === HASH_UNDEFINED ? undefined : result;
2944
- }
2945
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
2946
- }
2947
-
2948
- /**
2949
- * Checks if a hash value for `key` exists.
2950
- *
2951
- * @private
2952
- * @name has
2953
- * @memberOf Hash
2954
- * @param {string} key The key of the entry to check.
2955
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2956
- */
2957
- function hashHas(key) {
2958
- var data = this.__data__;
2959
- return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
2960
- }
2961
-
2962
- /**
2963
- * Sets the hash `key` to `value`.
2964
- *
2965
- * @private
2966
- * @name set
2967
- * @memberOf Hash
2968
- * @param {string} key The key of the value to set.
2969
- * @param {*} value The value to set.
2970
- * @returns {Object} Returns the hash instance.
2971
- */
2972
- function hashSet(key, value) {
2973
- var data = this.__data__;
2974
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
2975
- return this;
2976
- }
2977
-
2978
- // Add methods to `Hash`.
2979
- Hash.prototype.clear = hashClear;
2980
- Hash.prototype['delete'] = hashDelete;
2981
- Hash.prototype.get = hashGet;
2982
- Hash.prototype.has = hashHas;
2983
- Hash.prototype.set = hashSet;
2984
-
2985
- /**
2986
- * Creates an list cache object.
2987
- *
2988
- * @private
2989
- * @constructor
2990
- * @param {Array} [entries] The key-value pairs to cache.
2991
- */
2992
- function ListCache(entries) {
2993
- var index = -1,
2994
- length = entries ? entries.length : 0;
2995
-
2996
- this.clear();
2997
- while (++index < length) {
2998
- var entry = entries[index];
2999
- this.set(entry[0], entry[1]);
3000
- }
3001
- }
3002
-
3003
- /**
3004
- * Removes all key-value entries from the list cache.
3005
- *
3006
- * @private
3007
- * @name clear
3008
- * @memberOf ListCache
3009
- */
3010
- function listCacheClear() {
3011
- this.__data__ = [];
3012
- }
3013
-
3014
- /**
3015
- * Removes `key` and its value from the list cache.
3016
- *
3017
- * @private
3018
- * @name delete
3019
- * @memberOf ListCache
3020
- * @param {string} key The key of the value to remove.
3021
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
3022
- */
3023
- function listCacheDelete(key) {
3024
- var data = this.__data__,
3025
- index = assocIndexOf(data, key);
3026
-
3027
- if (index < 0) {
3028
- return false;
3029
- }
3030
- var lastIndex = data.length - 1;
3031
- if (index == lastIndex) {
3032
- data.pop();
3033
- } else {
3034
- splice.call(data, index, 1);
3035
- }
3036
- return true;
3037
- }
3038
-
3039
- /**
3040
- * Gets the list cache value for `key`.
3041
- *
3042
- * @private
3043
- * @name get
3044
- * @memberOf ListCache
3045
- * @param {string} key The key of the value to get.
3046
- * @returns {*} Returns the entry value.
3047
- */
3048
- function listCacheGet(key) {
3049
- var data = this.__data__,
3050
- index = assocIndexOf(data, key);
3051
-
3052
- return index < 0 ? undefined : data[index][1];
3053
- }
3054
-
3055
- /**
3056
- * Checks if a list cache value for `key` exists.
3057
- *
3058
- * @private
3059
- * @name has
3060
- * @memberOf ListCache
3061
- * @param {string} key The key of the entry to check.
3062
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
3063
- */
3064
- function listCacheHas(key) {
3065
- return assocIndexOf(this.__data__, key) > -1;
3066
- }
3067
-
3068
- /**
3069
- * Sets the list cache `key` to `value`.
3070
- *
3071
- * @private
3072
- * @name set
3073
- * @memberOf ListCache
3074
- * @param {string} key The key of the value to set.
3075
- * @param {*} value The value to set.
3076
- * @returns {Object} Returns the list cache instance.
3077
- */
3078
- function listCacheSet(key, value) {
3079
- var data = this.__data__,
3080
- index = assocIndexOf(data, key);
3081
-
3082
- if (index < 0) {
3083
- data.push([key, value]);
3084
- } else {
3085
- data[index][1] = value;
3086
- }
3087
- return this;
3088
- }
3089
-
3090
- // Add methods to `ListCache`.
3091
- ListCache.prototype.clear = listCacheClear;
3092
- ListCache.prototype['delete'] = listCacheDelete;
3093
- ListCache.prototype.get = listCacheGet;
3094
- ListCache.prototype.has = listCacheHas;
3095
- ListCache.prototype.set = listCacheSet;
3096
-
3097
- /**
3098
- * Creates a map cache object to store key-value pairs.
3099
- *
3100
- * @private
3101
- * @constructor
3102
- * @param {Array} [entries] The key-value pairs to cache.
3103
- */
3104
- function MapCache(entries) {
3105
- var index = -1,
3106
- length = entries ? entries.length : 0;
3107
-
3108
- this.clear();
3109
- while (++index < length) {
3110
- var entry = entries[index];
3111
- this.set(entry[0], entry[1]);
3112
- }
3113
- }
3114
-
3115
- /**
3116
- * Removes all key-value entries from the map.
3117
- *
3118
- * @private
3119
- * @name clear
3120
- * @memberOf MapCache
3121
- */
3122
- function mapCacheClear() {
3123
- this.__data__ = {
3124
- 'hash': new Hash,
3125
- 'map': new (Map$1 || ListCache),
3126
- 'string': new Hash
3127
- };
3128
- }
3129
-
3130
- /**
3131
- * Removes `key` and its value from the map.
3132
- *
3133
- * @private
3134
- * @name delete
3135
- * @memberOf MapCache
3136
- * @param {string} key The key of the value to remove.
3137
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
3138
- */
3139
- function mapCacheDelete(key) {
3140
- return getMapData(this, key)['delete'](key);
3141
- }
3142
-
3143
- /**
3144
- * Gets the map value for `key`.
3145
- *
3146
- * @private
3147
- * @name get
3148
- * @memberOf MapCache
3149
- * @param {string} key The key of the value to get.
3150
- * @returns {*} Returns the entry value.
3151
- */
3152
- function mapCacheGet(key) {
3153
- return getMapData(this, key).get(key);
3154
- }
3155
-
3156
- /**
3157
- * Checks if a map value for `key` exists.
3158
- *
3159
- * @private
3160
- * @name has
3161
- * @memberOf MapCache
3162
- * @param {string} key The key of the entry to check.
3163
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
3164
- */
3165
- function mapCacheHas(key) {
3166
- return getMapData(this, key).has(key);
3167
- }
3168
-
3169
- /**
3170
- * Sets the map `key` to `value`.
3171
- *
3172
- * @private
3173
- * @name set
3174
- * @memberOf MapCache
3175
- * @param {string} key The key of the value to set.
3176
- * @param {*} value The value to set.
3177
- * @returns {Object} Returns the map cache instance.
3178
- */
3179
- function mapCacheSet(key, value) {
3180
- getMapData(this, key).set(key, value);
3181
- return this;
3182
- }
3183
-
3184
- // Add methods to `MapCache`.
3185
- MapCache.prototype.clear = mapCacheClear;
3186
- MapCache.prototype['delete'] = mapCacheDelete;
3187
- MapCache.prototype.get = mapCacheGet;
3188
- MapCache.prototype.has = mapCacheHas;
3189
- MapCache.prototype.set = mapCacheSet;
3190
-
3191
- /**
3192
- *
3193
- * Creates an array cache object to store unique values.
3194
- *
3195
- * @private
3196
- * @constructor
3197
- * @param {Array} [values] The values to cache.
3198
- */
3199
- function SetCache(values) {
3200
- var index = -1,
3201
- length = values ? values.length : 0;
3202
-
3203
- this.__data__ = new MapCache;
3204
- while (++index < length) {
3205
- this.add(values[index]);
3206
- }
3207
- }
3208
-
3209
- /**
3210
- * Adds `value` to the array cache.
3211
- *
3212
- * @private
3213
- * @name add
3214
- * @memberOf SetCache
3215
- * @alias push
3216
- * @param {*} value The value to cache.
3217
- * @returns {Object} Returns the cache instance.
3218
- */
3219
- function setCacheAdd(value) {
3220
- this.__data__.set(value, HASH_UNDEFINED);
3221
- return this;
3222
- }
3223
-
3224
- /**
3225
- * Checks if `value` is in the array cache.
3226
- *
3227
- * @private
3228
- * @name has
3229
- * @memberOf SetCache
3230
- * @param {*} value The value to search for.
3231
- * @returns {number} Returns `true` if `value` is found, else `false`.
3232
- */
3233
- function setCacheHas(value) {
3234
- return this.__data__.has(value);
3235
- }
3236
-
3237
- // Add methods to `SetCache`.
3238
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
3239
- SetCache.prototype.has = setCacheHas;
3240
-
3241
- /**
3242
- * Gets the index at which the `key` is found in `array` of key-value pairs.
3243
- *
3244
- * @private
3245
- * @param {Array} array The array to inspect.
3246
- * @param {*} key The key to search for.
3247
- * @returns {number} Returns the index of the matched value, else `-1`.
3248
- */
3249
- function assocIndexOf(array, key) {
3250
- var length = array.length;
3251
- while (length--) {
3252
- if (eq(array[length][0], key)) {
3253
- return length;
3254
- }
3255
- }
3256
- return -1;
3257
- }
3258
-
3259
- /**
3260
- * The base implementation of methods like `_.intersection`, without support
3261
- * for iteratee shorthands, that accepts an array of arrays to inspect.
3262
- *
3263
- * @private
3264
- * @param {Array} arrays The arrays to inspect.
3265
- * @param {Function} [iteratee] The iteratee invoked per element.
3266
- * @param {Function} [comparator] The comparator invoked per element.
3267
- * @returns {Array} Returns the new array of shared values.
3268
- */
3269
- function baseIntersection(arrays, iteratee, comparator) {
3270
- var includes = comparator ? arrayIncludesWith : arrayIncludes,
3271
- length = arrays[0].length,
3272
- othLength = arrays.length,
3273
- othIndex = othLength,
3274
- caches = Array(othLength),
3275
- maxLength = Infinity,
3276
- result = [];
3277
-
3278
- while (othIndex--) {
3279
- var array = arrays[othIndex];
3280
- if (othIndex && iteratee) {
3281
- array = arrayMap(array, baseUnary(iteratee));
3282
- }
3283
- maxLength = nativeMin(array.length, maxLength);
3284
- caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
3285
- ? new SetCache(othIndex && array)
3286
- : undefined;
3287
- }
3288
- array = arrays[0];
3289
-
3290
- var index = -1,
3291
- seen = caches[0];
3292
-
3293
- outer:
3294
- while (++index < length && result.length < maxLength) {
3295
- var value = array[index],
3296
- computed = iteratee ? iteratee(value) : value;
3297
-
3298
- value = (comparator || value !== 0) ? value : 0;
3299
- if (!(seen
3300
- ? cacheHas(seen, computed)
3301
- : includes(result, computed, comparator)
3302
- )) {
3303
- othIndex = othLength;
3304
- while (--othIndex) {
3305
- var cache = caches[othIndex];
3306
- if (!(cache
3307
- ? cacheHas(cache, computed)
3308
- : includes(arrays[othIndex], computed, comparator))
3309
- ) {
3310
- continue outer;
3311
- }
3312
- }
3313
- if (seen) {
3314
- seen.push(computed);
3315
- }
3316
- result.push(value);
3317
- }
3318
- }
3319
- return result;
3320
- }
3321
-
3322
- /**
3323
- * The base implementation of `_.isNative` without bad shim checks.
3324
- *
3325
- * @private
3326
- * @param {*} value The value to check.
3327
- * @returns {boolean} Returns `true` if `value` is a native function,
3328
- * else `false`.
3329
- */
3330
- function baseIsNative(value) {
3331
- if (!isObject(value) || isMasked(value)) {
3332
- return false;
3333
- }
3334
- var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
3335
- return pattern.test(toSource(value));
3336
- }
3337
-
3338
- /**
3339
- * The base implementation of `_.rest` which doesn't validate or coerce arguments.
3340
- *
3341
- * @private
3342
- * @param {Function} func The function to apply a rest parameter to.
3343
- * @param {number} [start=func.length-1] The start position of the rest parameter.
3344
- * @returns {Function} Returns the new function.
3345
- */
3346
- function baseRest(func, start) {
3347
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
3348
- return function() {
3349
- var args = arguments,
3350
- index = -1,
3351
- length = nativeMax(args.length - start, 0),
3352
- array = Array(length);
3353
-
3354
- while (++index < length) {
3355
- array[index] = args[start + index];
3356
- }
3357
- index = -1;
3358
- var otherArgs = Array(start + 1);
3359
- while (++index < start) {
3360
- otherArgs[index] = args[index];
3361
- }
3362
- otherArgs[start] = array;
3363
- return apply(func, this, otherArgs);
3364
- };
3365
- }
3366
-
3367
- /**
3368
- * Casts `value` to an empty array if it's not an array like object.
3369
- *
3370
- * @private
3371
- * @param {*} value The value to inspect.
3372
- * @returns {Array|Object} Returns the cast array-like object.
3373
- */
3374
- function castArrayLikeObject(value) {
3375
- return isArrayLikeObject(value) ? value : [];
3376
- }
3377
-
3378
- /**
3379
- * Gets the data for `map`.
3380
- *
3381
- * @private
3382
- * @param {Object} map The map to query.
3383
- * @param {string} key The reference key.
3384
- * @returns {*} Returns the map data.
3385
- */
3386
- function getMapData(map, key) {
3387
- var data = map.__data__;
3388
- return isKeyable(key)
3389
- ? data[typeof key == 'string' ? 'string' : 'hash']
3390
- : data.map;
3391
- }
3392
-
3393
- /**
3394
- * Gets the native function at `key` of `object`.
3395
- *
3396
- * @private
3397
- * @param {Object} object The object to query.
3398
- * @param {string} key The key of the method to get.
3399
- * @returns {*} Returns the function if it's native, else `undefined`.
3400
- */
3401
- function getNative(object, key) {
3402
- var value = getValue(object, key);
3403
- return baseIsNative(value) ? value : undefined;
3404
- }
3405
-
3406
- /**
3407
- * Checks if `value` is suitable for use as unique object key.
3408
- *
3409
- * @private
3410
- * @param {*} value The value to check.
3411
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
3412
- */
3413
- function isKeyable(value) {
3414
- var type = typeof value;
3415
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
3416
- ? (value !== '__proto__')
3417
- : (value === null);
3418
- }
3419
-
3420
- /**
3421
- * Checks if `func` has its source masked.
3422
- *
3423
- * @private
3424
- * @param {Function} func The function to check.
3425
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
3426
- */
3427
- function isMasked(func) {
3428
- return !!maskSrcKey && (maskSrcKey in func);
3429
- }
3430
-
3431
- /**
3432
- * Converts `func` to its source code.
3433
- *
3434
- * @private
3435
- * @param {Function} func The function to process.
3436
- * @returns {string} Returns the source code.
3437
- */
3438
- function toSource(func) {
3439
- if (func != null) {
3440
- try {
3441
- return funcToString.call(func);
3442
- } catch (e) {}
3443
- try {
3444
- return (func + '');
3445
- } catch (e) {}
3446
- }
3447
- return '';
3448
- }
3449
-
3450
- /**
3451
- * Creates an array of unique values that are included in all given arrays
3452
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
3453
- * for equality comparisons. The order of result values is determined by the
3454
- * order they occur in the first array.
3455
- *
3456
- * @static
3457
- * @memberOf _
3458
- * @since 0.1.0
3459
- * @category Array
3460
- * @param {...Array} [arrays] The arrays to inspect.
3461
- * @returns {Array} Returns the new array of intersecting values.
3462
- * @example
3463
- *
3464
- * _.intersection([2, 1], [2, 3]);
3465
- * // => [2]
3466
- */
3467
- var intersection = baseRest(function(arrays) {
3468
- var mapped = arrayMap(arrays, castArrayLikeObject);
3469
- return (mapped.length && mapped[0] === arrays[0])
3470
- ? baseIntersection(mapped)
3471
- : [];
3472
- });
3473
-
3474
- /**
3475
- * Performs a
3476
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
3477
- * comparison between two values to determine if they are equivalent.
3478
- *
3479
- * @static
3480
- * @memberOf _
3481
- * @since 4.0.0
3482
- * @category Lang
3483
- * @param {*} value The value to compare.
3484
- * @param {*} other The other value to compare.
3485
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3486
- * @example
3487
- *
3488
- * var object = { 'a': 1 };
3489
- * var other = { 'a': 1 };
3490
- *
3491
- * _.eq(object, object);
3492
- * // => true
3493
- *
3494
- * _.eq(object, other);
3495
- * // => false
3496
- *
3497
- * _.eq('a', 'a');
3498
- * // => true
3499
- *
3500
- * _.eq('a', Object('a'));
3501
- * // => false
3502
- *
3503
- * _.eq(NaN, NaN);
3504
- * // => true
3505
- */
3506
- function eq(value, other) {
3507
- return value === other || (value !== value && other !== other);
3508
- }
3509
-
3510
- /**
3511
- * Checks if `value` is array-like. A value is considered array-like if it's
3512
- * not a function and has a `value.length` that's an integer greater than or
3513
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
3514
- *
3515
- * @static
3516
- * @memberOf _
3517
- * @since 4.0.0
3518
- * @category Lang
3519
- * @param {*} value The value to check.
3520
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
3521
- * @example
3522
- *
3523
- * _.isArrayLike([1, 2, 3]);
3524
- * // => true
3525
- *
3526
- * _.isArrayLike(document.body.children);
3527
- * // => true
3528
- *
3529
- * _.isArrayLike('abc');
3530
- * // => true
3531
- *
3532
- * _.isArrayLike(_.noop);
3533
- * // => false
3534
- */
3535
- function isArrayLike(value) {
3536
- return value != null && isLength(value.length) && !isFunction(value);
3537
- }
3538
-
3539
- /**
3540
- * This method is like `_.isArrayLike` except that it also checks if `value`
3541
- * is an object.
3542
- *
3543
- * @static
3544
- * @memberOf _
3545
- * @since 4.0.0
3546
- * @category Lang
3547
- * @param {*} value The value to check.
3548
- * @returns {boolean} Returns `true` if `value` is an array-like object,
3549
- * else `false`.
3550
- * @example
3551
- *
3552
- * _.isArrayLikeObject([1, 2, 3]);
3553
- * // => true
3554
- *
3555
- * _.isArrayLikeObject(document.body.children);
3556
- * // => true
3557
- *
3558
- * _.isArrayLikeObject('abc');
3559
- * // => false
3560
- *
3561
- * _.isArrayLikeObject(_.noop);
3562
- * // => false
3563
- */
3564
- function isArrayLikeObject(value) {
3565
- return isObjectLike(value) && isArrayLike(value);
3566
- }
3567
-
3568
- /**
3569
- * Checks if `value` is classified as a `Function` object.
3570
- *
3571
- * @static
3572
- * @memberOf _
3573
- * @since 0.1.0
3574
- * @category Lang
3575
- * @param {*} value The value to check.
3576
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
3577
- * @example
3578
- *
3579
- * _.isFunction(_);
3580
- * // => true
3581
- *
3582
- * _.isFunction(/abc/);
3583
- * // => false
3584
- */
3585
- function isFunction(value) {
3586
- // The use of `Object#toString` avoids issues with the `typeof` operator
3587
- // in Safari 8-9 which returns 'object' for typed array and other constructors.
3588
- var tag = isObject(value) ? objectToString.call(value) : '';
3589
- return tag == funcTag || tag == genTag;
3590
- }
3591
-
3592
- /**
3593
- * Checks if `value` is a valid array-like length.
3594
- *
3595
- * **Note:** This method is loosely based on
3596
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
3597
- *
3598
- * @static
3599
- * @memberOf _
3600
- * @since 4.0.0
3601
- * @category Lang
3602
- * @param {*} value The value to check.
3603
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3604
- * @example
3605
- *
3606
- * _.isLength(3);
3607
- * // => true
3608
- *
3609
- * _.isLength(Number.MIN_VALUE);
3610
- * // => false
3611
- *
3612
- * _.isLength(Infinity);
3613
- * // => false
3614
- *
3615
- * _.isLength('3');
3616
- * // => false
3617
- */
3618
- function isLength(value) {
3619
- return typeof value == 'number' &&
3620
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
3621
- }
3622
-
3623
- /**
3624
- * Checks if `value` is the
3625
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3626
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3627
- *
3628
- * @static
3629
- * @memberOf _
3630
- * @since 0.1.0
3631
- * @category Lang
3632
- * @param {*} value The value to check.
3633
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3634
- * @example
3635
- *
3636
- * _.isObject({});
3637
- * // => true
3638
- *
3639
- * _.isObject([1, 2, 3]);
3640
- * // => true
3641
- *
3642
- * _.isObject(_.noop);
3643
- * // => true
3644
- *
3645
- * _.isObject(null);
3646
- * // => false
3647
- */
3648
- function isObject(value) {
3649
- var type = typeof value;
3650
- return !!value && (type == 'object' || type == 'function');
3651
- }
3652
-
3653
- /**
3654
- * Checks if `value` is object-like. A value is object-like if it's not `null`
3655
- * and has a `typeof` result of "object".
3656
- *
3657
- * @static
3658
- * @memberOf _
3659
- * @since 4.0.0
3660
- * @category Lang
3661
- * @param {*} value The value to check.
3662
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3663
- * @example
3664
- *
3665
- * _.isObjectLike({});
3666
- * // => true
3667
- *
3668
- * _.isObjectLike([1, 2, 3]);
3669
- * // => true
3670
- *
3671
- * _.isObjectLike(_.noop);
3672
- * // => false
3673
- *
3674
- * _.isObjectLike(null);
3675
- * // => false
3676
- */
3677
- function isObjectLike(value) {
3678
- return !!value && typeof value == 'object';
3679
- }
3680
-
3681
- var lodash_intersection = intersection;
3682
-
3683
- /**
3684
- * @name arrayiffy-if-string
3685
- * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
3686
- * @version 3.14.0
3687
- * @author Roy Revelt, Codsen Ltd
3688
- * @license MIT
3689
- * {@link https://codsen.com/os/arrayiffy-if-string/}
3690
- */
3691
-
3692
- function arrayiffy(something) {
3693
- if (typeof something === "string") {
3694
- if (something.length) {
3695
- return [something];
3696
- }
3697
- return [];
3698
- }
3699
- return something;
3700
- }
3701
-
3702
- var objectPath$1 = {exports: {}};
3703
-
3704
- (function (module) {
3705
- (function (root, factory){
3706
-
3707
- /*istanbul ignore next:cant test*/
3708
- {
3709
- module.exports = factory();
3710
- }
3711
- })(commonjsGlobal, function(){
3712
-
3713
- var toStr = Object.prototype.toString;
3714
- function hasOwnProperty(obj, prop) {
3715
- if(obj == null) {
3716
- return false
3717
- }
3718
- //to handle objects with null prototypes (too edge case?)
3719
- return Object.prototype.hasOwnProperty.call(obj, prop)
3720
- }
3721
-
3722
- function isEmpty(value){
3723
- if (!value) {
3724
- return true;
3725
- }
3726
- if (isArray(value) && value.length === 0) {
3727
- return true;
3728
- } else if (typeof value !== 'string') {
3729
- for (var i in value) {
3730
- if (hasOwnProperty(value, i)) {
3731
- return false;
3732
- }
3733
- }
3734
- return true;
3735
- }
3736
- return false;
3737
- }
3738
-
3739
- function toString(type){
3740
- return toStr.call(type);
3741
- }
3742
-
3743
- function isObject(obj){
3744
- return typeof obj === 'object' && toString(obj) === "[object Object]";
3745
- }
3746
-
3747
- var isArray = Array.isArray || function(obj){
3748
- /*istanbul ignore next:cant test*/
3749
- return toStr.call(obj) === '[object Array]';
3750
- };
3751
-
3752
- function isBoolean(obj){
3753
- return typeof obj === 'boolean' || toString(obj) === '[object Boolean]';
3754
- }
3755
-
3756
- function getKey(key){
3757
- var intKey = parseInt(key);
3758
- if (intKey.toString() === key) {
3759
- return intKey;
3760
- }
3761
- return key;
3762
- }
3763
-
3764
- function factory(options) {
3765
- options = options || {};
3766
-
3767
- var objectPath = function(obj) {
3768
- return Object.keys(objectPath).reduce(function(proxy, prop) {
3769
- if(prop === 'create') {
3770
- return proxy;
3771
- }
3772
-
3773
- /*istanbul ignore else*/
3774
- if (typeof objectPath[prop] === 'function') {
3775
- proxy[prop] = objectPath[prop].bind(objectPath, obj);
3776
- }
3777
-
3778
- return proxy;
3779
- }, {});
3780
- };
3781
-
3782
- var hasShallowProperty;
3783
- if (options.includeInheritedProps) {
3784
- hasShallowProperty = function () {
3785
- return true
3786
- };
3787
- } else {
3788
- hasShallowProperty = function (obj, prop) {
3789
- return (typeof prop === 'number' && Array.isArray(obj)) || hasOwnProperty(obj, prop)
3790
- };
3791
- }
3792
-
3793
- function getShallowProperty(obj, prop) {
3794
- if (hasShallowProperty(obj, prop)) {
3795
- return obj[prop];
3796
- }
3797
- }
3798
-
3799
- function set(obj, path, value, doNotReplace){
3800
- if (typeof path === 'number') {
3801
- path = [path];
3802
- }
3803
- if (!path || path.length === 0) {
3804
- return obj;
3805
- }
3806
- if (typeof path === 'string') {
3807
- return set(obj, path.split('.').map(getKey), value, doNotReplace);
3808
- }
3809
- var currentPath = path[0];
3810
- var currentValue = getShallowProperty(obj, currentPath);
3811
- if (options.includeInheritedProps && (currentPath === '__proto__' ||
3812
- (currentPath === 'constructor' && typeof currentValue === 'function'))) {
3813
- throw new Error('For security reasons, object\'s magic properties cannot be set')
3814
- }
3815
- if (path.length === 1) {
3816
- if (currentValue === void 0 || !doNotReplace) {
3817
- obj[currentPath] = value;
3818
- }
3819
- return currentValue;
3820
- }
3821
-
3822
- if (currentValue === void 0) {
3823
- //check if we assume an array
3824
- if(typeof path[1] === 'number') {
3825
- obj[currentPath] = [];
3826
- } else {
3827
- obj[currentPath] = {};
3828
- }
3829
- }
3830
-
3831
- return set(obj[currentPath], path.slice(1), value, doNotReplace);
3832
- }
3833
-
3834
- objectPath.has = function (obj, path) {
3835
- if (typeof path === 'number') {
3836
- path = [path];
3837
- } else if (typeof path === 'string') {
3838
- path = path.split('.');
3839
- }
3840
-
3841
- if (!path || path.length === 0) {
3842
- return !!obj;
3843
- }
3844
-
3845
- for (var i = 0; i < path.length; i++) {
3846
- var j = getKey(path[i]);
3847
-
3848
- if((typeof j === 'number' && isArray(obj) && j < obj.length) ||
3849
- (options.includeInheritedProps ? (j in Object(obj)) : hasOwnProperty(obj, j))) {
3850
- obj = obj[j];
3851
- } else {
3852
- return false;
3853
- }
3854
- }
3855
-
3856
- return true;
3857
- };
3858
-
3859
- objectPath.ensureExists = function (obj, path, value){
3860
- return set(obj, path, value, true);
3861
- };
3862
-
3863
- objectPath.set = function (obj, path, value, doNotReplace){
3864
- return set(obj, path, value, doNotReplace);
3865
- };
3866
-
3867
- objectPath.insert = function (obj, path, value, at){
3868
- var arr = objectPath.get(obj, path);
3869
- at = ~~at;
3870
- if (!isArray(arr)) {
3871
- arr = [];
3872
- objectPath.set(obj, path, arr);
3873
- }
3874
- arr.splice(at, 0, value);
3875
- };
3876
-
3877
- objectPath.empty = function(obj, path) {
3878
- if (isEmpty(path)) {
3879
- return void 0;
3880
- }
3881
- if (obj == null) {
3882
- return void 0;
3883
- }
3884
-
3885
- var value, i;
3886
- if (!(value = objectPath.get(obj, path))) {
3887
- return void 0;
3888
- }
3889
-
3890
- if (typeof value === 'string') {
3891
- return objectPath.set(obj, path, '');
3892
- } else if (isBoolean(value)) {
3893
- return objectPath.set(obj, path, false);
3894
- } else if (typeof value === 'number') {
3895
- return objectPath.set(obj, path, 0);
3896
- } else if (isArray(value)) {
3897
- value.length = 0;
3898
- } else if (isObject(value)) {
3899
- for (i in value) {
3900
- if (hasShallowProperty(value, i)) {
3901
- delete value[i];
3902
- }
3903
- }
3904
- } else {
3905
- return objectPath.set(obj, path, null);
3906
- }
3907
- };
3908
-
3909
- objectPath.push = function (obj, path /*, values */){
3910
- var arr = objectPath.get(obj, path);
3911
- if (!isArray(arr)) {
3912
- arr = [];
3913
- objectPath.set(obj, path, arr);
3914
- }
3915
-
3916
- arr.push.apply(arr, Array.prototype.slice.call(arguments, 2));
3917
- };
3918
-
3919
- objectPath.coalesce = function (obj, paths, defaultValue) {
3920
- var value;
3921
-
3922
- for (var i = 0, len = paths.length; i < len; i++) {
3923
- if ((value = objectPath.get(obj, paths[i])) !== void 0) {
3924
- return value;
3925
- }
3926
- }
3927
-
3928
- return defaultValue;
3929
- };
3930
-
3931
- objectPath.get = function (obj, path, defaultValue){
3932
- if (typeof path === 'number') {
3933
- path = [path];
3934
- }
3935
- if (!path || path.length === 0) {
3936
- return obj;
3937
- }
3938
- if (obj == null) {
3939
- return defaultValue;
3940
- }
3941
- if (typeof path === 'string') {
3942
- return objectPath.get(obj, path.split('.'), defaultValue);
3943
- }
3944
-
3945
- var currentPath = getKey(path[0]);
3946
- var nextObj = getShallowProperty(obj, currentPath);
3947
- if (nextObj === void 0) {
3948
- return defaultValue;
3949
- }
3950
-
3951
- if (path.length === 1) {
3952
- return nextObj;
3953
- }
3954
-
3955
- return objectPath.get(obj[currentPath], path.slice(1), defaultValue);
3956
- };
3957
-
3958
- objectPath.del = function del(obj, path) {
3959
- if (typeof path === 'number') {
3960
- path = [path];
3961
- }
3962
-
3963
- if (obj == null) {
3964
- return obj;
3965
- }
3966
-
3967
- if (isEmpty(path)) {
3968
- return obj;
3969
- }
3970
- if(typeof path === 'string') {
3971
- return objectPath.del(obj, path.split('.'));
3972
- }
3973
-
3974
- var currentPath = getKey(path[0]);
3975
- if (!hasShallowProperty(obj, currentPath)) {
3976
- return obj;
3977
- }
3978
-
3979
- if(path.length === 1) {
3980
- if (isArray(obj)) {
3981
- obj.splice(currentPath, 1);
3982
- } else {
3983
- delete obj[currentPath];
3984
- }
3985
- } else {
3986
- return objectPath.del(obj[currentPath], path.slice(1));
3987
- }
3988
-
3989
- return obj;
3990
- };
3991
-
3992
- return objectPath;
3993
- }
3994
-
3995
- var mod = factory();
3996
- mod.create = factory;
3997
- mod.withInheritedProps = factory({includeInheritedProps: true});
3998
- return mod;
3999
- });
4000
- }(objectPath$1));
4001
-
4002
- var objectPath = objectPath$1.exports;
4003
-
4004
- var matcher$1 = {exports: {}};
4005
-
4006
- var escapeStringRegexp$1 = string => {
4007
- if (typeof string !== 'string') {
4008
- throw new TypeError('Expected a string');
4009
- }
4010
-
4011
- // Escape characters with special meaning either inside or outside character sets.
4012
- // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
4013
- return string
4014
- .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
4015
- .replace(/-/g, '\\x2d');
4016
- };
4017
-
4018
- const escapeStringRegexp = escapeStringRegexp$1;
4019
-
4020
- const regexpCache = new Map();
4021
-
4022
- function sanitizeArray(input, inputName) {
4023
- if (!Array.isArray(input)) {
4024
- switch (typeof input) {
4025
- case 'string':
4026
- input = [input];
4027
- break;
4028
- case 'undefined':
4029
- input = [];
4030
- break;
4031
- default:
4032
- throw new TypeError(`Expected '${inputName}' to be a string or an array, but got a type of '${typeof input}'`);
4033
- }
4034
- }
4035
-
4036
- return input.filter(string => {
4037
- if (typeof string !== 'string') {
4038
- if (typeof string === 'undefined') {
4039
- return false;
4040
- }
4041
-
4042
- throw new TypeError(`Expected '${inputName}' to be an array of strings, but found a type of '${typeof string}' in the array`);
4043
- }
4044
-
4045
- return true;
4046
- });
4047
- }
4048
-
4049
- function makeRegexp(pattern, options) {
4050
- options = {
4051
- caseSensitive: false,
4052
- ...options
4053
- };
4054
-
4055
- const cacheKey = pattern + JSON.stringify(options);
4056
-
4057
- if (regexpCache.has(cacheKey)) {
4058
- return regexpCache.get(cacheKey);
4059
- }
4060
-
4061
- const negated = pattern[0] === '!';
4062
-
4063
- if (negated) {
4064
- pattern = pattern.slice(1);
4065
- }
4066
-
4067
- pattern = escapeStringRegexp(pattern).replace(/\\\*/g, '[\\s\\S]*');
4068
-
4069
- const regexp = new RegExp(`^${pattern}$`, options.caseSensitive ? '' : 'i');
4070
- regexp.negated = negated;
4071
- regexpCache.set(cacheKey, regexp);
4072
-
4073
- return regexp;
4074
- }
4075
-
4076
- matcher$1.exports = (inputs, patterns, options) => {
4077
- inputs = sanitizeArray(inputs, 'inputs');
4078
- patterns = sanitizeArray(patterns, 'patterns');
4079
-
4080
- if (patterns.length === 0) {
4081
- return [];
4082
- }
4083
-
4084
- const isFirstPatternNegated = patterns[0][0] === '!';
4085
-
4086
- patterns = patterns.map(pattern => makeRegexp(pattern, options));
4087
-
4088
- const result = [];
4089
-
4090
- for (const input of inputs) {
4091
- // If first pattern is negated we include everything to match user expectation.
4092
- let matches = isFirstPatternNegated;
4093
-
4094
- for (const pattern of patterns) {
4095
- if (pattern.test(input)) {
4096
- matches = !pattern.negated;
4097
- }
4098
- }
4099
-
4100
- if (matches) {
4101
- result.push(input);
4102
- }
4103
- }
4104
-
4105
- return result;
4106
- };
4107
-
4108
- matcher$1.exports.isMatch = (inputs, patterns, options) => {
4109
- inputs = sanitizeArray(inputs, 'inputs');
4110
- patterns = sanitizeArray(patterns, 'patterns');
4111
-
4112
- if (patterns.length === 0) {
4113
- return false;
4114
- }
4115
-
4116
- return inputs.some(input => {
4117
- return patterns.every(pattern => {
4118
- const regexp = makeRegexp(pattern, options);
4119
- const matches = regexp.test(input);
4120
- return regexp.negated ? !matches : matches;
4121
- });
4122
- });
4123
- };
4124
-
4125
- var matcher = matcher$1.exports;
4126
-
4127
- const defaults = {
4128
- ignoreKeys: [],
4129
- ignorePaths: [],
4130
- acceptArrays: false,
4131
- acceptArraysIgnore: [],
4132
- enforceStrictKeyset: true,
4133
- schema: {},
4134
- msg: "check-types-mini",
4135
- optsVarName: "opts",
4136
- };
4137
- // fourth input argument is shielded from an external API:
4138
- function internalApi(obj, ref, originalOptions) {
4139
- //
4140
- // Functions
4141
- // =========
4142
- function existy(something) {
4143
- return something != null; // deliberate !=
4144
- }
4145
- function isObj(something) {
4146
- return typ(something) === "Object";
4147
- }
4148
- function pullAllWithGlob(originalInput, toBeRemoved) {
4149
- if (typeof toBeRemoved === "string") {
4150
- toBeRemoved = arrayiffy(toBeRemoved);
4151
- }
4152
- return Array.from(originalInput).filter((originalVal) => !toBeRemoved.some((remVal) => matcher.isMatch(originalVal, remVal, {
4153
- caseSensitive: true,
4154
- })));
4155
- }
4156
- const hasKey = Object.prototype.hasOwnProperty;
4157
- // Variables
4158
- // =========
4159
- const NAMESFORANYTYPE = [
4160
- "any",
4161
- "anything",
4162
- "every",
4163
- "everything",
4164
- "all",
4165
- "whatever",
4166
- "whatevs",
4167
- ];
4168
- if (!existy(obj)) {
4169
- throw new Error("check-types-mini: [THROW_ID_01] First argument is missing!");
4170
- }
4171
- // Prep our own opts
4172
- // =================
4173
- const opts = { ...defaults, ...originalOptions };
4174
- if (typeof opts.ignoreKeys === "string") {
4175
- opts.ignoreKeys = [opts.ignoreKeys];
4176
- }
4177
- if (typeof opts.ignorePaths === "string") {
4178
- opts.ignorePaths = [opts.ignorePaths];
4179
- }
4180
- if (typeof opts.acceptArraysIgnore === "string") {
4181
- opts.acceptArraysIgnore = [opts.acceptArraysIgnore];
4182
- }
4183
- opts.msg = `${opts.msg}`.trim();
4184
- if (opts.msg[opts.msg.length - 1] === ":") {
4185
- opts.msg = opts.msg.slice(0, opts.msg.length - 1).trim();
4186
- }
4187
- // now, since we let users type the allowed types, we have to normalise the letter case:
4188
- if (isObj(opts.schema)) {
4189
- // 1. if schema is given as nested AST tree, for example:
4190
- // {
4191
- // schema: {
4192
- // option1: { somekey: "any" }, // <------ !
4193
- // option2: "whatever"
4194
- // }
4195
- // }
4196
- //
4197
- // (notice it's not flat, "option1.somekey": "any", but nested!)
4198
- //
4199
- // then, we flatten it first, so that each AST branch's path is key and the
4200
- // value at that branch's tip is the key's value:
4201
- // {
4202
- // schema: {
4203
- // "option1.somekey": "any", // <------ !
4204
- // option2: "whatever"
4205
- // }
4206
- // }
4207
- Object.keys(opts.schema).forEach((oneKey) => {
4208
- if (isObj(opts.schema[oneKey])) {
4209
- // 1. extract all unique AST branches leading to their tips
4210
- const tempObj = {};
4211
- traverse(opts.schema[oneKey], (key, val, innerObj) => {
4212
- const current = val !== undefined ? val : key;
4213
- if (!Array.isArray(current) && !isObj(current)) {
4214
- tempObj[`${oneKey}.${innerObj.path}`] = current;
4215
- }
4216
- return current;
4217
- });
4218
- // 2. delete that key which leads to object:
4219
- delete opts.schema[oneKey];
4220
- // 3. merge in all paths-as-keys into schema opts object:
4221
- opts.schema = { ...opts.schema, ...tempObj };
4222
- }
4223
- });
4224
- //
4225
- //
4226
- //
4227
- //
4228
- //
4229
- // 2. arrayiffy
4230
- Object.keys(opts.schema).forEach((oneKey) => {
4231
- if (!Array.isArray(opts.schema[oneKey])) {
4232
- opts.schema[oneKey] = [opts.schema[oneKey]];
4233
- }
4234
- // then turn all keys into strings and trim and lowercase them:
4235
- opts.schema[oneKey] = opts.schema[oneKey].map((el) => `${el}`.toLowerCase().trim());
4236
- });
4237
- }
4238
- else if (opts.schema != null) {
4239
- throw new Error(`check-types-mini: opts.schema was customised to ${JSON.stringify(opts.schema, null, 0)} which is not object but ${typeof opts.schema}`);
4240
- }
4241
- if (!existy(ref)) {
4242
- // eslint-disable-next-line no-param-reassign
4243
- ref = {};
4244
- }
4245
- // ---------------------------------------------------------------------------
4246
- // ---------------------------------------------------------------------------
4247
- // ---------------------------------------------------------------------------
4248
- // THE BUSINESS
4249
- // ============
4250
- // Since v.4 we support nested opts. That's AST's. This means, we will have to
4251
- // traverse them somehow up until the last tip of each branch. Luckily, we have
4252
- // tools for traversal - ast-monkey-traverse.
4253
- // 1. The "obj" and "ref" root level keys need separate attention.
4254
- // If keys mismatch, we need to check them separately from traversal.
4255
- // During traversal, we'll check if each value is a plain object/array and
4256
- // match the keysets as well. However, traversal won't "see" root level keys.
4257
- if (opts.enforceStrictKeyset) {
4258
- if (existy(opts.schema) && Object.keys(opts.schema).length > 0) {
4259
- if (ref &&
4260
- pullAllWithGlob(lodash_pullall(Object.keys(obj), Object.keys(ref).concat(Object.keys(opts.schema))), opts.ignoreKeys).length) {
4261
- const keys = lodash_pullall(Object.keys(obj), Object.keys(ref).concat(Object.keys(opts.schema)));
4262
- throw new TypeError(`${opts.msg}: ${opts.optsVarName}.enforceStrictKeyset is on and the following key${keys.length > 1 ? "s" : ""} ${keys.length > 1 ? "are" : "is"} not covered by schema and/or reference objects: ${keys.join(", ")}`);
4263
- }
4264
- }
4265
- else if (isObj(ref) && Object.keys(ref).length > 0) {
4266
- if (pullAllWithGlob(lodash_pullall(Object.keys(obj), Object.keys(ref)), opts.ignoreKeys).length !== 0) {
4267
- const keys = lodash_pullall(Object.keys(obj), Object.keys(ref));
4268
- throw new TypeError(`${opts.msg}: The input object has key${keys.length > 1 ? "s" : ""} which ${keys.length > 1 ? "are" : "is"} not covered by the reference object: ${keys.join(", ")}`);
4269
- }
4270
- else if (pullAllWithGlob(lodash_pullall(Object.keys(ref), Object.keys(obj)), opts.ignoreKeys).length !== 0) {
4271
- const keys = lodash_pullall(Object.keys(ref), Object.keys(obj));
4272
- throw new TypeError(`${opts.msg}: The reference object has key${keys.length > 1 ? "s" : ""} which ${keys.length > 1 ? "are" : "is"} not present in the input object: ${keys.join(", ")}`);
4273
- }
4274
- }
4275
- else {
4276
- // it's an error because both schema and reference don't exist
4277
- throw new TypeError(`${opts.msg}: Both ${opts.optsVarName}.schema and reference objects are missing! We don't have anything to match the keys as you requested via opts.enforceStrictKeyset!`);
4278
- }
4279
- }
4280
- // 2. Call the monkey and traverse the schema object, checking each value-as-object
4281
- // or value-as-array separately, if opts.enforceStrictKeyset is on. Root level
4282
- // was checked in step 1. above. What's left is deeper levels.
4283
- // When users set schema to "any" for certain path, this applies to that path
4284
- // and any (if exists) children objects/arrays/strings whatever on deeper children
4285
- // paths. Now, the problem is, we check by traversing everything - this means,
4286
- // for example, we have this to check:
4287
- //
4288
- // {
4289
- // a: {
4290
- // b: "c"
4291
- // },
4292
- // d: "e"
4293
- // }
4294
- // ast-monkey-traverse will check "a" and find it's schema is "any" - basically,
4295
- // we don't care what it's type is and instruct "check-types-mini" to skip it.
4296
- // This "skip" instruction applies to "b" too! However, our checking engine,
4297
- // "ast-monkey-traverse" will still traverse "b". It can't stop there, because
4298
- // there's still "d" key to check - we're traversing EVERYTHING.
4299
- // Challenge: when "ast-monkey" will stumble upon "b" it might flag it up as
4300
- // being of a wrong type, it does not have visibility of its parent's schemas.
4301
- // What we'll do to fix this is we'll compile the list of any paths that have
4302
- // "any"/"whatever" schemas in an array. Then, when deeper children nodes are
4303
- // traversed, we'll check, are they children of any aforementioned paths (technically
4304
- // speaking, do their path strings start with any of the strings in aforementioned
4305
- // paths array strings).
4306
- const ignoredPathsArr = [];
4307
- traverse(obj, (key, val, innerObj) => {
4308
- // innerObj.path
4309
- // Here what we have been given:
4310
- let current = val;
4311
- let objKey = key;
4312
- if (innerObj.parentType === "array") {
4313
- objKey = undefined;
4314
- current = key;
4315
- }
4316
- // Here's what we will compare against to.
4317
- // If schema exists, types defined there will be used to compare against:
4318
- // if current path is a children of any paths in "ignoredPathsArr", skip it:
4319
- if (Array.isArray(ignoredPathsArr) &&
4320
- ignoredPathsArr.length &&
4321
- ignoredPathsArr.some((path) => innerObj.path.startsWith(path))) {
4322
- return current;
4323
- }
4324
- // if this key is ignored, skip it:
4325
- if (objKey &&
4326
- opts.ignoreKeys.some((oneOfKeysToIgnore) => matcher.isMatch(objKey, oneOfKeysToIgnore))) {
4327
- return current;
4328
- }
4329
- // if this path is ignored, skip it:
4330
- if (opts.ignorePaths.some((oneOfPathsToIgnore) => matcher.isMatch(innerObj.path, oneOfPathsToIgnore))) {
4331
- return current;
4332
- }
4333
- const isNotAnArrayChild = !(!isObj(current) &&
4334
- !Array.isArray(current) &&
4335
- Array.isArray(innerObj.parent));
4336
- // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █
4337
- let optsSchemaHasThisPathDefined = false;
4338
- if (isObj(opts.schema) && hasKey.call(opts.schema, innerObj.path)) {
4339
- optsSchemaHasThisPathDefined = true;
4340
- }
4341
- let refHasThisPathDefined = false;
4342
- if (isObj(ref) && objectPath.has(ref, innerObj.path)) {
4343
- refHasThisPathDefined = true;
4344
- }
4345
- // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █
4346
- // First, check if given path is not covered by neither ref object nor schema.
4347
- // We also skip the non-container types (obj/arr) within arrays (test 02.11)
4348
- // Otherwise, we would get false throws because arrays can mention list of
4349
- // "things" (tag names, for example) and this application would enforce each
4350
- // one of them, does it exist in schema/ref, but it won't exist!
4351
- // Thus, strict existence checks apply only for object keys and arrays, not
4352
- // array elements which are not objects/arrays.
4353
- if (opts.enforceStrictKeyset &&
4354
- isNotAnArrayChild &&
4355
- !optsSchemaHasThisPathDefined &&
4356
- !refHasThisPathDefined) {
4357
- throw new TypeError(`${opts.msg}: ${opts.optsVarName}.${innerObj.path} is neither covered by reference object (second input argument), nor ${opts.optsVarName}.schema! To stop this error, turn off ${opts.optsVarName}.enforceStrictKeyset or provide some type reference (2nd argument or ${opts.optsVarName}.schema).\n\nDebug info:\n
4358
- obj = ${JSON.stringify(obj, null, 4)}\n
4359
- ref = ${JSON.stringify(ref, null, 4)}\n
4360
- innerObj = ${JSON.stringify(innerObj, null, 4)}\n
4361
- opts = ${JSON.stringify(opts, null, 4)}\n
4362
- current = ${JSON.stringify(current, null, 4)}\n\n`);
4363
- }
4364
- else if (optsSchemaHasThisPathDefined) {
4365
- // step 1. Fetch the current keys' schema and normalise it - it's an array
4366
- // which holds strings. Those strings have to be lowercased. It also can
4367
- // be raw null/undefined, which would be arrayified and turned into string.
4368
- const currentKeysSchema = arrayiffy(opts.schema[innerObj.path]).map((el) => `${el}`.toLowerCase());
4369
- objectPath.set(opts.schema, innerObj.path, currentKeysSchema);
4370
- // step 2. First check does our schema contain any blanket names, "any", "whatever" etc.
4371
- if (!lodash_intersection(currentKeysSchema, NAMESFORANYTYPE).length) {
4372
- // Because, if not, it means we need to do some work, check types.
4373
- // Beware, Booleans can be allowed blanket, as "boolean", but also,
4374
- // in granular fashion: as just "true" or just "false".
4375
- if ((current !== true &&
4376
- current !== false &&
4377
- !currentKeysSchema.includes(typ(current).toLowerCase())) ||
4378
- ((current === true || current === false) &&
4379
- !currentKeysSchema.includes(String(current)) &&
4380
- !currentKeysSchema.includes("boolean"))) {
4381
- // new in v.2.2
4382
- // Check if key's value is array. Then, if it is, check if opts.acceptArrays is on.
4383
- // If it is, then iterate through the array, checking does each value conform to the
4384
- // types listed in that key's schema entry.
4385
- if (Array.isArray(current) && opts.acceptArrays) {
4386
- // check each key:
4387
- for (let i = 0, len = current.length; i < len; i++) {
4388
- if (!currentKeysSchema.includes(typ(current[i]).toLowerCase())) {
4389
- throw new TypeError(`${opts.msg}: ${opts.optsVarName}.${innerObj.path}.${i}, the ${i}th element (equal to ${JSON.stringify(current[i], null, 0)}) is of a type ${typ(current[i]).toLowerCase()}, but only the following are allowed by the ${opts.optsVarName}.schema: ${currentKeysSchema.join(", ")}`);
4390
- }
4391
- }
4392
- }
4393
- else {
4394
- // only then do throw...
4395
- throw new TypeError(`${opts.msg}: ${opts.optsVarName}.${innerObj.path} was customised to ${typ(current) !== "string" ? '"' : ""}${JSON.stringify(current, null, 0)}${typ(current) !== "string" ? '"' : ""} (type: ${typ(current).toLowerCase()}) which is not among the allowed types in schema (which is equal to ${JSON.stringify(currentKeysSchema, null, 0)})`);
4396
- }
4397
- }
4398
- }
4399
- else {
4400
- ignoredPathsArr.push(innerObj.path);
4401
- }
4402
- }
4403
- else if (ref && isObj(ref) && refHasThisPathDefined) {
4404
- const compareTo = objectPath.get(ref, innerObj.path);
4405
- if (opts.acceptArrays &&
4406
- Array.isArray(current) &&
4407
- !opts.acceptArraysIgnore.includes(key)) {
4408
- const allMatch = current.every((el) => typ(el).toLowerCase() === typ(ref[key]).toLowerCase());
4409
- if (!allMatch) {
4410
- throw new TypeError(`${opts.msg}: ${opts.optsVarName}.${innerObj.path} was customised to be array, but not all of its elements are ${typ(ref[key]).toLowerCase()}-type`);
4411
- }
4412
- }
4413
- else if (typ(current) !== typ(compareTo)) {
4414
- throw new TypeError(`${opts.msg}: ${opts.optsVarName}.${innerObj.path} was customised to ${typ(current).toLowerCase() === "string" ? "" : '"'}${JSON.stringify(current, null, 0)}${typ(current).toLowerCase() === "string" ? "" : '"'} which is not ${typ(compareTo).toLowerCase()} but ${typ(current).toLowerCase()}`);
4415
- }
4416
- }
4417
- else ;
4418
- return current;
4419
- });
4420
- }
4421
- /**
4422
- * Validate options object
4423
- */
4424
- function checkTypesMini(obj, ref, originalOptions) {
4425
- return internalApi(obj, ref, originalOptions);
4426
- }
4427
-
4428
- exports.checkTypesMini = checkTypesMini;
4429
-
4430
- Object.defineProperty(exports, '__esModule', { value: true });
4431
-
4432
- })));