ast-compare 2.0.16 → 3.0.2

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,2726 +0,0 @@
1
- /**
2
- * @name ast-compare
3
- * @fileoverview Compare anything: AST, objects, arrays, strings and nested thereof
4
- * @version 2.0.16
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/ast-compare/}
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.astCompare = {}));
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
- function createCommonjsModule(fn) {
19
- var module = { exports: {} };
20
- return fn(module, module.exports), module.exports;
21
- }
22
-
23
- var typeDetect = createCommonjsModule(function (module, exports) {
24
- (function (global, factory) {
25
- module.exports = factory() ;
26
- }(commonjsGlobal, (function () {
27
- /* !
28
- * type-detect
29
- * Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
30
- * MIT Licensed
31
- */
32
- var promiseExists = typeof Promise === 'function';
33
-
34
- /* eslint-disable no-undef */
35
- var globalObject = typeof self === 'object' ? self : commonjsGlobal; // eslint-disable-line id-blacklist
36
-
37
- var symbolExists = typeof Symbol !== 'undefined';
38
- var mapExists = typeof Map !== 'undefined';
39
- var setExists = typeof Set !== 'undefined';
40
- var weakMapExists = typeof WeakMap !== 'undefined';
41
- var weakSetExists = typeof WeakSet !== 'undefined';
42
- var dataViewExists = typeof DataView !== 'undefined';
43
- var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
44
- var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
45
- var setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
46
- var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
47
- var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
48
- var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
49
- var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
50
- var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
51
- var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function';
52
- var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
53
- var toStringLeftSliceLength = 8;
54
- var toStringRightSliceLength = -1;
55
- /**
56
- * ### typeOf (obj)
57
- *
58
- * Uses `Object.prototype.toString` to determine the type of an object,
59
- * normalising behaviour across engine versions & well optimised.
60
- *
61
- * @param {Mixed} object
62
- * @return {String} object type
63
- * @api public
64
- */
65
- function typeDetect(obj) {
66
- /* ! Speed optimisation
67
- * Pre:
68
- * string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
69
- * boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled)
70
- * number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled)
71
- * undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled)
72
- * function x 2,556,769 ops/sec ±1.73% (77 runs sampled)
73
- * Post:
74
- * string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled)
75
- * boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled)
76
- * number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled)
77
- * undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled)
78
- * function x 31,296,870 ops/sec ±0.96% (83 runs sampled)
79
- */
80
- var typeofObj = typeof obj;
81
- if (typeofObj !== 'object') {
82
- return typeofObj;
83
- }
84
-
85
- /* ! Speed optimisation
86
- * Pre:
87
- * null x 28,645,765 ops/sec ±1.17% (82 runs sampled)
88
- * Post:
89
- * null x 36,428,962 ops/sec ±1.37% (84 runs sampled)
90
- */
91
- if (obj === null) {
92
- return 'null';
93
- }
94
-
95
- /* ! Spec Conformance
96
- * Test: `Object.prototype.toString.call(window)``
97
- * - Node === "[object global]"
98
- * - Chrome === "[object global]"
99
- * - Firefox === "[object Window]"
100
- * - PhantomJS === "[object Window]"
101
- * - Safari === "[object Window]"
102
- * - IE 11 === "[object Window]"
103
- * - IE Edge === "[object Window]"
104
- * Test: `Object.prototype.toString.call(this)``
105
- * - Chrome Worker === "[object global]"
106
- * - Firefox Worker === "[object DedicatedWorkerGlobalScope]"
107
- * - Safari Worker === "[object DedicatedWorkerGlobalScope]"
108
- * - IE 11 Worker === "[object WorkerGlobalScope]"
109
- * - IE Edge Worker === "[object WorkerGlobalScope]"
110
- */
111
- if (obj === globalObject) {
112
- return 'global';
113
- }
114
-
115
- /* ! Speed optimisation
116
- * Pre:
117
- * array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled)
118
- * Post:
119
- * array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
120
- */
121
- if (
122
- Array.isArray(obj) &&
123
- (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))
124
- ) {
125
- return 'Array';
126
- }
127
-
128
- // Not caching existence of `window` and related properties due to potential
129
- // for `window` to be unset before tests in quasi-browser environments.
130
- if (typeof window === 'object' && window !== null) {
131
- /* ! Spec Conformance
132
- * (https://html.spec.whatwg.org/multipage/browsers.html#location)
133
- * WhatWG HTML$7.7.3 - The `Location` interface
134
- * Test: `Object.prototype.toString.call(window.location)``
135
- * - IE <=11 === "[object Object]"
136
- * - IE Edge <=13 === "[object Object]"
137
- */
138
- if (typeof window.location === 'object' && obj === window.location) {
139
- return 'Location';
140
- }
141
-
142
- /* ! Spec Conformance
143
- * (https://html.spec.whatwg.org/#document)
144
- * WhatWG HTML$3.1.1 - The `Document` object
145
- * Note: Most browsers currently adher to the W3C DOM Level 2 spec
146
- * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)
147
- * which suggests that browsers should use HTMLTableCellElement for
148
- * both TD and TH elements. WhatWG separates these.
149
- * WhatWG HTML states:
150
- * > For historical reasons, Window objects must also have a
151
- * > writable, configurable, non-enumerable property named
152
- * > HTMLDocument whose value is the Document interface object.
153
- * Test: `Object.prototype.toString.call(document)``
154
- * - Chrome === "[object HTMLDocument]"
155
- * - Firefox === "[object HTMLDocument]"
156
- * - Safari === "[object HTMLDocument]"
157
- * - IE <=10 === "[object Document]"
158
- * - IE 11 === "[object HTMLDocument]"
159
- * - IE Edge <=13 === "[object HTMLDocument]"
160
- */
161
- if (typeof window.document === 'object' && obj === window.document) {
162
- return 'Document';
163
- }
164
-
165
- if (typeof window.navigator === 'object') {
166
- /* ! Spec Conformance
167
- * (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
168
- * WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
169
- * Test: `Object.prototype.toString.call(navigator.mimeTypes)``
170
- * - IE <=10 === "[object MSMimeTypesCollection]"
171
- */
172
- if (typeof window.navigator.mimeTypes === 'object' &&
173
- obj === window.navigator.mimeTypes) {
174
- return 'MimeTypeArray';
175
- }
176
-
177
- /* ! Spec Conformance
178
- * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
179
- * WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
180
- * Test: `Object.prototype.toString.call(navigator.plugins)``
181
- * - IE <=10 === "[object MSPluginsCollection]"
182
- */
183
- if (typeof window.navigator.plugins === 'object' &&
184
- obj === window.navigator.plugins) {
185
- return 'PluginArray';
186
- }
187
- }
188
-
189
- if ((typeof window.HTMLElement === 'function' ||
190
- typeof window.HTMLElement === 'object') &&
191
- obj instanceof window.HTMLElement) {
192
- /* ! Spec Conformance
193
- * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
194
- * WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
195
- * Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
196
- * - IE <=10 === "[object HTMLBlockElement]"
197
- */
198
- if (obj.tagName === 'BLOCKQUOTE') {
199
- return 'HTMLQuoteElement';
200
- }
201
-
202
- /* ! Spec Conformance
203
- * (https://html.spec.whatwg.org/#htmltabledatacellelement)
204
- * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
205
- * Note: Most browsers currently adher to the W3C DOM Level 2 spec
206
- * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
207
- * which suggests that browsers should use HTMLTableCellElement for
208
- * both TD and TH elements. WhatWG separates these.
209
- * Test: Object.prototype.toString.call(document.createElement('td'))
210
- * - Chrome === "[object HTMLTableCellElement]"
211
- * - Firefox === "[object HTMLTableCellElement]"
212
- * - Safari === "[object HTMLTableCellElement]"
213
- */
214
- if (obj.tagName === 'TD') {
215
- return 'HTMLTableDataCellElement';
216
- }
217
-
218
- /* ! Spec Conformance
219
- * (https://html.spec.whatwg.org/#htmltableheadercellelement)
220
- * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
221
- * Note: Most browsers currently adher to the W3C DOM Level 2 spec
222
- * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
223
- * which suggests that browsers should use HTMLTableCellElement for
224
- * both TD and TH elements. WhatWG separates these.
225
- * Test: Object.prototype.toString.call(document.createElement('th'))
226
- * - Chrome === "[object HTMLTableCellElement]"
227
- * - Firefox === "[object HTMLTableCellElement]"
228
- * - Safari === "[object HTMLTableCellElement]"
229
- */
230
- if (obj.tagName === 'TH') {
231
- return 'HTMLTableHeaderCellElement';
232
- }
233
- }
234
- }
235
-
236
- /* ! Speed optimisation
237
- * Pre:
238
- * Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled)
239
- * Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled)
240
- * Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled)
241
- * Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled)
242
- * Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled)
243
- * Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled)
244
- * Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled)
245
- * Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled)
246
- * Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled)
247
- * Post:
248
- * Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled)
249
- * Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled)
250
- * Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled)
251
- * Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled)
252
- * Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled)
253
- * Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled)
254
- * Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled)
255
- * Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled)
256
- * Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled)
257
- */
258
- var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]);
259
- if (typeof stringTag === 'string') {
260
- return stringTag;
261
- }
262
-
263
- var objPrototype = Object.getPrototypeOf(obj);
264
- /* ! Speed optimisation
265
- * Pre:
266
- * regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled)
267
- * regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled)
268
- * Post:
269
- * regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled)
270
- * regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled)
271
- */
272
- if (objPrototype === RegExp.prototype) {
273
- return 'RegExp';
274
- }
275
-
276
- /* ! Speed optimisation
277
- * Pre:
278
- * date x 2,130,074 ops/sec ±4.42% (68 runs sampled)
279
- * Post:
280
- * date x 3,953,779 ops/sec ±1.35% (77 runs sampled)
281
- */
282
- if (objPrototype === Date.prototype) {
283
- return 'Date';
284
- }
285
-
286
- /* ! Spec Conformance
287
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag)
288
- * ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise":
289
- * Test: `Object.prototype.toString.call(Promise.resolve())``
290
- * - Chrome <=47 === "[object Object]"
291
- * - Edge <=20 === "[object Object]"
292
- * - Firefox 29-Latest === "[object Promise]"
293
- * - Safari 7.1-Latest === "[object Promise]"
294
- */
295
- if (promiseExists && objPrototype === Promise.prototype) {
296
- return 'Promise';
297
- }
298
-
299
- /* ! Speed optimisation
300
- * Pre:
301
- * set x 2,222,186 ops/sec ±1.31% (82 runs sampled)
302
- * Post:
303
- * set x 4,545,879 ops/sec ±1.13% (83 runs sampled)
304
- */
305
- if (setExists && objPrototype === Set.prototype) {
306
- return 'Set';
307
- }
308
-
309
- /* ! Speed optimisation
310
- * Pre:
311
- * map x 2,396,842 ops/sec ±1.59% (81 runs sampled)
312
- * Post:
313
- * map x 4,183,945 ops/sec ±6.59% (82 runs sampled)
314
- */
315
- if (mapExists && objPrototype === Map.prototype) {
316
- return 'Map';
317
- }
318
-
319
- /* ! Speed optimisation
320
- * Pre:
321
- * weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled)
322
- * Post:
323
- * weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled)
324
- */
325
- if (weakSetExists && objPrototype === WeakSet.prototype) {
326
- return 'WeakSet';
327
- }
328
-
329
- /* ! Speed optimisation
330
- * Pre:
331
- * weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled)
332
- * Post:
333
- * weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled)
334
- */
335
- if (weakMapExists && objPrototype === WeakMap.prototype) {
336
- return 'WeakMap';
337
- }
338
-
339
- /* ! Spec Conformance
340
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag)
341
- * ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView":
342
- * Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))``
343
- * - Edge <=13 === "[object Object]"
344
- */
345
- if (dataViewExists && objPrototype === DataView.prototype) {
346
- return 'DataView';
347
- }
348
-
349
- /* ! Spec Conformance
350
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag)
351
- * ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator":
352
- * Test: `Object.prototype.toString.call(new Map().entries())``
353
- * - Edge <=13 === "[object Object]"
354
- */
355
- if (mapExists && objPrototype === mapIteratorPrototype) {
356
- return 'Map Iterator';
357
- }
358
-
359
- /* ! Spec Conformance
360
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag)
361
- * ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator":
362
- * Test: `Object.prototype.toString.call(new Set().entries())``
363
- * - Edge <=13 === "[object Object]"
364
- */
365
- if (setExists && objPrototype === setIteratorPrototype) {
366
- return 'Set Iterator';
367
- }
368
-
369
- /* ! Spec Conformance
370
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag)
371
- * ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator":
372
- * Test: `Object.prototype.toString.call([][Symbol.iterator]())``
373
- * - Edge <=13 === "[object Object]"
374
- */
375
- if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
376
- return 'Array Iterator';
377
- }
378
-
379
- /* ! Spec Conformance
380
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag)
381
- * ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator":
382
- * Test: `Object.prototype.toString.call(''[Symbol.iterator]())``
383
- * - Edge <=13 === "[object Object]"
384
- */
385
- if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
386
- return 'String Iterator';
387
- }
388
-
389
- /* ! Speed optimisation
390
- * Pre:
391
- * object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled)
392
- * Post:
393
- * object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled)
394
- */
395
- if (objPrototype === null) {
396
- return 'Object';
397
- }
398
-
399
- return Object
400
- .prototype
401
- .toString
402
- .call(obj)
403
- .slice(toStringLeftSliceLength, toStringRightSliceLength);
404
- }
405
-
406
- return typeDetect;
407
-
408
- })));
409
- });
410
-
411
- /**
412
- * lodash (Custom Build) <https://lodash.com/>
413
- * Build: `lodash modularize exports="npm" -o ./`
414
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
415
- * Released under MIT license <https://lodash.com/license>
416
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
417
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
418
- */
419
-
420
- var lodash_clonedeep = createCommonjsModule(function (module, exports) {
421
- /** Used as the size to enable large array optimizations. */
422
- var LARGE_ARRAY_SIZE = 200;
423
-
424
- /** Used to stand-in for `undefined` hash values. */
425
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
426
-
427
- /** Used as references for various `Number` constants. */
428
- var MAX_SAFE_INTEGER = 9007199254740991;
429
-
430
- /** `Object#toString` result references. */
431
- var argsTag = '[object Arguments]',
432
- arrayTag = '[object Array]',
433
- boolTag = '[object Boolean]',
434
- dateTag = '[object Date]',
435
- errorTag = '[object Error]',
436
- funcTag = '[object Function]',
437
- genTag = '[object GeneratorFunction]',
438
- mapTag = '[object Map]',
439
- numberTag = '[object Number]',
440
- objectTag = '[object Object]',
441
- promiseTag = '[object Promise]',
442
- regexpTag = '[object RegExp]',
443
- setTag = '[object Set]',
444
- stringTag = '[object String]',
445
- symbolTag = '[object Symbol]',
446
- weakMapTag = '[object WeakMap]';
447
-
448
- var arrayBufferTag = '[object ArrayBuffer]',
449
- dataViewTag = '[object DataView]',
450
- float32Tag = '[object Float32Array]',
451
- float64Tag = '[object Float64Array]',
452
- int8Tag = '[object Int8Array]',
453
- int16Tag = '[object Int16Array]',
454
- int32Tag = '[object Int32Array]',
455
- uint8Tag = '[object Uint8Array]',
456
- uint8ClampedTag = '[object Uint8ClampedArray]',
457
- uint16Tag = '[object Uint16Array]',
458
- uint32Tag = '[object Uint32Array]';
459
-
460
- /**
461
- * Used to match `RegExp`
462
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
463
- */
464
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
465
-
466
- /** Used to match `RegExp` flags from their coerced string values. */
467
- var reFlags = /\w*$/;
468
-
469
- /** Used to detect host constructors (Safari). */
470
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
471
-
472
- /** Used to detect unsigned integer values. */
473
- var reIsUint = /^(?:0|[1-9]\d*)$/;
474
-
475
- /** Used to identify `toStringTag` values supported by `_.clone`. */
476
- var cloneableTags = {};
477
- cloneableTags[argsTag] = cloneableTags[arrayTag] =
478
- cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
479
- cloneableTags[boolTag] = cloneableTags[dateTag] =
480
- cloneableTags[float32Tag] = cloneableTags[float64Tag] =
481
- cloneableTags[int8Tag] = cloneableTags[int16Tag] =
482
- cloneableTags[int32Tag] = cloneableTags[mapTag] =
483
- cloneableTags[numberTag] = cloneableTags[objectTag] =
484
- cloneableTags[regexpTag] = cloneableTags[setTag] =
485
- cloneableTags[stringTag] = cloneableTags[symbolTag] =
486
- cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
487
- cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
488
- cloneableTags[errorTag] = cloneableTags[funcTag] =
489
- cloneableTags[weakMapTag] = false;
490
-
491
- /** Detect free variable `global` from Node.js. */
492
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
493
-
494
- /** Detect free variable `self`. */
495
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
496
-
497
- /** Used as a reference to the global object. */
498
- var root = freeGlobal || freeSelf || Function('return this')();
499
-
500
- /** Detect free variable `exports`. */
501
- var freeExports = exports && !exports.nodeType && exports;
502
-
503
- /** Detect free variable `module`. */
504
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
505
-
506
- /** Detect the popular CommonJS extension `module.exports`. */
507
- var moduleExports = freeModule && freeModule.exports === freeExports;
508
-
509
- /**
510
- * Adds the key-value `pair` to `map`.
511
- *
512
- * @private
513
- * @param {Object} map The map to modify.
514
- * @param {Array} pair The key-value pair to add.
515
- * @returns {Object} Returns `map`.
516
- */
517
- function addMapEntry(map, pair) {
518
- // Don't return `map.set` because it's not chainable in IE 11.
519
- map.set(pair[0], pair[1]);
520
- return map;
521
- }
522
-
523
- /**
524
- * Adds `value` to `set`.
525
- *
526
- * @private
527
- * @param {Object} set The set to modify.
528
- * @param {*} value The value to add.
529
- * @returns {Object} Returns `set`.
530
- */
531
- function addSetEntry(set, value) {
532
- // Don't return `set.add` because it's not chainable in IE 11.
533
- set.add(value);
534
- return set;
535
- }
536
-
537
- /**
538
- * A specialized version of `_.forEach` for arrays without support for
539
- * iteratee shorthands.
540
- *
541
- * @private
542
- * @param {Array} [array] The array to iterate over.
543
- * @param {Function} iteratee The function invoked per iteration.
544
- * @returns {Array} Returns `array`.
545
- */
546
- function arrayEach(array, iteratee) {
547
- var index = -1,
548
- length = array ? array.length : 0;
549
-
550
- while (++index < length) {
551
- if (iteratee(array[index], index, array) === false) {
552
- break;
553
- }
554
- }
555
- return array;
556
- }
557
-
558
- /**
559
- * Appends the elements of `values` to `array`.
560
- *
561
- * @private
562
- * @param {Array} array The array to modify.
563
- * @param {Array} values The values to append.
564
- * @returns {Array} Returns `array`.
565
- */
566
- function arrayPush(array, values) {
567
- var index = -1,
568
- length = values.length,
569
- offset = array.length;
570
-
571
- while (++index < length) {
572
- array[offset + index] = values[index];
573
- }
574
- return array;
575
- }
576
-
577
- /**
578
- * A specialized version of `_.reduce` for arrays without support for
579
- * iteratee shorthands.
580
- *
581
- * @private
582
- * @param {Array} [array] The array to iterate over.
583
- * @param {Function} iteratee The function invoked per iteration.
584
- * @param {*} [accumulator] The initial value.
585
- * @param {boolean} [initAccum] Specify using the first element of `array` as
586
- * the initial value.
587
- * @returns {*} Returns the accumulated value.
588
- */
589
- function arrayReduce(array, iteratee, accumulator, initAccum) {
590
- var index = -1,
591
- length = array ? array.length : 0;
592
-
593
- if (initAccum && length) {
594
- accumulator = array[++index];
595
- }
596
- while (++index < length) {
597
- accumulator = iteratee(accumulator, array[index], index, array);
598
- }
599
- return accumulator;
600
- }
601
-
602
- /**
603
- * The base implementation of `_.times` without support for iteratee shorthands
604
- * or max array length checks.
605
- *
606
- * @private
607
- * @param {number} n The number of times to invoke `iteratee`.
608
- * @param {Function} iteratee The function invoked per iteration.
609
- * @returns {Array} Returns the array of results.
610
- */
611
- function baseTimes(n, iteratee) {
612
- var index = -1,
613
- result = Array(n);
614
-
615
- while (++index < n) {
616
- result[index] = iteratee(index);
617
- }
618
- return result;
619
- }
620
-
621
- /**
622
- * Gets the value at `key` of `object`.
623
- *
624
- * @private
625
- * @param {Object} [object] The object to query.
626
- * @param {string} key The key of the property to get.
627
- * @returns {*} Returns the property value.
628
- */
629
- function getValue(object, key) {
630
- return object == null ? undefined : object[key];
631
- }
632
-
633
- /**
634
- * Checks if `value` is a host object in IE < 9.
635
- *
636
- * @private
637
- * @param {*} value The value to check.
638
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
639
- */
640
- function isHostObject(value) {
641
- // Many host objects are `Object` objects that can coerce to strings
642
- // despite having improperly defined `toString` methods.
643
- var result = false;
644
- if (value != null && typeof value.toString != 'function') {
645
- try {
646
- result = !!(value + '');
647
- } catch (e) {}
648
- }
649
- return result;
650
- }
651
-
652
- /**
653
- * Converts `map` to its key-value pairs.
654
- *
655
- * @private
656
- * @param {Object} map The map to convert.
657
- * @returns {Array} Returns the key-value pairs.
658
- */
659
- function mapToArray(map) {
660
- var index = -1,
661
- result = Array(map.size);
662
-
663
- map.forEach(function(value, key) {
664
- result[++index] = [key, value];
665
- });
666
- return result;
667
- }
668
-
669
- /**
670
- * Creates a unary function that invokes `func` with its argument transformed.
671
- *
672
- * @private
673
- * @param {Function} func The function to wrap.
674
- * @param {Function} transform The argument transform.
675
- * @returns {Function} Returns the new function.
676
- */
677
- function overArg(func, transform) {
678
- return function(arg) {
679
- return func(transform(arg));
680
- };
681
- }
682
-
683
- /**
684
- * Converts `set` to an array of its values.
685
- *
686
- * @private
687
- * @param {Object} set The set to convert.
688
- * @returns {Array} Returns the values.
689
- */
690
- function setToArray(set) {
691
- var index = -1,
692
- result = Array(set.size);
693
-
694
- set.forEach(function(value) {
695
- result[++index] = value;
696
- });
697
- return result;
698
- }
699
-
700
- /** Used for built-in method references. */
701
- var arrayProto = Array.prototype,
702
- funcProto = Function.prototype,
703
- objectProto = Object.prototype;
704
-
705
- /** Used to detect overreaching core-js shims. */
706
- var coreJsData = root['__core-js_shared__'];
707
-
708
- /** Used to detect methods masquerading as native. */
709
- var maskSrcKey = (function() {
710
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
711
- return uid ? ('Symbol(src)_1.' + uid) : '';
712
- }());
713
-
714
- /** Used to resolve the decompiled source of functions. */
715
- var funcToString = funcProto.toString;
716
-
717
- /** Used to check objects for own properties. */
718
- var hasOwnProperty = objectProto.hasOwnProperty;
719
-
720
- /**
721
- * Used to resolve the
722
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
723
- * of values.
724
- */
725
- var objectToString = objectProto.toString;
726
-
727
- /** Used to detect if a method is native. */
728
- var reIsNative = RegExp('^' +
729
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
730
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
731
- );
732
-
733
- /** Built-in value references. */
734
- var Buffer = moduleExports ? root.Buffer : undefined,
735
- Symbol = root.Symbol,
736
- Uint8Array = root.Uint8Array,
737
- getPrototype = overArg(Object.getPrototypeOf, Object),
738
- objectCreate = Object.create,
739
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
740
- splice = arrayProto.splice;
741
-
742
- /* Built-in method references for those with the same name as other `lodash` methods. */
743
- var nativeGetSymbols = Object.getOwnPropertySymbols,
744
- nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
745
- nativeKeys = overArg(Object.keys, Object);
746
-
747
- /* Built-in method references that are verified to be native. */
748
- var DataView = getNative(root, 'DataView'),
749
- Map = getNative(root, 'Map'),
750
- Promise = getNative(root, 'Promise'),
751
- Set = getNative(root, 'Set'),
752
- WeakMap = getNative(root, 'WeakMap'),
753
- nativeCreate = getNative(Object, 'create');
754
-
755
- /** Used to detect maps, sets, and weakmaps. */
756
- var dataViewCtorString = toSource(DataView),
757
- mapCtorString = toSource(Map),
758
- promiseCtorString = toSource(Promise),
759
- setCtorString = toSource(Set),
760
- weakMapCtorString = toSource(WeakMap);
761
-
762
- /** Used to convert symbols to primitives and strings. */
763
- var symbolProto = Symbol ? Symbol.prototype : undefined,
764
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
765
-
766
- /**
767
- * Creates a hash object.
768
- *
769
- * @private
770
- * @constructor
771
- * @param {Array} [entries] The key-value pairs to cache.
772
- */
773
- function Hash(entries) {
774
- var index = -1,
775
- length = entries ? entries.length : 0;
776
-
777
- this.clear();
778
- while (++index < length) {
779
- var entry = entries[index];
780
- this.set(entry[0], entry[1]);
781
- }
782
- }
783
-
784
- /**
785
- * Removes all key-value entries from the hash.
786
- *
787
- * @private
788
- * @name clear
789
- * @memberOf Hash
790
- */
791
- function hashClear() {
792
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
793
- }
794
-
795
- /**
796
- * Removes `key` and its value from the hash.
797
- *
798
- * @private
799
- * @name delete
800
- * @memberOf Hash
801
- * @param {Object} hash The hash to modify.
802
- * @param {string} key The key of the value to remove.
803
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
804
- */
805
- function hashDelete(key) {
806
- return this.has(key) && delete this.__data__[key];
807
- }
808
-
809
- /**
810
- * Gets the hash value for `key`.
811
- *
812
- * @private
813
- * @name get
814
- * @memberOf Hash
815
- * @param {string} key The key of the value to get.
816
- * @returns {*} Returns the entry value.
817
- */
818
- function hashGet(key) {
819
- var data = this.__data__;
820
- if (nativeCreate) {
821
- var result = data[key];
822
- return result === HASH_UNDEFINED ? undefined : result;
823
- }
824
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
825
- }
826
-
827
- /**
828
- * Checks if a hash value for `key` exists.
829
- *
830
- * @private
831
- * @name has
832
- * @memberOf Hash
833
- * @param {string} key The key of the entry to check.
834
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
835
- */
836
- function hashHas(key) {
837
- var data = this.__data__;
838
- return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
839
- }
840
-
841
- /**
842
- * Sets the hash `key` to `value`.
843
- *
844
- * @private
845
- * @name set
846
- * @memberOf Hash
847
- * @param {string} key The key of the value to set.
848
- * @param {*} value The value to set.
849
- * @returns {Object} Returns the hash instance.
850
- */
851
- function hashSet(key, value) {
852
- var data = this.__data__;
853
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
854
- return this;
855
- }
856
-
857
- // Add methods to `Hash`.
858
- Hash.prototype.clear = hashClear;
859
- Hash.prototype['delete'] = hashDelete;
860
- Hash.prototype.get = hashGet;
861
- Hash.prototype.has = hashHas;
862
- Hash.prototype.set = hashSet;
863
-
864
- /**
865
- * Creates an list cache object.
866
- *
867
- * @private
868
- * @constructor
869
- * @param {Array} [entries] The key-value pairs to cache.
870
- */
871
- function ListCache(entries) {
872
- var index = -1,
873
- length = entries ? entries.length : 0;
874
-
875
- this.clear();
876
- while (++index < length) {
877
- var entry = entries[index];
878
- this.set(entry[0], entry[1]);
879
- }
880
- }
881
-
882
- /**
883
- * Removes all key-value entries from the list cache.
884
- *
885
- * @private
886
- * @name clear
887
- * @memberOf ListCache
888
- */
889
- function listCacheClear() {
890
- this.__data__ = [];
891
- }
892
-
893
- /**
894
- * Removes `key` and its value from the list cache.
895
- *
896
- * @private
897
- * @name delete
898
- * @memberOf ListCache
899
- * @param {string} key The key of the value to remove.
900
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
901
- */
902
- function listCacheDelete(key) {
903
- var data = this.__data__,
904
- index = assocIndexOf(data, key);
905
-
906
- if (index < 0) {
907
- return false;
908
- }
909
- var lastIndex = data.length - 1;
910
- if (index == lastIndex) {
911
- data.pop();
912
- } else {
913
- splice.call(data, index, 1);
914
- }
915
- return true;
916
- }
917
-
918
- /**
919
- * Gets the list cache value for `key`.
920
- *
921
- * @private
922
- * @name get
923
- * @memberOf ListCache
924
- * @param {string} key The key of the value to get.
925
- * @returns {*} Returns the entry value.
926
- */
927
- function listCacheGet(key) {
928
- var data = this.__data__,
929
- index = assocIndexOf(data, key);
930
-
931
- return index < 0 ? undefined : data[index][1];
932
- }
933
-
934
- /**
935
- * Checks if a list cache value for `key` exists.
936
- *
937
- * @private
938
- * @name has
939
- * @memberOf ListCache
940
- * @param {string} key The key of the entry to check.
941
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
942
- */
943
- function listCacheHas(key) {
944
- return assocIndexOf(this.__data__, key) > -1;
945
- }
946
-
947
- /**
948
- * Sets the list cache `key` to `value`.
949
- *
950
- * @private
951
- * @name set
952
- * @memberOf ListCache
953
- * @param {string} key The key of the value to set.
954
- * @param {*} value The value to set.
955
- * @returns {Object} Returns the list cache instance.
956
- */
957
- function listCacheSet(key, value) {
958
- var data = this.__data__,
959
- index = assocIndexOf(data, key);
960
-
961
- if (index < 0) {
962
- data.push([key, value]);
963
- } else {
964
- data[index][1] = value;
965
- }
966
- return this;
967
- }
968
-
969
- // Add methods to `ListCache`.
970
- ListCache.prototype.clear = listCacheClear;
971
- ListCache.prototype['delete'] = listCacheDelete;
972
- ListCache.prototype.get = listCacheGet;
973
- ListCache.prototype.has = listCacheHas;
974
- ListCache.prototype.set = listCacheSet;
975
-
976
- /**
977
- * Creates a map cache object to store key-value pairs.
978
- *
979
- * @private
980
- * @constructor
981
- * @param {Array} [entries] The key-value pairs to cache.
982
- */
983
- function MapCache(entries) {
984
- var index = -1,
985
- length = entries ? entries.length : 0;
986
-
987
- this.clear();
988
- while (++index < length) {
989
- var entry = entries[index];
990
- this.set(entry[0], entry[1]);
991
- }
992
- }
993
-
994
- /**
995
- * Removes all key-value entries from the map.
996
- *
997
- * @private
998
- * @name clear
999
- * @memberOf MapCache
1000
- */
1001
- function mapCacheClear() {
1002
- this.__data__ = {
1003
- 'hash': new Hash,
1004
- 'map': new (Map || ListCache),
1005
- 'string': new Hash
1006
- };
1007
- }
1008
-
1009
- /**
1010
- * Removes `key` and its value from the map.
1011
- *
1012
- * @private
1013
- * @name delete
1014
- * @memberOf MapCache
1015
- * @param {string} key The key of the value to remove.
1016
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1017
- */
1018
- function mapCacheDelete(key) {
1019
- return getMapData(this, key)['delete'](key);
1020
- }
1021
-
1022
- /**
1023
- * Gets the map value for `key`.
1024
- *
1025
- * @private
1026
- * @name get
1027
- * @memberOf MapCache
1028
- * @param {string} key The key of the value to get.
1029
- * @returns {*} Returns the entry value.
1030
- */
1031
- function mapCacheGet(key) {
1032
- return getMapData(this, key).get(key);
1033
- }
1034
-
1035
- /**
1036
- * Checks if a map value for `key` exists.
1037
- *
1038
- * @private
1039
- * @name has
1040
- * @memberOf MapCache
1041
- * @param {string} key The key of the entry to check.
1042
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1043
- */
1044
- function mapCacheHas(key) {
1045
- return getMapData(this, key).has(key);
1046
- }
1047
-
1048
- /**
1049
- * Sets the map `key` to `value`.
1050
- *
1051
- * @private
1052
- * @name set
1053
- * @memberOf MapCache
1054
- * @param {string} key The key of the value to set.
1055
- * @param {*} value The value to set.
1056
- * @returns {Object} Returns the map cache instance.
1057
- */
1058
- function mapCacheSet(key, value) {
1059
- getMapData(this, key).set(key, value);
1060
- return this;
1061
- }
1062
-
1063
- // Add methods to `MapCache`.
1064
- MapCache.prototype.clear = mapCacheClear;
1065
- MapCache.prototype['delete'] = mapCacheDelete;
1066
- MapCache.prototype.get = mapCacheGet;
1067
- MapCache.prototype.has = mapCacheHas;
1068
- MapCache.prototype.set = mapCacheSet;
1069
-
1070
- /**
1071
- * Creates a stack cache object to store key-value pairs.
1072
- *
1073
- * @private
1074
- * @constructor
1075
- * @param {Array} [entries] The key-value pairs to cache.
1076
- */
1077
- function Stack(entries) {
1078
- this.__data__ = new ListCache(entries);
1079
- }
1080
-
1081
- /**
1082
- * Removes all key-value entries from the stack.
1083
- *
1084
- * @private
1085
- * @name clear
1086
- * @memberOf Stack
1087
- */
1088
- function stackClear() {
1089
- this.__data__ = new ListCache;
1090
- }
1091
-
1092
- /**
1093
- * Removes `key` and its value from the stack.
1094
- *
1095
- * @private
1096
- * @name delete
1097
- * @memberOf Stack
1098
- * @param {string} key The key of the value to remove.
1099
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1100
- */
1101
- function stackDelete(key) {
1102
- return this.__data__['delete'](key);
1103
- }
1104
-
1105
- /**
1106
- * Gets the stack value for `key`.
1107
- *
1108
- * @private
1109
- * @name get
1110
- * @memberOf Stack
1111
- * @param {string} key The key of the value to get.
1112
- * @returns {*} Returns the entry value.
1113
- */
1114
- function stackGet(key) {
1115
- return this.__data__.get(key);
1116
- }
1117
-
1118
- /**
1119
- * Checks if a stack value for `key` exists.
1120
- *
1121
- * @private
1122
- * @name has
1123
- * @memberOf Stack
1124
- * @param {string} key The key of the entry to check.
1125
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1126
- */
1127
- function stackHas(key) {
1128
- return this.__data__.has(key);
1129
- }
1130
-
1131
- /**
1132
- * Sets the stack `key` to `value`.
1133
- *
1134
- * @private
1135
- * @name set
1136
- * @memberOf Stack
1137
- * @param {string} key The key of the value to set.
1138
- * @param {*} value The value to set.
1139
- * @returns {Object} Returns the stack cache instance.
1140
- */
1141
- function stackSet(key, value) {
1142
- var cache = this.__data__;
1143
- if (cache instanceof ListCache) {
1144
- var pairs = cache.__data__;
1145
- if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
1146
- pairs.push([key, value]);
1147
- return this;
1148
- }
1149
- cache = this.__data__ = new MapCache(pairs);
1150
- }
1151
- cache.set(key, value);
1152
- return this;
1153
- }
1154
-
1155
- // Add methods to `Stack`.
1156
- Stack.prototype.clear = stackClear;
1157
- Stack.prototype['delete'] = stackDelete;
1158
- Stack.prototype.get = stackGet;
1159
- Stack.prototype.has = stackHas;
1160
- Stack.prototype.set = stackSet;
1161
-
1162
- /**
1163
- * Creates an array of the enumerable property names of the array-like `value`.
1164
- *
1165
- * @private
1166
- * @param {*} value The value to query.
1167
- * @param {boolean} inherited Specify returning inherited property names.
1168
- * @returns {Array} Returns the array of property names.
1169
- */
1170
- function arrayLikeKeys(value, inherited) {
1171
- // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1172
- // Safari 9 makes `arguments.length` enumerable in strict mode.
1173
- var result = (isArray(value) || isArguments(value))
1174
- ? baseTimes(value.length, String)
1175
- : [];
1176
-
1177
- var length = result.length,
1178
- skipIndexes = !!length;
1179
-
1180
- for (var key in value) {
1181
- if ((inherited || hasOwnProperty.call(value, key)) &&
1182
- !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
1183
- result.push(key);
1184
- }
1185
- }
1186
- return result;
1187
- }
1188
-
1189
- /**
1190
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
1191
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1192
- * for equality comparisons.
1193
- *
1194
- * @private
1195
- * @param {Object} object The object to modify.
1196
- * @param {string} key The key of the property to assign.
1197
- * @param {*} value The value to assign.
1198
- */
1199
- function assignValue(object, key, value) {
1200
- var objValue = object[key];
1201
- if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
1202
- (value === undefined && !(key in object))) {
1203
- object[key] = value;
1204
- }
1205
- }
1206
-
1207
- /**
1208
- * Gets the index at which the `key` is found in `array` of key-value pairs.
1209
- *
1210
- * @private
1211
- * @param {Array} array The array to inspect.
1212
- * @param {*} key The key to search for.
1213
- * @returns {number} Returns the index of the matched value, else `-1`.
1214
- */
1215
- function assocIndexOf(array, key) {
1216
- var length = array.length;
1217
- while (length--) {
1218
- if (eq(array[length][0], key)) {
1219
- return length;
1220
- }
1221
- }
1222
- return -1;
1223
- }
1224
-
1225
- /**
1226
- * The base implementation of `_.assign` without support for multiple sources
1227
- * or `customizer` functions.
1228
- *
1229
- * @private
1230
- * @param {Object} object The destination object.
1231
- * @param {Object} source The source object.
1232
- * @returns {Object} Returns `object`.
1233
- */
1234
- function baseAssign(object, source) {
1235
- return object && copyObject(source, keys(source), object);
1236
- }
1237
-
1238
- /**
1239
- * The base implementation of `_.clone` and `_.cloneDeep` which tracks
1240
- * traversed objects.
1241
- *
1242
- * @private
1243
- * @param {*} value The value to clone.
1244
- * @param {boolean} [isDeep] Specify a deep clone.
1245
- * @param {boolean} [isFull] Specify a clone including symbols.
1246
- * @param {Function} [customizer] The function to customize cloning.
1247
- * @param {string} [key] The key of `value`.
1248
- * @param {Object} [object] The parent object of `value`.
1249
- * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
1250
- * @returns {*} Returns the cloned value.
1251
- */
1252
- function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
1253
- var result;
1254
- if (customizer) {
1255
- result = object ? customizer(value, key, object, stack) : customizer(value);
1256
- }
1257
- if (result !== undefined) {
1258
- return result;
1259
- }
1260
- if (!isObject(value)) {
1261
- return value;
1262
- }
1263
- var isArr = isArray(value);
1264
- if (isArr) {
1265
- result = initCloneArray(value);
1266
- if (!isDeep) {
1267
- return copyArray(value, result);
1268
- }
1269
- } else {
1270
- var tag = getTag(value),
1271
- isFunc = tag == funcTag || tag == genTag;
1272
-
1273
- if (isBuffer(value)) {
1274
- return cloneBuffer(value, isDeep);
1275
- }
1276
- if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
1277
- if (isHostObject(value)) {
1278
- return object ? value : {};
1279
- }
1280
- result = initCloneObject(isFunc ? {} : value);
1281
- if (!isDeep) {
1282
- return copySymbols(value, baseAssign(result, value));
1283
- }
1284
- } else {
1285
- if (!cloneableTags[tag]) {
1286
- return object ? value : {};
1287
- }
1288
- result = initCloneByTag(value, tag, baseClone, isDeep);
1289
- }
1290
- }
1291
- // Check for circular references and return its corresponding clone.
1292
- stack || (stack = new Stack);
1293
- var stacked = stack.get(value);
1294
- if (stacked) {
1295
- return stacked;
1296
- }
1297
- stack.set(value, result);
1298
-
1299
- if (!isArr) {
1300
- var props = isFull ? getAllKeys(value) : keys(value);
1301
- }
1302
- arrayEach(props || value, function(subValue, key) {
1303
- if (props) {
1304
- key = subValue;
1305
- subValue = value[key];
1306
- }
1307
- // Recursively populate clone (susceptible to call stack limits).
1308
- assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
1309
- });
1310
- return result;
1311
- }
1312
-
1313
- /**
1314
- * The base implementation of `_.create` without support for assigning
1315
- * properties to the created object.
1316
- *
1317
- * @private
1318
- * @param {Object} prototype The object to inherit from.
1319
- * @returns {Object} Returns the new object.
1320
- */
1321
- function baseCreate(proto) {
1322
- return isObject(proto) ? objectCreate(proto) : {};
1323
- }
1324
-
1325
- /**
1326
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
1327
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
1328
- * symbols of `object`.
1329
- *
1330
- * @private
1331
- * @param {Object} object The object to query.
1332
- * @param {Function} keysFunc The function to get the keys of `object`.
1333
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
1334
- * @returns {Array} Returns the array of property names and symbols.
1335
- */
1336
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1337
- var result = keysFunc(object);
1338
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
1339
- }
1340
-
1341
- /**
1342
- * The base implementation of `getTag`.
1343
- *
1344
- * @private
1345
- * @param {*} value The value to query.
1346
- * @returns {string} Returns the `toStringTag`.
1347
- */
1348
- function baseGetTag(value) {
1349
- return objectToString.call(value);
1350
- }
1351
-
1352
- /**
1353
- * The base implementation of `_.isNative` without bad shim checks.
1354
- *
1355
- * @private
1356
- * @param {*} value The value to check.
1357
- * @returns {boolean} Returns `true` if `value` is a native function,
1358
- * else `false`.
1359
- */
1360
- function baseIsNative(value) {
1361
- if (!isObject(value) || isMasked(value)) {
1362
- return false;
1363
- }
1364
- var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
1365
- return pattern.test(toSource(value));
1366
- }
1367
-
1368
- /**
1369
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1370
- *
1371
- * @private
1372
- * @param {Object} object The object to query.
1373
- * @returns {Array} Returns the array of property names.
1374
- */
1375
- function baseKeys(object) {
1376
- if (!isPrototype(object)) {
1377
- return nativeKeys(object);
1378
- }
1379
- var result = [];
1380
- for (var key in Object(object)) {
1381
- if (hasOwnProperty.call(object, key) && key != 'constructor') {
1382
- result.push(key);
1383
- }
1384
- }
1385
- return result;
1386
- }
1387
-
1388
- /**
1389
- * Creates a clone of `buffer`.
1390
- *
1391
- * @private
1392
- * @param {Buffer} buffer The buffer to clone.
1393
- * @param {boolean} [isDeep] Specify a deep clone.
1394
- * @returns {Buffer} Returns the cloned buffer.
1395
- */
1396
- function cloneBuffer(buffer, isDeep) {
1397
- if (isDeep) {
1398
- return buffer.slice();
1399
- }
1400
- var result = new buffer.constructor(buffer.length);
1401
- buffer.copy(result);
1402
- return result;
1403
- }
1404
-
1405
- /**
1406
- * Creates a clone of `arrayBuffer`.
1407
- *
1408
- * @private
1409
- * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
1410
- * @returns {ArrayBuffer} Returns the cloned array buffer.
1411
- */
1412
- function cloneArrayBuffer(arrayBuffer) {
1413
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1414
- new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1415
- return result;
1416
- }
1417
-
1418
- /**
1419
- * Creates a clone of `dataView`.
1420
- *
1421
- * @private
1422
- * @param {Object} dataView The data view to clone.
1423
- * @param {boolean} [isDeep] Specify a deep clone.
1424
- * @returns {Object} Returns the cloned data view.
1425
- */
1426
- function cloneDataView(dataView, isDeep) {
1427
- var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
1428
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
1429
- }
1430
-
1431
- /**
1432
- * Creates a clone of `map`.
1433
- *
1434
- * @private
1435
- * @param {Object} map The map to clone.
1436
- * @param {Function} cloneFunc The function to clone values.
1437
- * @param {boolean} [isDeep] Specify a deep clone.
1438
- * @returns {Object} Returns the cloned map.
1439
- */
1440
- function cloneMap(map, isDeep, cloneFunc) {
1441
- var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
1442
- return arrayReduce(array, addMapEntry, new map.constructor);
1443
- }
1444
-
1445
- /**
1446
- * Creates a clone of `regexp`.
1447
- *
1448
- * @private
1449
- * @param {Object} regexp The regexp to clone.
1450
- * @returns {Object} Returns the cloned regexp.
1451
- */
1452
- function cloneRegExp(regexp) {
1453
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
1454
- result.lastIndex = regexp.lastIndex;
1455
- return result;
1456
- }
1457
-
1458
- /**
1459
- * Creates a clone of `set`.
1460
- *
1461
- * @private
1462
- * @param {Object} set The set to clone.
1463
- * @param {Function} cloneFunc The function to clone values.
1464
- * @param {boolean} [isDeep] Specify a deep clone.
1465
- * @returns {Object} Returns the cloned set.
1466
- */
1467
- function cloneSet(set, isDeep, cloneFunc) {
1468
- var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
1469
- return arrayReduce(array, addSetEntry, new set.constructor);
1470
- }
1471
-
1472
- /**
1473
- * Creates a clone of the `symbol` object.
1474
- *
1475
- * @private
1476
- * @param {Object} symbol The symbol object to clone.
1477
- * @returns {Object} Returns the cloned symbol object.
1478
- */
1479
- function cloneSymbol(symbol) {
1480
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
1481
- }
1482
-
1483
- /**
1484
- * Creates a clone of `typedArray`.
1485
- *
1486
- * @private
1487
- * @param {Object} typedArray The typed array to clone.
1488
- * @param {boolean} [isDeep] Specify a deep clone.
1489
- * @returns {Object} Returns the cloned typed array.
1490
- */
1491
- function cloneTypedArray(typedArray, isDeep) {
1492
- var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1493
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1494
- }
1495
-
1496
- /**
1497
- * Copies the values of `source` to `array`.
1498
- *
1499
- * @private
1500
- * @param {Array} source The array to copy values from.
1501
- * @param {Array} [array=[]] The array to copy values to.
1502
- * @returns {Array} Returns `array`.
1503
- */
1504
- function copyArray(source, array) {
1505
- var index = -1,
1506
- length = source.length;
1507
-
1508
- array || (array = Array(length));
1509
- while (++index < length) {
1510
- array[index] = source[index];
1511
- }
1512
- return array;
1513
- }
1514
-
1515
- /**
1516
- * Copies properties of `source` to `object`.
1517
- *
1518
- * @private
1519
- * @param {Object} source The object to copy properties from.
1520
- * @param {Array} props The property identifiers to copy.
1521
- * @param {Object} [object={}] The object to copy properties to.
1522
- * @param {Function} [customizer] The function to customize copied values.
1523
- * @returns {Object} Returns `object`.
1524
- */
1525
- function copyObject(source, props, object, customizer) {
1526
- object || (object = {});
1527
-
1528
- var index = -1,
1529
- length = props.length;
1530
-
1531
- while (++index < length) {
1532
- var key = props[index];
1533
-
1534
- var newValue = customizer
1535
- ? customizer(object[key], source[key], key, object, source)
1536
- : undefined;
1537
-
1538
- assignValue(object, key, newValue === undefined ? source[key] : newValue);
1539
- }
1540
- return object;
1541
- }
1542
-
1543
- /**
1544
- * Copies own symbol properties of `source` to `object`.
1545
- *
1546
- * @private
1547
- * @param {Object} source The object to copy symbols from.
1548
- * @param {Object} [object={}] The object to copy symbols to.
1549
- * @returns {Object} Returns `object`.
1550
- */
1551
- function copySymbols(source, object) {
1552
- return copyObject(source, getSymbols(source), object);
1553
- }
1554
-
1555
- /**
1556
- * Creates an array of own enumerable property names and symbols of `object`.
1557
- *
1558
- * @private
1559
- * @param {Object} object The object to query.
1560
- * @returns {Array} Returns the array of property names and symbols.
1561
- */
1562
- function getAllKeys(object) {
1563
- return baseGetAllKeys(object, keys, getSymbols);
1564
- }
1565
-
1566
- /**
1567
- * Gets the data for `map`.
1568
- *
1569
- * @private
1570
- * @param {Object} map The map to query.
1571
- * @param {string} key The reference key.
1572
- * @returns {*} Returns the map data.
1573
- */
1574
- function getMapData(map, key) {
1575
- var data = map.__data__;
1576
- return isKeyable(key)
1577
- ? data[typeof key == 'string' ? 'string' : 'hash']
1578
- : data.map;
1579
- }
1580
-
1581
- /**
1582
- * Gets the native function at `key` of `object`.
1583
- *
1584
- * @private
1585
- * @param {Object} object The object to query.
1586
- * @param {string} key The key of the method to get.
1587
- * @returns {*} Returns the function if it's native, else `undefined`.
1588
- */
1589
- function getNative(object, key) {
1590
- var value = getValue(object, key);
1591
- return baseIsNative(value) ? value : undefined;
1592
- }
1593
-
1594
- /**
1595
- * Creates an array of the own enumerable symbol properties of `object`.
1596
- *
1597
- * @private
1598
- * @param {Object} object The object to query.
1599
- * @returns {Array} Returns the array of symbols.
1600
- */
1601
- var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
1602
-
1603
- /**
1604
- * Gets the `toStringTag` of `value`.
1605
- *
1606
- * @private
1607
- * @param {*} value The value to query.
1608
- * @returns {string} Returns the `toStringTag`.
1609
- */
1610
- var getTag = baseGetTag;
1611
-
1612
- // Fallback for data views, maps, sets, and weak maps in IE 11,
1613
- // for data views in Edge < 14, and promises in Node.js.
1614
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1615
- (Map && getTag(new Map) != mapTag) ||
1616
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
1617
- (Set && getTag(new Set) != setTag) ||
1618
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1619
- getTag = function(value) {
1620
- var result = objectToString.call(value),
1621
- Ctor = result == objectTag ? value.constructor : undefined,
1622
- ctorString = Ctor ? toSource(Ctor) : undefined;
1623
-
1624
- if (ctorString) {
1625
- switch (ctorString) {
1626
- case dataViewCtorString: return dataViewTag;
1627
- case mapCtorString: return mapTag;
1628
- case promiseCtorString: return promiseTag;
1629
- case setCtorString: return setTag;
1630
- case weakMapCtorString: return weakMapTag;
1631
- }
1632
- }
1633
- return result;
1634
- };
1635
- }
1636
-
1637
- /**
1638
- * Initializes an array clone.
1639
- *
1640
- * @private
1641
- * @param {Array} array The array to clone.
1642
- * @returns {Array} Returns the initialized clone.
1643
- */
1644
- function initCloneArray(array) {
1645
- var length = array.length,
1646
- result = array.constructor(length);
1647
-
1648
- // Add properties assigned by `RegExp#exec`.
1649
- if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
1650
- result.index = array.index;
1651
- result.input = array.input;
1652
- }
1653
- return result;
1654
- }
1655
-
1656
- /**
1657
- * Initializes an object clone.
1658
- *
1659
- * @private
1660
- * @param {Object} object The object to clone.
1661
- * @returns {Object} Returns the initialized clone.
1662
- */
1663
- function initCloneObject(object) {
1664
- return (typeof object.constructor == 'function' && !isPrototype(object))
1665
- ? baseCreate(getPrototype(object))
1666
- : {};
1667
- }
1668
-
1669
- /**
1670
- * Initializes an object clone based on its `toStringTag`.
1671
- *
1672
- * **Note:** This function only supports cloning values with tags of
1673
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1674
- *
1675
- * @private
1676
- * @param {Object} object The object to clone.
1677
- * @param {string} tag The `toStringTag` of the object to clone.
1678
- * @param {Function} cloneFunc The function to clone values.
1679
- * @param {boolean} [isDeep] Specify a deep clone.
1680
- * @returns {Object} Returns the initialized clone.
1681
- */
1682
- function initCloneByTag(object, tag, cloneFunc, isDeep) {
1683
- var Ctor = object.constructor;
1684
- switch (tag) {
1685
- case arrayBufferTag:
1686
- return cloneArrayBuffer(object);
1687
-
1688
- case boolTag:
1689
- case dateTag:
1690
- return new Ctor(+object);
1691
-
1692
- case dataViewTag:
1693
- return cloneDataView(object, isDeep);
1694
-
1695
- case float32Tag: case float64Tag:
1696
- case int8Tag: case int16Tag: case int32Tag:
1697
- case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
1698
- return cloneTypedArray(object, isDeep);
1699
-
1700
- case mapTag:
1701
- return cloneMap(object, isDeep, cloneFunc);
1702
-
1703
- case numberTag:
1704
- case stringTag:
1705
- return new Ctor(object);
1706
-
1707
- case regexpTag:
1708
- return cloneRegExp(object);
1709
-
1710
- case setTag:
1711
- return cloneSet(object, isDeep, cloneFunc);
1712
-
1713
- case symbolTag:
1714
- return cloneSymbol(object);
1715
- }
1716
- }
1717
-
1718
- /**
1719
- * Checks if `value` is a valid array-like index.
1720
- *
1721
- * @private
1722
- * @param {*} value The value to check.
1723
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1724
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1725
- */
1726
- function isIndex(value, length) {
1727
- length = length == null ? MAX_SAFE_INTEGER : length;
1728
- return !!length &&
1729
- (typeof value == 'number' || reIsUint.test(value)) &&
1730
- (value > -1 && value % 1 == 0 && value < length);
1731
- }
1732
-
1733
- /**
1734
- * Checks if `value` is suitable for use as unique object key.
1735
- *
1736
- * @private
1737
- * @param {*} value The value to check.
1738
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1739
- */
1740
- function isKeyable(value) {
1741
- var type = typeof value;
1742
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1743
- ? (value !== '__proto__')
1744
- : (value === null);
1745
- }
1746
-
1747
- /**
1748
- * Checks if `func` has its source masked.
1749
- *
1750
- * @private
1751
- * @param {Function} func The function to check.
1752
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1753
- */
1754
- function isMasked(func) {
1755
- return !!maskSrcKey && (maskSrcKey in func);
1756
- }
1757
-
1758
- /**
1759
- * Checks if `value` is likely a prototype object.
1760
- *
1761
- * @private
1762
- * @param {*} value The value to check.
1763
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1764
- */
1765
- function isPrototype(value) {
1766
- var Ctor = value && value.constructor,
1767
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1768
-
1769
- return value === proto;
1770
- }
1771
-
1772
- /**
1773
- * Converts `func` to its source code.
1774
- *
1775
- * @private
1776
- * @param {Function} func The function to process.
1777
- * @returns {string} Returns the source code.
1778
- */
1779
- function toSource(func) {
1780
- if (func != null) {
1781
- try {
1782
- return funcToString.call(func);
1783
- } catch (e) {}
1784
- try {
1785
- return (func + '');
1786
- } catch (e) {}
1787
- }
1788
- return '';
1789
- }
1790
-
1791
- /**
1792
- * This method is like `_.clone` except that it recursively clones `value`.
1793
- *
1794
- * @static
1795
- * @memberOf _
1796
- * @since 1.0.0
1797
- * @category Lang
1798
- * @param {*} value The value to recursively clone.
1799
- * @returns {*} Returns the deep cloned value.
1800
- * @see _.clone
1801
- * @example
1802
- *
1803
- * var objects = [{ 'a': 1 }, { 'b': 2 }];
1804
- *
1805
- * var deep = _.cloneDeep(objects);
1806
- * console.log(deep[0] === objects[0]);
1807
- * // => false
1808
- */
1809
- function cloneDeep(value) {
1810
- return baseClone(value, true, true);
1811
- }
1812
-
1813
- /**
1814
- * Performs a
1815
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1816
- * comparison between two values to determine if they are equivalent.
1817
- *
1818
- * @static
1819
- * @memberOf _
1820
- * @since 4.0.0
1821
- * @category Lang
1822
- * @param {*} value The value to compare.
1823
- * @param {*} other The other value to compare.
1824
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1825
- * @example
1826
- *
1827
- * var object = { 'a': 1 };
1828
- * var other = { 'a': 1 };
1829
- *
1830
- * _.eq(object, object);
1831
- * // => true
1832
- *
1833
- * _.eq(object, other);
1834
- * // => false
1835
- *
1836
- * _.eq('a', 'a');
1837
- * // => true
1838
- *
1839
- * _.eq('a', Object('a'));
1840
- * // => false
1841
- *
1842
- * _.eq(NaN, NaN);
1843
- * // => true
1844
- */
1845
- function eq(value, other) {
1846
- return value === other || (value !== value && other !== other);
1847
- }
1848
-
1849
- /**
1850
- * Checks if `value` is likely an `arguments` object.
1851
- *
1852
- * @static
1853
- * @memberOf _
1854
- * @since 0.1.0
1855
- * @category Lang
1856
- * @param {*} value The value to check.
1857
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1858
- * else `false`.
1859
- * @example
1860
- *
1861
- * _.isArguments(function() { return arguments; }());
1862
- * // => true
1863
- *
1864
- * _.isArguments([1, 2, 3]);
1865
- * // => false
1866
- */
1867
- function isArguments(value) {
1868
- // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1869
- return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
1870
- (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
1871
- }
1872
-
1873
- /**
1874
- * Checks if `value` is classified as an `Array` object.
1875
- *
1876
- * @static
1877
- * @memberOf _
1878
- * @since 0.1.0
1879
- * @category Lang
1880
- * @param {*} value The value to check.
1881
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1882
- * @example
1883
- *
1884
- * _.isArray([1, 2, 3]);
1885
- * // => true
1886
- *
1887
- * _.isArray(document.body.children);
1888
- * // => false
1889
- *
1890
- * _.isArray('abc');
1891
- * // => false
1892
- *
1893
- * _.isArray(_.noop);
1894
- * // => false
1895
- */
1896
- var isArray = Array.isArray;
1897
-
1898
- /**
1899
- * Checks if `value` is array-like. A value is considered array-like if it's
1900
- * not a function and has a `value.length` that's an integer greater than or
1901
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1902
- *
1903
- * @static
1904
- * @memberOf _
1905
- * @since 4.0.0
1906
- * @category Lang
1907
- * @param {*} value The value to check.
1908
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1909
- * @example
1910
- *
1911
- * _.isArrayLike([1, 2, 3]);
1912
- * // => true
1913
- *
1914
- * _.isArrayLike(document.body.children);
1915
- * // => true
1916
- *
1917
- * _.isArrayLike('abc');
1918
- * // => true
1919
- *
1920
- * _.isArrayLike(_.noop);
1921
- * // => false
1922
- */
1923
- function isArrayLike(value) {
1924
- return value != null && isLength(value.length) && !isFunction(value);
1925
- }
1926
-
1927
- /**
1928
- * This method is like `_.isArrayLike` except that it also checks if `value`
1929
- * is an object.
1930
- *
1931
- * @static
1932
- * @memberOf _
1933
- * @since 4.0.0
1934
- * @category Lang
1935
- * @param {*} value The value to check.
1936
- * @returns {boolean} Returns `true` if `value` is an array-like object,
1937
- * else `false`.
1938
- * @example
1939
- *
1940
- * _.isArrayLikeObject([1, 2, 3]);
1941
- * // => true
1942
- *
1943
- * _.isArrayLikeObject(document.body.children);
1944
- * // => true
1945
- *
1946
- * _.isArrayLikeObject('abc');
1947
- * // => false
1948
- *
1949
- * _.isArrayLikeObject(_.noop);
1950
- * // => false
1951
- */
1952
- function isArrayLikeObject(value) {
1953
- return isObjectLike(value) && isArrayLike(value);
1954
- }
1955
-
1956
- /**
1957
- * Checks if `value` is a buffer.
1958
- *
1959
- * @static
1960
- * @memberOf _
1961
- * @since 4.3.0
1962
- * @category Lang
1963
- * @param {*} value The value to check.
1964
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1965
- * @example
1966
- *
1967
- * _.isBuffer(new Buffer(2));
1968
- * // => true
1969
- *
1970
- * _.isBuffer(new Uint8Array(2));
1971
- * // => false
1972
- */
1973
- var isBuffer = nativeIsBuffer || stubFalse;
1974
-
1975
- /**
1976
- * Checks if `value` is classified as a `Function` object.
1977
- *
1978
- * @static
1979
- * @memberOf _
1980
- * @since 0.1.0
1981
- * @category Lang
1982
- * @param {*} value The value to check.
1983
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1984
- * @example
1985
- *
1986
- * _.isFunction(_);
1987
- * // => true
1988
- *
1989
- * _.isFunction(/abc/);
1990
- * // => false
1991
- */
1992
- function isFunction(value) {
1993
- // The use of `Object#toString` avoids issues with the `typeof` operator
1994
- // in Safari 8-9 which returns 'object' for typed array and other constructors.
1995
- var tag = isObject(value) ? objectToString.call(value) : '';
1996
- return tag == funcTag || tag == genTag;
1997
- }
1998
-
1999
- /**
2000
- * Checks if `value` is a valid array-like length.
2001
- *
2002
- * **Note:** This method is loosely based on
2003
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2004
- *
2005
- * @static
2006
- * @memberOf _
2007
- * @since 4.0.0
2008
- * @category Lang
2009
- * @param {*} value The value to check.
2010
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2011
- * @example
2012
- *
2013
- * _.isLength(3);
2014
- * // => true
2015
- *
2016
- * _.isLength(Number.MIN_VALUE);
2017
- * // => false
2018
- *
2019
- * _.isLength(Infinity);
2020
- * // => false
2021
- *
2022
- * _.isLength('3');
2023
- * // => false
2024
- */
2025
- function isLength(value) {
2026
- return typeof value == 'number' &&
2027
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2028
- }
2029
-
2030
- /**
2031
- * Checks if `value` is the
2032
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2033
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2034
- *
2035
- * @static
2036
- * @memberOf _
2037
- * @since 0.1.0
2038
- * @category Lang
2039
- * @param {*} value The value to check.
2040
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2041
- * @example
2042
- *
2043
- * _.isObject({});
2044
- * // => true
2045
- *
2046
- * _.isObject([1, 2, 3]);
2047
- * // => true
2048
- *
2049
- * _.isObject(_.noop);
2050
- * // => true
2051
- *
2052
- * _.isObject(null);
2053
- * // => false
2054
- */
2055
- function isObject(value) {
2056
- var type = typeof value;
2057
- return !!value && (type == 'object' || type == 'function');
2058
- }
2059
-
2060
- /**
2061
- * Checks if `value` is object-like. A value is object-like if it's not `null`
2062
- * and has a `typeof` result of "object".
2063
- *
2064
- * @static
2065
- * @memberOf _
2066
- * @since 4.0.0
2067
- * @category Lang
2068
- * @param {*} value The value to check.
2069
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2070
- * @example
2071
- *
2072
- * _.isObjectLike({});
2073
- * // => true
2074
- *
2075
- * _.isObjectLike([1, 2, 3]);
2076
- * // => true
2077
- *
2078
- * _.isObjectLike(_.noop);
2079
- * // => false
2080
- *
2081
- * _.isObjectLike(null);
2082
- * // => false
2083
- */
2084
- function isObjectLike(value) {
2085
- return !!value && typeof value == 'object';
2086
- }
2087
-
2088
- /**
2089
- * Creates an array of the own enumerable property names of `object`.
2090
- *
2091
- * **Note:** Non-object values are coerced to objects. See the
2092
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2093
- * for more details.
2094
- *
2095
- * @static
2096
- * @since 0.1.0
2097
- * @memberOf _
2098
- * @category Object
2099
- * @param {Object} object The object to query.
2100
- * @returns {Array} Returns the array of property names.
2101
- * @example
2102
- *
2103
- * function Foo() {
2104
- * this.a = 1;
2105
- * this.b = 2;
2106
- * }
2107
- *
2108
- * Foo.prototype.c = 3;
2109
- *
2110
- * _.keys(new Foo);
2111
- * // => ['a', 'b'] (iteration order is not guaranteed)
2112
- *
2113
- * _.keys('hi');
2114
- * // => ['0', '1']
2115
- */
2116
- function keys(object) {
2117
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
2118
- }
2119
-
2120
- /**
2121
- * This method returns a new empty array.
2122
- *
2123
- * @static
2124
- * @memberOf _
2125
- * @since 4.13.0
2126
- * @category Util
2127
- * @returns {Array} Returns the new empty array.
2128
- * @example
2129
- *
2130
- * var arrays = _.times(2, _.stubArray);
2131
- *
2132
- * console.log(arrays);
2133
- * // => [[], []]
2134
- *
2135
- * console.log(arrays[0] === arrays[1]);
2136
- * // => false
2137
- */
2138
- function stubArray() {
2139
- return [];
2140
- }
2141
-
2142
- /**
2143
- * This method returns `false`.
2144
- *
2145
- * @static
2146
- * @memberOf _
2147
- * @since 4.13.0
2148
- * @category Util
2149
- * @returns {boolean} Returns `false`.
2150
- * @example
2151
- *
2152
- * _.times(2, _.stubFalse);
2153
- * // => [false, false]
2154
- */
2155
- function stubFalse() {
2156
- return false;
2157
- }
2158
-
2159
- module.exports = cloneDeep;
2160
- });
2161
-
2162
- /**
2163
- * lodash (Custom Build) <https://lodash.com/>
2164
- * Build: `lodash modularize exports="npm" -o ./`
2165
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
2166
- * Released under MIT license <https://lodash.com/license>
2167
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
2168
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2169
- */
2170
- /** `Object#toString` result references. */
2171
- var objectTag = '[object Object]';
2172
-
2173
- /**
2174
- * Checks if `value` is a host object in IE < 9.
2175
- *
2176
- * @private
2177
- * @param {*} value The value to check.
2178
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
2179
- */
2180
- function isHostObject(value) {
2181
- // Many host objects are `Object` objects that can coerce to strings
2182
- // despite having improperly defined `toString` methods.
2183
- var result = false;
2184
- if (value != null && typeof value.toString != 'function') {
2185
- try {
2186
- result = !!(value + '');
2187
- } catch (e) {}
2188
- }
2189
- return result;
2190
- }
2191
-
2192
- /**
2193
- * Creates a unary function that invokes `func` with its argument transformed.
2194
- *
2195
- * @private
2196
- * @param {Function} func The function to wrap.
2197
- * @param {Function} transform The argument transform.
2198
- * @returns {Function} Returns the new function.
2199
- */
2200
- function overArg(func, transform) {
2201
- return function(arg) {
2202
- return func(transform(arg));
2203
- };
2204
- }
2205
-
2206
- /** Used for built-in method references. */
2207
- var funcProto = Function.prototype,
2208
- objectProto = Object.prototype;
2209
-
2210
- /** Used to resolve the decompiled source of functions. */
2211
- var funcToString = funcProto.toString;
2212
-
2213
- /** Used to check objects for own properties. */
2214
- var hasOwnProperty = objectProto.hasOwnProperty;
2215
-
2216
- /** Used to infer the `Object` constructor. */
2217
- var objectCtorString = funcToString.call(Object);
2218
-
2219
- /**
2220
- * Used to resolve the
2221
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2222
- * of values.
2223
- */
2224
- var objectToString = objectProto.toString;
2225
-
2226
- /** Built-in value references. */
2227
- var getPrototype = overArg(Object.getPrototypeOf, Object);
2228
-
2229
- /**
2230
- * Checks if `value` is object-like. A value is object-like if it's not `null`
2231
- * and has a `typeof` result of "object".
2232
- *
2233
- * @static
2234
- * @memberOf _
2235
- * @since 4.0.0
2236
- * @category Lang
2237
- * @param {*} value The value to check.
2238
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2239
- * @example
2240
- *
2241
- * _.isObjectLike({});
2242
- * // => true
2243
- *
2244
- * _.isObjectLike([1, 2, 3]);
2245
- * // => true
2246
- *
2247
- * _.isObjectLike(_.noop);
2248
- * // => false
2249
- *
2250
- * _.isObjectLike(null);
2251
- * // => false
2252
- */
2253
- function isObjectLike(value) {
2254
- return !!value && typeof value == 'object';
2255
- }
2256
-
2257
- /**
2258
- * Checks if `value` is a plain object, that is, an object created by the
2259
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
2260
- *
2261
- * @static
2262
- * @memberOf _
2263
- * @since 0.8.0
2264
- * @category Lang
2265
- * @param {*} value The value to check.
2266
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
2267
- * @example
2268
- *
2269
- * function Foo() {
2270
- * this.a = 1;
2271
- * }
2272
- *
2273
- * _.isPlainObject(new Foo);
2274
- * // => false
2275
- *
2276
- * _.isPlainObject([1, 2, 3]);
2277
- * // => false
2278
- *
2279
- * _.isPlainObject({ 'x': 0, 'y': 0 });
2280
- * // => true
2281
- *
2282
- * _.isPlainObject(Object.create(null));
2283
- * // => true
2284
- */
2285
- function isPlainObject(value) {
2286
- if (!isObjectLike(value) ||
2287
- objectToString.call(value) != objectTag || isHostObject(value)) {
2288
- return false;
2289
- }
2290
- var proto = getPrototype(value);
2291
- if (proto === null) {
2292
- return true;
2293
- }
2294
- var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
2295
- return (typeof Ctor == 'function' &&
2296
- Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
2297
- }
2298
-
2299
- var lodash_isplainobject = isPlainObject;
2300
-
2301
- /**
2302
- * @name ast-monkey-util
2303
- * @fileoverview Utility library of AST helper functions
2304
- * @version 1.3.16
2305
- * @author Roy Revelt, Codsen Ltd
2306
- * @license MIT
2307
- * {@link https://codsen.com/os/ast-monkey-util/}
2308
- */
2309
-
2310
- function parent(str) {
2311
- if (str.includes(".")) {
2312
- const lastDotAt = str.lastIndexOf(".");
2313
- if (!str.slice(0, lastDotAt).includes(".")) {
2314
- return str.slice(0, lastDotAt);
2315
- }
2316
- for (let i = lastDotAt - 1; i--;) {
2317
- if (str[i] === ".") {
2318
- return str.slice(i + 1, lastDotAt);
2319
- }
2320
- }
2321
- }
2322
- return null;
2323
- }
2324
-
2325
- /**
2326
- * @name ast-monkey-traverse
2327
- * @fileoverview Utility library to traverse AST
2328
- * @version 2.0.16
2329
- * @author Roy Revelt, Codsen Ltd
2330
- * @license MIT
2331
- * {@link https://codsen.com/os/ast-monkey-traverse/}
2332
- */
2333
- function traverse(tree1, cb1) {
2334
- const stop2 = {
2335
- now: false
2336
- };
2337
- function traverseInner(treeOriginal, callback, originalInnerObj, stop) {
2338
- const tree = lodash_clonedeep(treeOriginal);
2339
- let res;
2340
- const innerObj = {
2341
- depth: -1,
2342
- path: "",
2343
- ...originalInnerObj
2344
- };
2345
- innerObj.depth += 1;
2346
- if (Array.isArray(tree)) {
2347
- for (let i = 0, len = tree.length; i < len; i++) {
2348
- if (stop.now) {
2349
- break;
2350
- }
2351
- const path = innerObj.path ? `${innerObj.path}.${i}` : `${i}`;
2352
- if (tree[i] !== undefined) {
2353
- innerObj.parent = lodash_clonedeep(tree);
2354
- innerObj.parentType = "array";
2355
- innerObj.parentKey = parent(path);
2356
- res = traverseInner(callback(tree[i], undefined, { ...innerObj,
2357
- path
2358
- }, stop), callback, { ...innerObj,
2359
- path
2360
- }, stop);
2361
- if (Number.isNaN(res) && i < tree.length) {
2362
- tree.splice(i, 1);
2363
- i -= 1;
2364
- } else {
2365
- tree[i] = res;
2366
- }
2367
- } else {
2368
- tree.splice(i, 1);
2369
- }
2370
- }
2371
- } else if (lodash_isplainobject(tree)) {
2372
- for (const key in tree) {
2373
- if (stop.now && key != null) {
2374
- break;
2375
- }
2376
- const path = innerObj.path ? `${innerObj.path}.${key}` : key;
2377
- if (innerObj.depth === 0 && key != null) {
2378
- innerObj.topmostKey = key;
2379
- }
2380
- innerObj.parent = lodash_clonedeep(tree);
2381
- innerObj.parentType = "object";
2382
- innerObj.parentKey = parent(path);
2383
- res = traverseInner(callback(key, tree[key], { ...innerObj,
2384
- path
2385
- }, stop), callback, { ...innerObj,
2386
- path
2387
- }, stop);
2388
- if (Number.isNaN(res)) {
2389
- delete tree[key];
2390
- } else {
2391
- tree[key] = res;
2392
- }
2393
- }
2394
- }
2395
- return tree;
2396
- }
2397
- return traverseInner(tree1, cb1, {}, stop2);
2398
- }
2399
-
2400
- /**
2401
- * @name ast-contains-only-empty-space
2402
- * @fileoverview Does AST contain only empty space?
2403
- * @version 2.0.16
2404
- * @author Roy Revelt, Codsen Ltd
2405
- * @license MIT
2406
- * {@link https://codsen.com/os/ast-contains-only-empty-space/}
2407
- */
2408
-
2409
- function empty(input) {
2410
- if (typeof input === "string") {
2411
- return !input.trim();
2412
- }
2413
- if (!["object", "string"].includes(typeof input) || !input) {
2414
- return false;
2415
- }
2416
- let found = true;
2417
- input = traverse(input, (key, val, innerObj, stop) => {
2418
- const current = val !== undefined ? val : key;
2419
- if (typeof current === "string" && current.trim()) {
2420
- found = false;
2421
- stop.now = true;
2422
- }
2423
- return current;
2424
- });
2425
- return found;
2426
- }
2427
-
2428
- var escapeStringRegexp = string => {
2429
- if (typeof string !== 'string') {
2430
- throw new TypeError('Expected a string');
2431
- }
2432
-
2433
- // Escape characters with special meaning either inside or outside character sets.
2434
- // 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.
2435
- return string
2436
- .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
2437
- .replace(/-/g, '\\x2d');
2438
- };
2439
-
2440
- const regexpCache = new Map();
2441
-
2442
- function sanitizeArray(input, inputName) {
2443
- if (!Array.isArray(input)) {
2444
- switch (typeof input) {
2445
- case 'string':
2446
- input = [input];
2447
- break;
2448
- case 'undefined':
2449
- input = [];
2450
- break;
2451
- default:
2452
- throw new TypeError(`Expected '${inputName}' to be a string or an array, but got a type of '${typeof input}'`);
2453
- }
2454
- }
2455
-
2456
- return input.filter(string => {
2457
- if (typeof string !== 'string') {
2458
- if (typeof string === 'undefined') {
2459
- return false;
2460
- }
2461
-
2462
- throw new TypeError(`Expected '${inputName}' to be an array of strings, but found a type of '${typeof string}' in the array`);
2463
- }
2464
-
2465
- return true;
2466
- });
2467
- }
2468
-
2469
- function makeRegexp(pattern, options) {
2470
- options = {
2471
- caseSensitive: false,
2472
- ...options
2473
- };
2474
-
2475
- const cacheKey = pattern + JSON.stringify(options);
2476
-
2477
- if (regexpCache.has(cacheKey)) {
2478
- return regexpCache.get(cacheKey);
2479
- }
2480
-
2481
- const negated = pattern[0] === '!';
2482
-
2483
- if (negated) {
2484
- pattern = pattern.slice(1);
2485
- }
2486
-
2487
- pattern = escapeStringRegexp(pattern).replace(/\\\*/g, '[\\s\\S]*');
2488
-
2489
- const regexp = new RegExp(`^${pattern}$`, options.caseSensitive ? '' : 'i');
2490
- regexp.negated = negated;
2491
- regexpCache.set(cacheKey, regexp);
2492
-
2493
- return regexp;
2494
- }
2495
-
2496
- var matcher = (inputs, patterns, options) => {
2497
- inputs = sanitizeArray(inputs, 'inputs');
2498
- patterns = sanitizeArray(patterns, 'patterns');
2499
-
2500
- if (patterns.length === 0) {
2501
- return [];
2502
- }
2503
-
2504
- const isFirstPatternNegated = patterns[0][0] === '!';
2505
-
2506
- patterns = patterns.map(pattern => makeRegexp(pattern, options));
2507
-
2508
- const result = [];
2509
-
2510
- for (const input of inputs) {
2511
- // If first pattern is negated we include everything to match user expectation.
2512
- let matches = isFirstPatternNegated;
2513
-
2514
- for (const pattern of patterns) {
2515
- if (pattern.test(input)) {
2516
- matches = !pattern.negated;
2517
- }
2518
- }
2519
-
2520
- if (matches) {
2521
- result.push(input);
2522
- }
2523
- }
2524
-
2525
- return result;
2526
- };
2527
-
2528
- var isMatch = (inputs, patterns, options) => {
2529
- inputs = sanitizeArray(inputs, 'inputs');
2530
- patterns = sanitizeArray(patterns, 'patterns');
2531
-
2532
- if (patterns.length === 0) {
2533
- return false;
2534
- }
2535
-
2536
- return inputs.some(input => {
2537
- return patterns.every(pattern => {
2538
- const regexp = makeRegexp(pattern, options);
2539
- const matches = regexp.test(input);
2540
- return regexp.negated ? !matches : matches;
2541
- });
2542
- });
2543
- };
2544
- matcher.isMatch = isMatch;
2545
-
2546
- // -----------------------------------------------------------------------------
2547
- /* istanbul ignore next */
2548
- function isBlank(something) {
2549
- if (lodash_isplainobject(something)) {
2550
- return !Object.keys(something).length;
2551
- }
2552
- if (Array.isArray(something) || typeof something === "string") {
2553
- return !something.length;
2554
- }
2555
- return false;
2556
- }
2557
- // -----------------------------------------------------------------------------
2558
- // Legend:
2559
- // b - superset object; s - subset object
2560
- /**
2561
- * Compare anything: AST, objects, arrays, strings and nested thereof
2562
- */
2563
- function compare(b, s, originalOpts) {
2564
- let sKeys;
2565
- let bKeys;
2566
- let found;
2567
- let bOffset = 0;
2568
- // prep opts
2569
- const defaults = {
2570
- hungryForWhitespace: false,
2571
- matchStrictly: false,
2572
- verboseWhenMismatches: false,
2573
- useWildcards: false,
2574
- };
2575
- const opts = { ...defaults, ...originalOpts };
2576
- // edge case when hungryForWhitespace=true, matchStrictly=true and matching against blank object:
2577
- if (opts.hungryForWhitespace &&
2578
- opts.matchStrictly &&
2579
- lodash_isplainobject(b) &&
2580
- empty(b) &&
2581
- lodash_isplainobject(s) &&
2582
- !Object.keys(s).length) {
2583
- return true;
2584
- }
2585
- // instant (falsey) result
2586
- if (((!opts.hungryForWhitespace ||
2587
- (opts.hungryForWhitespace && !empty(b) && empty(s))) &&
2588
- lodash_isplainobject(b) &&
2589
- Object.keys(b).length !== 0 &&
2590
- lodash_isplainobject(s) &&
2591
- Object.keys(s).length === 0) ||
2592
- (typeDetect(b) !== typeDetect(s) &&
2593
- (!opts.hungryForWhitespace || (opts.hungryForWhitespace && !empty(b))))) {
2594
- return false;
2595
- }
2596
- // A C T I O N
2597
- if (typeof b === "string" && typeof s === "string") {
2598
- if (opts.hungryForWhitespace && empty(b) && empty(s)) {
2599
- return true;
2600
- }
2601
- if (opts.verboseWhenMismatches) {
2602
- return b === s
2603
- ? true
2604
- : `Given string ${s} is not matched! We have ${b} on the other end.`;
2605
- }
2606
- return opts.useWildcards
2607
- ? matcher.isMatch(b, s, { caseSensitive: true })
2608
- : b === s;
2609
- }
2610
- if (Array.isArray(b) && Array.isArray(s)) {
2611
- if (opts.hungryForWhitespace &&
2612
- empty(s) &&
2613
- (!opts.matchStrictly || (opts.matchStrictly && b.length === s.length))) {
2614
- return true;
2615
- }
2616
- if ((!opts.hungryForWhitespace && s.length > b.length) ||
2617
- (opts.matchStrictly && s.length !== b.length)) {
2618
- if (!opts.verboseWhenMismatches) {
2619
- return false;
2620
- }
2621
- return `The length of a given array, ${JSON.stringify(s, null, 4)} is ${s.length} but the length of an array on the other end, ${JSON.stringify(b, null, 4)} is ${b.length}`;
2622
- }
2623
- if (s.length === 0) {
2624
- if (b.length === 0) {
2625
- return true;
2626
- }
2627
- // so b is not zero-long, but s is.
2628
- if (opts.verboseWhenMismatches) {
2629
- return `The given array has no elements, but the array on the other end, ${JSON.stringify(b, null, 4)} does have some`;
2630
- }
2631
- return false;
2632
- }
2633
- for (let i = 0, sLen = s.length; i < sLen; i++) {
2634
- found = false;
2635
- for (let j = bOffset, bLen = b.length; j < bLen; j++) {
2636
- bOffset += 1;
2637
- if (compare(b[j], s[i], opts) === true) {
2638
- found = true;
2639
- break;
2640
- }
2641
- }
2642
- if (!found) {
2643
- if (!opts.verboseWhenMismatches) {
2644
- return false;
2645
- }
2646
- return `The given array ${JSON.stringify(s, null, 4)} is not a subset of an array on the other end, ${JSON.stringify(b, null, 4)}`;
2647
- }
2648
- }
2649
- }
2650
- else if (lodash_isplainobject(b) && lodash_isplainobject(s)) {
2651
- sKeys = new Set(Object.keys(s));
2652
- bKeys = new Set(Object.keys(b));
2653
- if (opts.matchStrictly && sKeys.size !== bKeys.size) {
2654
- if (!opts.verboseWhenMismatches) {
2655
- return false;
2656
- }
2657
- const uniqueKeysOnS = new Set([...sKeys].filter((x) => !bKeys.has(x)));
2658
- const sMessage = uniqueKeysOnS.size
2659
- ? ` First object has unique keys: ${JSON.stringify(uniqueKeysOnS, null, 4)}.`
2660
- : "";
2661
- const uniqueKeysOnB = new Set([...bKeys].filter((x) => !sKeys.has(x)));
2662
- const bMessage = uniqueKeysOnB.size
2663
- ? ` Second object has unique keys:
2664
- ${JSON.stringify(uniqueKeysOnB, null, 4)}.`
2665
- : "";
2666
- return `When matching strictly, we found that both objects have different amount of keys.${sMessage}${bMessage}`;
2667
- }
2668
- // eslint-disable-next-line
2669
- for (const sKey of sKeys) {
2670
- if (!Object.prototype.hasOwnProperty.call(b, sKey)) {
2671
- if (!opts.useWildcards || (opts.useWildcards && !sKey.includes("*"))) {
2672
- if (!opts.verboseWhenMismatches) {
2673
- return false;
2674
- }
2675
- return `The given object has key "${sKey}" which the other-one does not have.`;
2676
- }
2677
- // so wildcards are on and sKeys[i] contains a wildcard
2678
- if (Object.keys(b).some((bKey) => matcher.isMatch(bKey, sKey, { caseSensitive: true }))) {
2679
- // so some keys do match. Return true
2680
- return true;
2681
- }
2682
- if (!opts.verboseWhenMismatches) {
2683
- return false;
2684
- }
2685
- return `The given object has key "${sKey}" which the other-one does not have.`;
2686
- }
2687
- if (b[sKey] != null &&
2688
- typeDetect(b[sKey]) !==
2689
- typeDetect(s[sKey])) {
2690
- // Types mismatch. Probably falsey result, unless comparing with
2691
- // empty/blank things. Let's check.
2692
- // it might be blank array vs blank object:
2693
- if (!(empty(b[sKey]) &&
2694
- empty(s[sKey]) &&
2695
- opts.hungryForWhitespace)) {
2696
- if (!opts.verboseWhenMismatches) {
2697
- return false;
2698
- }
2699
- return `The given key ${sKey} is of a different type on both objects. On the first-one, it's ${typeDetect(s[sKey])}, on the second-one, it's ${typeDetect(b[sKey])}`;
2700
- }
2701
- }
2702
- else if (compare(b[sKey], s[sKey], opts) !== true) {
2703
- if (!opts.verboseWhenMismatches) {
2704
- return false;
2705
- }
2706
- return `The given piece ${JSON.stringify(s[sKey], null, 4)} and ${JSON.stringify(b[sKey], null, 4)} don't match.`;
2707
- }
2708
- }
2709
- }
2710
- else {
2711
- if (opts.hungryForWhitespace &&
2712
- empty(b) &&
2713
- empty(s) &&
2714
- (!opts.matchStrictly || (opts.matchStrictly && isBlank(s)))) {
2715
- return true;
2716
- }
2717
- return b === s;
2718
- }
2719
- return true;
2720
- }
2721
-
2722
- exports.compare = compare;
2723
-
2724
- Object.defineProperty(exports, '__esModule', { value: true });
2725
-
2726
- })));