object-flatten-referencing 5.0.16 → 6.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,2399 +0,0 @@
1
- /**
2
- * @name object-flatten-referencing
3
- * @fileoverview Flatten complex nested objects according to a reference objects
4
- * @version 5.0.16
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/object-flatten-referencing/}
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.objectFlattenReferencing = {}));
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
- /**
24
- * lodash (Custom Build) <https://lodash.com/>
25
- * Build: `lodash modularize exports="npm" -o ./`
26
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
27
- * Released under MIT license <https://lodash.com/license>
28
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
29
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
30
- */
31
-
32
- var lodash_clonedeep = createCommonjsModule(function (module, exports) {
33
- /** Used as the size to enable large array optimizations. */
34
- var LARGE_ARRAY_SIZE = 200;
35
-
36
- /** Used to stand-in for `undefined` hash values. */
37
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
38
-
39
- /** Used as references for various `Number` constants. */
40
- var MAX_SAFE_INTEGER = 9007199254740991;
41
-
42
- /** `Object#toString` result references. */
43
- var argsTag = '[object Arguments]',
44
- arrayTag = '[object Array]',
45
- boolTag = '[object Boolean]',
46
- dateTag = '[object Date]',
47
- errorTag = '[object Error]',
48
- funcTag = '[object Function]',
49
- genTag = '[object GeneratorFunction]',
50
- mapTag = '[object Map]',
51
- numberTag = '[object Number]',
52
- objectTag = '[object Object]',
53
- promiseTag = '[object Promise]',
54
- regexpTag = '[object RegExp]',
55
- setTag = '[object Set]',
56
- stringTag = '[object String]',
57
- symbolTag = '[object Symbol]',
58
- weakMapTag = '[object WeakMap]';
59
-
60
- var arrayBufferTag = '[object ArrayBuffer]',
61
- dataViewTag = '[object DataView]',
62
- float32Tag = '[object Float32Array]',
63
- float64Tag = '[object Float64Array]',
64
- int8Tag = '[object Int8Array]',
65
- int16Tag = '[object Int16Array]',
66
- int32Tag = '[object Int32Array]',
67
- uint8Tag = '[object Uint8Array]',
68
- uint8ClampedTag = '[object Uint8ClampedArray]',
69
- uint16Tag = '[object Uint16Array]',
70
- uint32Tag = '[object Uint32Array]';
71
-
72
- /**
73
- * Used to match `RegExp`
74
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
75
- */
76
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
77
-
78
- /** Used to match `RegExp` flags from their coerced string values. */
79
- var reFlags = /\w*$/;
80
-
81
- /** Used to detect host constructors (Safari). */
82
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
83
-
84
- /** Used to detect unsigned integer values. */
85
- var reIsUint = /^(?:0|[1-9]\d*)$/;
86
-
87
- /** Used to identify `toStringTag` values supported by `_.clone`. */
88
- var cloneableTags = {};
89
- cloneableTags[argsTag] = cloneableTags[arrayTag] =
90
- cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
91
- cloneableTags[boolTag] = cloneableTags[dateTag] =
92
- cloneableTags[float32Tag] = cloneableTags[float64Tag] =
93
- cloneableTags[int8Tag] = cloneableTags[int16Tag] =
94
- cloneableTags[int32Tag] = cloneableTags[mapTag] =
95
- cloneableTags[numberTag] = cloneableTags[objectTag] =
96
- cloneableTags[regexpTag] = cloneableTags[setTag] =
97
- cloneableTags[stringTag] = cloneableTags[symbolTag] =
98
- cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
99
- cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
100
- cloneableTags[errorTag] = cloneableTags[funcTag] =
101
- cloneableTags[weakMapTag] = false;
102
-
103
- /** Detect free variable `global` from Node.js. */
104
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
105
-
106
- /** Detect free variable `self`. */
107
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
108
-
109
- /** Used as a reference to the global object. */
110
- var root = freeGlobal || freeSelf || Function('return this')();
111
-
112
- /** Detect free variable `exports`. */
113
- var freeExports = exports && !exports.nodeType && exports;
114
-
115
- /** Detect free variable `module`. */
116
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
117
-
118
- /** Detect the popular CommonJS extension `module.exports`. */
119
- var moduleExports = freeModule && freeModule.exports === freeExports;
120
-
121
- /**
122
- * Adds the key-value `pair` to `map`.
123
- *
124
- * @private
125
- * @param {Object} map The map to modify.
126
- * @param {Array} pair The key-value pair to add.
127
- * @returns {Object} Returns `map`.
128
- */
129
- function addMapEntry(map, pair) {
130
- // Don't return `map.set` because it's not chainable in IE 11.
131
- map.set(pair[0], pair[1]);
132
- return map;
133
- }
134
-
135
- /**
136
- * Adds `value` to `set`.
137
- *
138
- * @private
139
- * @param {Object} set The set to modify.
140
- * @param {*} value The value to add.
141
- * @returns {Object} Returns `set`.
142
- */
143
- function addSetEntry(set, value) {
144
- // Don't return `set.add` because it's not chainable in IE 11.
145
- set.add(value);
146
- return set;
147
- }
148
-
149
- /**
150
- * A specialized version of `_.forEach` for arrays without support for
151
- * iteratee shorthands.
152
- *
153
- * @private
154
- * @param {Array} [array] The array to iterate over.
155
- * @param {Function} iteratee The function invoked per iteration.
156
- * @returns {Array} Returns `array`.
157
- */
158
- function arrayEach(array, iteratee) {
159
- var index = -1,
160
- length = array ? array.length : 0;
161
-
162
- while (++index < length) {
163
- if (iteratee(array[index], index, array) === false) {
164
- break;
165
- }
166
- }
167
- return array;
168
- }
169
-
170
- /**
171
- * Appends the elements of `values` to `array`.
172
- *
173
- * @private
174
- * @param {Array} array The array to modify.
175
- * @param {Array} values The values to append.
176
- * @returns {Array} Returns `array`.
177
- */
178
- function arrayPush(array, values) {
179
- var index = -1,
180
- length = values.length,
181
- offset = array.length;
182
-
183
- while (++index < length) {
184
- array[offset + index] = values[index];
185
- }
186
- return array;
187
- }
188
-
189
- /**
190
- * A specialized version of `_.reduce` for arrays without support for
191
- * iteratee shorthands.
192
- *
193
- * @private
194
- * @param {Array} [array] The array to iterate over.
195
- * @param {Function} iteratee The function invoked per iteration.
196
- * @param {*} [accumulator] The initial value.
197
- * @param {boolean} [initAccum] Specify using the first element of `array` as
198
- * the initial value.
199
- * @returns {*} Returns the accumulated value.
200
- */
201
- function arrayReduce(array, iteratee, accumulator, initAccum) {
202
- var index = -1,
203
- length = array ? array.length : 0;
204
-
205
- if (initAccum && length) {
206
- accumulator = array[++index];
207
- }
208
- while (++index < length) {
209
- accumulator = iteratee(accumulator, array[index], index, array);
210
- }
211
- return accumulator;
212
- }
213
-
214
- /**
215
- * The base implementation of `_.times` without support for iteratee shorthands
216
- * or max array length checks.
217
- *
218
- * @private
219
- * @param {number} n The number of times to invoke `iteratee`.
220
- * @param {Function} iteratee The function invoked per iteration.
221
- * @returns {Array} Returns the array of results.
222
- */
223
- function baseTimes(n, iteratee) {
224
- var index = -1,
225
- result = Array(n);
226
-
227
- while (++index < n) {
228
- result[index] = iteratee(index);
229
- }
230
- return result;
231
- }
232
-
233
- /**
234
- * Gets the value at `key` of `object`.
235
- *
236
- * @private
237
- * @param {Object} [object] The object to query.
238
- * @param {string} key The key of the property to get.
239
- * @returns {*} Returns the property value.
240
- */
241
- function getValue(object, key) {
242
- return object == null ? undefined : object[key];
243
- }
244
-
245
- /**
246
- * Checks if `value` is a host object in IE < 9.
247
- *
248
- * @private
249
- * @param {*} value The value to check.
250
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
251
- */
252
- function isHostObject(value) {
253
- // Many host objects are `Object` objects that can coerce to strings
254
- // despite having improperly defined `toString` methods.
255
- var result = false;
256
- if (value != null && typeof value.toString != 'function') {
257
- try {
258
- result = !!(value + '');
259
- } catch (e) {}
260
- }
261
- return result;
262
- }
263
-
264
- /**
265
- * Converts `map` to its key-value pairs.
266
- *
267
- * @private
268
- * @param {Object} map The map to convert.
269
- * @returns {Array} Returns the key-value pairs.
270
- */
271
- function mapToArray(map) {
272
- var index = -1,
273
- result = Array(map.size);
274
-
275
- map.forEach(function(value, key) {
276
- result[++index] = [key, value];
277
- });
278
- return result;
279
- }
280
-
281
- /**
282
- * Creates a unary function that invokes `func` with its argument transformed.
283
- *
284
- * @private
285
- * @param {Function} func The function to wrap.
286
- * @param {Function} transform The argument transform.
287
- * @returns {Function} Returns the new function.
288
- */
289
- function overArg(func, transform) {
290
- return function(arg) {
291
- return func(transform(arg));
292
- };
293
- }
294
-
295
- /**
296
- * Converts `set` to an array of its values.
297
- *
298
- * @private
299
- * @param {Object} set The set to convert.
300
- * @returns {Array} Returns the values.
301
- */
302
- function setToArray(set) {
303
- var index = -1,
304
- result = Array(set.size);
305
-
306
- set.forEach(function(value) {
307
- result[++index] = value;
308
- });
309
- return result;
310
- }
311
-
312
- /** Used for built-in method references. */
313
- var arrayProto = Array.prototype,
314
- funcProto = Function.prototype,
315
- objectProto = Object.prototype;
316
-
317
- /** Used to detect overreaching core-js shims. */
318
- var coreJsData = root['__core-js_shared__'];
319
-
320
- /** Used to detect methods masquerading as native. */
321
- var maskSrcKey = (function() {
322
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
323
- return uid ? ('Symbol(src)_1.' + uid) : '';
324
- }());
325
-
326
- /** Used to resolve the decompiled source of functions. */
327
- var funcToString = funcProto.toString;
328
-
329
- /** Used to check objects for own properties. */
330
- var hasOwnProperty = objectProto.hasOwnProperty;
331
-
332
- /**
333
- * Used to resolve the
334
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
335
- * of values.
336
- */
337
- var objectToString = objectProto.toString;
338
-
339
- /** Used to detect if a method is native. */
340
- var reIsNative = RegExp('^' +
341
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
342
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
343
- );
344
-
345
- /** Built-in value references. */
346
- var Buffer = moduleExports ? root.Buffer : undefined,
347
- Symbol = root.Symbol,
348
- Uint8Array = root.Uint8Array,
349
- getPrototype = overArg(Object.getPrototypeOf, Object),
350
- objectCreate = Object.create,
351
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
352
- splice = arrayProto.splice;
353
-
354
- /* Built-in method references for those with the same name as other `lodash` methods. */
355
- var nativeGetSymbols = Object.getOwnPropertySymbols,
356
- nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
357
- nativeKeys = overArg(Object.keys, Object);
358
-
359
- /* Built-in method references that are verified to be native. */
360
- var DataView = getNative(root, 'DataView'),
361
- Map = getNative(root, 'Map'),
362
- Promise = getNative(root, 'Promise'),
363
- Set = getNative(root, 'Set'),
364
- WeakMap = getNative(root, 'WeakMap'),
365
- nativeCreate = getNative(Object, 'create');
366
-
367
- /** Used to detect maps, sets, and weakmaps. */
368
- var dataViewCtorString = toSource(DataView),
369
- mapCtorString = toSource(Map),
370
- promiseCtorString = toSource(Promise),
371
- setCtorString = toSource(Set),
372
- weakMapCtorString = toSource(WeakMap);
373
-
374
- /** Used to convert symbols to primitives and strings. */
375
- var symbolProto = Symbol ? Symbol.prototype : undefined,
376
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
377
-
378
- /**
379
- * Creates a hash object.
380
- *
381
- * @private
382
- * @constructor
383
- * @param {Array} [entries] The key-value pairs to cache.
384
- */
385
- function Hash(entries) {
386
- var index = -1,
387
- length = entries ? entries.length : 0;
388
-
389
- this.clear();
390
- while (++index < length) {
391
- var entry = entries[index];
392
- this.set(entry[0], entry[1]);
393
- }
394
- }
395
-
396
- /**
397
- * Removes all key-value entries from the hash.
398
- *
399
- * @private
400
- * @name clear
401
- * @memberOf Hash
402
- */
403
- function hashClear() {
404
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
405
- }
406
-
407
- /**
408
- * Removes `key` and its value from the hash.
409
- *
410
- * @private
411
- * @name delete
412
- * @memberOf Hash
413
- * @param {Object} hash The hash to modify.
414
- * @param {string} key The key of the value to remove.
415
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
416
- */
417
- function hashDelete(key) {
418
- return this.has(key) && delete this.__data__[key];
419
- }
420
-
421
- /**
422
- * Gets the hash value for `key`.
423
- *
424
- * @private
425
- * @name get
426
- * @memberOf Hash
427
- * @param {string} key The key of the value to get.
428
- * @returns {*} Returns the entry value.
429
- */
430
- function hashGet(key) {
431
- var data = this.__data__;
432
- if (nativeCreate) {
433
- var result = data[key];
434
- return result === HASH_UNDEFINED ? undefined : result;
435
- }
436
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
437
- }
438
-
439
- /**
440
- * Checks if a hash value for `key` exists.
441
- *
442
- * @private
443
- * @name has
444
- * @memberOf Hash
445
- * @param {string} key The key of the entry to check.
446
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
447
- */
448
- function hashHas(key) {
449
- var data = this.__data__;
450
- return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
451
- }
452
-
453
- /**
454
- * Sets the hash `key` to `value`.
455
- *
456
- * @private
457
- * @name set
458
- * @memberOf Hash
459
- * @param {string} key The key of the value to set.
460
- * @param {*} value The value to set.
461
- * @returns {Object} Returns the hash instance.
462
- */
463
- function hashSet(key, value) {
464
- var data = this.__data__;
465
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
466
- return this;
467
- }
468
-
469
- // Add methods to `Hash`.
470
- Hash.prototype.clear = hashClear;
471
- Hash.prototype['delete'] = hashDelete;
472
- Hash.prototype.get = hashGet;
473
- Hash.prototype.has = hashHas;
474
- Hash.prototype.set = hashSet;
475
-
476
- /**
477
- * Creates an list cache object.
478
- *
479
- * @private
480
- * @constructor
481
- * @param {Array} [entries] The key-value pairs to cache.
482
- */
483
- function ListCache(entries) {
484
- var index = -1,
485
- length = entries ? entries.length : 0;
486
-
487
- this.clear();
488
- while (++index < length) {
489
- var entry = entries[index];
490
- this.set(entry[0], entry[1]);
491
- }
492
- }
493
-
494
- /**
495
- * Removes all key-value entries from the list cache.
496
- *
497
- * @private
498
- * @name clear
499
- * @memberOf ListCache
500
- */
501
- function listCacheClear() {
502
- this.__data__ = [];
503
- }
504
-
505
- /**
506
- * Removes `key` and its value from the list cache.
507
- *
508
- * @private
509
- * @name delete
510
- * @memberOf ListCache
511
- * @param {string} key The key of the value to remove.
512
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
513
- */
514
- function listCacheDelete(key) {
515
- var data = this.__data__,
516
- index = assocIndexOf(data, key);
517
-
518
- if (index < 0) {
519
- return false;
520
- }
521
- var lastIndex = data.length - 1;
522
- if (index == lastIndex) {
523
- data.pop();
524
- } else {
525
- splice.call(data, index, 1);
526
- }
527
- return true;
528
- }
529
-
530
- /**
531
- * Gets the list cache value for `key`.
532
- *
533
- * @private
534
- * @name get
535
- * @memberOf ListCache
536
- * @param {string} key The key of the value to get.
537
- * @returns {*} Returns the entry value.
538
- */
539
- function listCacheGet(key) {
540
- var data = this.__data__,
541
- index = assocIndexOf(data, key);
542
-
543
- return index < 0 ? undefined : data[index][1];
544
- }
545
-
546
- /**
547
- * Checks if a list cache value for `key` exists.
548
- *
549
- * @private
550
- * @name has
551
- * @memberOf ListCache
552
- * @param {string} key The key of the entry to check.
553
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
554
- */
555
- function listCacheHas(key) {
556
- return assocIndexOf(this.__data__, key) > -1;
557
- }
558
-
559
- /**
560
- * Sets the list cache `key` to `value`.
561
- *
562
- * @private
563
- * @name set
564
- * @memberOf ListCache
565
- * @param {string} key The key of the value to set.
566
- * @param {*} value The value to set.
567
- * @returns {Object} Returns the list cache instance.
568
- */
569
- function listCacheSet(key, value) {
570
- var data = this.__data__,
571
- index = assocIndexOf(data, key);
572
-
573
- if (index < 0) {
574
- data.push([key, value]);
575
- } else {
576
- data[index][1] = value;
577
- }
578
- return this;
579
- }
580
-
581
- // Add methods to `ListCache`.
582
- ListCache.prototype.clear = listCacheClear;
583
- ListCache.prototype['delete'] = listCacheDelete;
584
- ListCache.prototype.get = listCacheGet;
585
- ListCache.prototype.has = listCacheHas;
586
- ListCache.prototype.set = listCacheSet;
587
-
588
- /**
589
- * Creates a map cache object to store key-value pairs.
590
- *
591
- * @private
592
- * @constructor
593
- * @param {Array} [entries] The key-value pairs to cache.
594
- */
595
- function MapCache(entries) {
596
- var index = -1,
597
- length = entries ? entries.length : 0;
598
-
599
- this.clear();
600
- while (++index < length) {
601
- var entry = entries[index];
602
- this.set(entry[0], entry[1]);
603
- }
604
- }
605
-
606
- /**
607
- * Removes all key-value entries from the map.
608
- *
609
- * @private
610
- * @name clear
611
- * @memberOf MapCache
612
- */
613
- function mapCacheClear() {
614
- this.__data__ = {
615
- 'hash': new Hash,
616
- 'map': new (Map || ListCache),
617
- 'string': new Hash
618
- };
619
- }
620
-
621
- /**
622
- * Removes `key` and its value from the map.
623
- *
624
- * @private
625
- * @name delete
626
- * @memberOf MapCache
627
- * @param {string} key The key of the value to remove.
628
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
629
- */
630
- function mapCacheDelete(key) {
631
- return getMapData(this, key)['delete'](key);
632
- }
633
-
634
- /**
635
- * Gets the map value for `key`.
636
- *
637
- * @private
638
- * @name get
639
- * @memberOf MapCache
640
- * @param {string} key The key of the value to get.
641
- * @returns {*} Returns the entry value.
642
- */
643
- function mapCacheGet(key) {
644
- return getMapData(this, key).get(key);
645
- }
646
-
647
- /**
648
- * Checks if a map value for `key` exists.
649
- *
650
- * @private
651
- * @name has
652
- * @memberOf MapCache
653
- * @param {string} key The key of the entry to check.
654
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
655
- */
656
- function mapCacheHas(key) {
657
- return getMapData(this, key).has(key);
658
- }
659
-
660
- /**
661
- * Sets the map `key` to `value`.
662
- *
663
- * @private
664
- * @name set
665
- * @memberOf MapCache
666
- * @param {string} key The key of the value to set.
667
- * @param {*} value The value to set.
668
- * @returns {Object} Returns the map cache instance.
669
- */
670
- function mapCacheSet(key, value) {
671
- getMapData(this, key).set(key, value);
672
- return this;
673
- }
674
-
675
- // Add methods to `MapCache`.
676
- MapCache.prototype.clear = mapCacheClear;
677
- MapCache.prototype['delete'] = mapCacheDelete;
678
- MapCache.prototype.get = mapCacheGet;
679
- MapCache.prototype.has = mapCacheHas;
680
- MapCache.prototype.set = mapCacheSet;
681
-
682
- /**
683
- * Creates a stack cache object to store key-value pairs.
684
- *
685
- * @private
686
- * @constructor
687
- * @param {Array} [entries] The key-value pairs to cache.
688
- */
689
- function Stack(entries) {
690
- this.__data__ = new ListCache(entries);
691
- }
692
-
693
- /**
694
- * Removes all key-value entries from the stack.
695
- *
696
- * @private
697
- * @name clear
698
- * @memberOf Stack
699
- */
700
- function stackClear() {
701
- this.__data__ = new ListCache;
702
- }
703
-
704
- /**
705
- * Removes `key` and its value from the stack.
706
- *
707
- * @private
708
- * @name delete
709
- * @memberOf Stack
710
- * @param {string} key The key of the value to remove.
711
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
712
- */
713
- function stackDelete(key) {
714
- return this.__data__['delete'](key);
715
- }
716
-
717
- /**
718
- * Gets the stack value for `key`.
719
- *
720
- * @private
721
- * @name get
722
- * @memberOf Stack
723
- * @param {string} key The key of the value to get.
724
- * @returns {*} Returns the entry value.
725
- */
726
- function stackGet(key) {
727
- return this.__data__.get(key);
728
- }
729
-
730
- /**
731
- * Checks if a stack value for `key` exists.
732
- *
733
- * @private
734
- * @name has
735
- * @memberOf Stack
736
- * @param {string} key The key of the entry to check.
737
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
738
- */
739
- function stackHas(key) {
740
- return this.__data__.has(key);
741
- }
742
-
743
- /**
744
- * Sets the stack `key` to `value`.
745
- *
746
- * @private
747
- * @name set
748
- * @memberOf Stack
749
- * @param {string} key The key of the value to set.
750
- * @param {*} value The value to set.
751
- * @returns {Object} Returns the stack cache instance.
752
- */
753
- function stackSet(key, value) {
754
- var cache = this.__data__;
755
- if (cache instanceof ListCache) {
756
- var pairs = cache.__data__;
757
- if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
758
- pairs.push([key, value]);
759
- return this;
760
- }
761
- cache = this.__data__ = new MapCache(pairs);
762
- }
763
- cache.set(key, value);
764
- return this;
765
- }
766
-
767
- // Add methods to `Stack`.
768
- Stack.prototype.clear = stackClear;
769
- Stack.prototype['delete'] = stackDelete;
770
- Stack.prototype.get = stackGet;
771
- Stack.prototype.has = stackHas;
772
- Stack.prototype.set = stackSet;
773
-
774
- /**
775
- * Creates an array of the enumerable property names of the array-like `value`.
776
- *
777
- * @private
778
- * @param {*} value The value to query.
779
- * @param {boolean} inherited Specify returning inherited property names.
780
- * @returns {Array} Returns the array of property names.
781
- */
782
- function arrayLikeKeys(value, inherited) {
783
- // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
784
- // Safari 9 makes `arguments.length` enumerable in strict mode.
785
- var result = (isArray(value) || isArguments(value))
786
- ? baseTimes(value.length, String)
787
- : [];
788
-
789
- var length = result.length,
790
- skipIndexes = !!length;
791
-
792
- for (var key in value) {
793
- if ((inherited || hasOwnProperty.call(value, key)) &&
794
- !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
795
- result.push(key);
796
- }
797
- }
798
- return result;
799
- }
800
-
801
- /**
802
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
803
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
804
- * for equality comparisons.
805
- *
806
- * @private
807
- * @param {Object} object The object to modify.
808
- * @param {string} key The key of the property to assign.
809
- * @param {*} value The value to assign.
810
- */
811
- function assignValue(object, key, value) {
812
- var objValue = object[key];
813
- if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
814
- (value === undefined && !(key in object))) {
815
- object[key] = value;
816
- }
817
- }
818
-
819
- /**
820
- * Gets the index at which the `key` is found in `array` of key-value pairs.
821
- *
822
- * @private
823
- * @param {Array} array The array to inspect.
824
- * @param {*} key The key to search for.
825
- * @returns {number} Returns the index of the matched value, else `-1`.
826
- */
827
- function assocIndexOf(array, key) {
828
- var length = array.length;
829
- while (length--) {
830
- if (eq(array[length][0], key)) {
831
- return length;
832
- }
833
- }
834
- return -1;
835
- }
836
-
837
- /**
838
- * The base implementation of `_.assign` without support for multiple sources
839
- * or `customizer` functions.
840
- *
841
- * @private
842
- * @param {Object} object The destination object.
843
- * @param {Object} source The source object.
844
- * @returns {Object} Returns `object`.
845
- */
846
- function baseAssign(object, source) {
847
- return object && copyObject(source, keys(source), object);
848
- }
849
-
850
- /**
851
- * The base implementation of `_.clone` and `_.cloneDeep` which tracks
852
- * traversed objects.
853
- *
854
- * @private
855
- * @param {*} value The value to clone.
856
- * @param {boolean} [isDeep] Specify a deep clone.
857
- * @param {boolean} [isFull] Specify a clone including symbols.
858
- * @param {Function} [customizer] The function to customize cloning.
859
- * @param {string} [key] The key of `value`.
860
- * @param {Object} [object] The parent object of `value`.
861
- * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
862
- * @returns {*} Returns the cloned value.
863
- */
864
- function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
865
- var result;
866
- if (customizer) {
867
- result = object ? customizer(value, key, object, stack) : customizer(value);
868
- }
869
- if (result !== undefined) {
870
- return result;
871
- }
872
- if (!isObject(value)) {
873
- return value;
874
- }
875
- var isArr = isArray(value);
876
- if (isArr) {
877
- result = initCloneArray(value);
878
- if (!isDeep) {
879
- return copyArray(value, result);
880
- }
881
- } else {
882
- var tag = getTag(value),
883
- isFunc = tag == funcTag || tag == genTag;
884
-
885
- if (isBuffer(value)) {
886
- return cloneBuffer(value, isDeep);
887
- }
888
- if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
889
- if (isHostObject(value)) {
890
- return object ? value : {};
891
- }
892
- result = initCloneObject(isFunc ? {} : value);
893
- if (!isDeep) {
894
- return copySymbols(value, baseAssign(result, value));
895
- }
896
- } else {
897
- if (!cloneableTags[tag]) {
898
- return object ? value : {};
899
- }
900
- result = initCloneByTag(value, tag, baseClone, isDeep);
901
- }
902
- }
903
- // Check for circular references and return its corresponding clone.
904
- stack || (stack = new Stack);
905
- var stacked = stack.get(value);
906
- if (stacked) {
907
- return stacked;
908
- }
909
- stack.set(value, result);
910
-
911
- if (!isArr) {
912
- var props = isFull ? getAllKeys(value) : keys(value);
913
- }
914
- arrayEach(props || value, function(subValue, key) {
915
- if (props) {
916
- key = subValue;
917
- subValue = value[key];
918
- }
919
- // Recursively populate clone (susceptible to call stack limits).
920
- assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
921
- });
922
- return result;
923
- }
924
-
925
- /**
926
- * The base implementation of `_.create` without support for assigning
927
- * properties to the created object.
928
- *
929
- * @private
930
- * @param {Object} prototype The object to inherit from.
931
- * @returns {Object} Returns the new object.
932
- */
933
- function baseCreate(proto) {
934
- return isObject(proto) ? objectCreate(proto) : {};
935
- }
936
-
937
- /**
938
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
939
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
940
- * symbols of `object`.
941
- *
942
- * @private
943
- * @param {Object} object The object to query.
944
- * @param {Function} keysFunc The function to get the keys of `object`.
945
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
946
- * @returns {Array} Returns the array of property names and symbols.
947
- */
948
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
949
- var result = keysFunc(object);
950
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
951
- }
952
-
953
- /**
954
- * The base implementation of `getTag`.
955
- *
956
- * @private
957
- * @param {*} value The value to query.
958
- * @returns {string} Returns the `toStringTag`.
959
- */
960
- function baseGetTag(value) {
961
- return objectToString.call(value);
962
- }
963
-
964
- /**
965
- * The base implementation of `_.isNative` without bad shim checks.
966
- *
967
- * @private
968
- * @param {*} value The value to check.
969
- * @returns {boolean} Returns `true` if `value` is a native function,
970
- * else `false`.
971
- */
972
- function baseIsNative(value) {
973
- if (!isObject(value) || isMasked(value)) {
974
- return false;
975
- }
976
- var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
977
- return pattern.test(toSource(value));
978
- }
979
-
980
- /**
981
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
982
- *
983
- * @private
984
- * @param {Object} object The object to query.
985
- * @returns {Array} Returns the array of property names.
986
- */
987
- function baseKeys(object) {
988
- if (!isPrototype(object)) {
989
- return nativeKeys(object);
990
- }
991
- var result = [];
992
- for (var key in Object(object)) {
993
- if (hasOwnProperty.call(object, key) && key != 'constructor') {
994
- result.push(key);
995
- }
996
- }
997
- return result;
998
- }
999
-
1000
- /**
1001
- * Creates a clone of `buffer`.
1002
- *
1003
- * @private
1004
- * @param {Buffer} buffer The buffer to clone.
1005
- * @param {boolean} [isDeep] Specify a deep clone.
1006
- * @returns {Buffer} Returns the cloned buffer.
1007
- */
1008
- function cloneBuffer(buffer, isDeep) {
1009
- if (isDeep) {
1010
- return buffer.slice();
1011
- }
1012
- var result = new buffer.constructor(buffer.length);
1013
- buffer.copy(result);
1014
- return result;
1015
- }
1016
-
1017
- /**
1018
- * Creates a clone of `arrayBuffer`.
1019
- *
1020
- * @private
1021
- * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
1022
- * @returns {ArrayBuffer} Returns the cloned array buffer.
1023
- */
1024
- function cloneArrayBuffer(arrayBuffer) {
1025
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1026
- new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1027
- return result;
1028
- }
1029
-
1030
- /**
1031
- * Creates a clone of `dataView`.
1032
- *
1033
- * @private
1034
- * @param {Object} dataView The data view to clone.
1035
- * @param {boolean} [isDeep] Specify a deep clone.
1036
- * @returns {Object} Returns the cloned data view.
1037
- */
1038
- function cloneDataView(dataView, isDeep) {
1039
- var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
1040
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
1041
- }
1042
-
1043
- /**
1044
- * Creates a clone of `map`.
1045
- *
1046
- * @private
1047
- * @param {Object} map The map to clone.
1048
- * @param {Function} cloneFunc The function to clone values.
1049
- * @param {boolean} [isDeep] Specify a deep clone.
1050
- * @returns {Object} Returns the cloned map.
1051
- */
1052
- function cloneMap(map, isDeep, cloneFunc) {
1053
- var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
1054
- return arrayReduce(array, addMapEntry, new map.constructor);
1055
- }
1056
-
1057
- /**
1058
- * Creates a clone of `regexp`.
1059
- *
1060
- * @private
1061
- * @param {Object} regexp The regexp to clone.
1062
- * @returns {Object} Returns the cloned regexp.
1063
- */
1064
- function cloneRegExp(regexp) {
1065
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
1066
- result.lastIndex = regexp.lastIndex;
1067
- return result;
1068
- }
1069
-
1070
- /**
1071
- * Creates a clone of `set`.
1072
- *
1073
- * @private
1074
- * @param {Object} set The set to clone.
1075
- * @param {Function} cloneFunc The function to clone values.
1076
- * @param {boolean} [isDeep] Specify a deep clone.
1077
- * @returns {Object} Returns the cloned set.
1078
- */
1079
- function cloneSet(set, isDeep, cloneFunc) {
1080
- var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
1081
- return arrayReduce(array, addSetEntry, new set.constructor);
1082
- }
1083
-
1084
- /**
1085
- * Creates a clone of the `symbol` object.
1086
- *
1087
- * @private
1088
- * @param {Object} symbol The symbol object to clone.
1089
- * @returns {Object} Returns the cloned symbol object.
1090
- */
1091
- function cloneSymbol(symbol) {
1092
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
1093
- }
1094
-
1095
- /**
1096
- * Creates a clone of `typedArray`.
1097
- *
1098
- * @private
1099
- * @param {Object} typedArray The typed array to clone.
1100
- * @param {boolean} [isDeep] Specify a deep clone.
1101
- * @returns {Object} Returns the cloned typed array.
1102
- */
1103
- function cloneTypedArray(typedArray, isDeep) {
1104
- var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1105
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1106
- }
1107
-
1108
- /**
1109
- * Copies the values of `source` to `array`.
1110
- *
1111
- * @private
1112
- * @param {Array} source The array to copy values from.
1113
- * @param {Array} [array=[]] The array to copy values to.
1114
- * @returns {Array} Returns `array`.
1115
- */
1116
- function copyArray(source, array) {
1117
- var index = -1,
1118
- length = source.length;
1119
-
1120
- array || (array = Array(length));
1121
- while (++index < length) {
1122
- array[index] = source[index];
1123
- }
1124
- return array;
1125
- }
1126
-
1127
- /**
1128
- * Copies properties of `source` to `object`.
1129
- *
1130
- * @private
1131
- * @param {Object} source The object to copy properties from.
1132
- * @param {Array} props The property identifiers to copy.
1133
- * @param {Object} [object={}] The object to copy properties to.
1134
- * @param {Function} [customizer] The function to customize copied values.
1135
- * @returns {Object} Returns `object`.
1136
- */
1137
- function copyObject(source, props, object, customizer) {
1138
- object || (object = {});
1139
-
1140
- var index = -1,
1141
- length = props.length;
1142
-
1143
- while (++index < length) {
1144
- var key = props[index];
1145
-
1146
- var newValue = customizer
1147
- ? customizer(object[key], source[key], key, object, source)
1148
- : undefined;
1149
-
1150
- assignValue(object, key, newValue === undefined ? source[key] : newValue);
1151
- }
1152
- return object;
1153
- }
1154
-
1155
- /**
1156
- * Copies own symbol properties of `source` to `object`.
1157
- *
1158
- * @private
1159
- * @param {Object} source The object to copy symbols from.
1160
- * @param {Object} [object={}] The object to copy symbols to.
1161
- * @returns {Object} Returns `object`.
1162
- */
1163
- function copySymbols(source, object) {
1164
- return copyObject(source, getSymbols(source), object);
1165
- }
1166
-
1167
- /**
1168
- * Creates an array of own enumerable property names and symbols of `object`.
1169
- *
1170
- * @private
1171
- * @param {Object} object The object to query.
1172
- * @returns {Array} Returns the array of property names and symbols.
1173
- */
1174
- function getAllKeys(object) {
1175
- return baseGetAllKeys(object, keys, getSymbols);
1176
- }
1177
-
1178
- /**
1179
- * Gets the data for `map`.
1180
- *
1181
- * @private
1182
- * @param {Object} map The map to query.
1183
- * @param {string} key The reference key.
1184
- * @returns {*} Returns the map data.
1185
- */
1186
- function getMapData(map, key) {
1187
- var data = map.__data__;
1188
- return isKeyable(key)
1189
- ? data[typeof key == 'string' ? 'string' : 'hash']
1190
- : data.map;
1191
- }
1192
-
1193
- /**
1194
- * Gets the native function at `key` of `object`.
1195
- *
1196
- * @private
1197
- * @param {Object} object The object to query.
1198
- * @param {string} key The key of the method to get.
1199
- * @returns {*} Returns the function if it's native, else `undefined`.
1200
- */
1201
- function getNative(object, key) {
1202
- var value = getValue(object, key);
1203
- return baseIsNative(value) ? value : undefined;
1204
- }
1205
-
1206
- /**
1207
- * Creates an array of the own enumerable symbol properties of `object`.
1208
- *
1209
- * @private
1210
- * @param {Object} object The object to query.
1211
- * @returns {Array} Returns the array of symbols.
1212
- */
1213
- var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
1214
-
1215
- /**
1216
- * Gets the `toStringTag` of `value`.
1217
- *
1218
- * @private
1219
- * @param {*} value The value to query.
1220
- * @returns {string} Returns the `toStringTag`.
1221
- */
1222
- var getTag = baseGetTag;
1223
-
1224
- // Fallback for data views, maps, sets, and weak maps in IE 11,
1225
- // for data views in Edge < 14, and promises in Node.js.
1226
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1227
- (Map && getTag(new Map) != mapTag) ||
1228
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
1229
- (Set && getTag(new Set) != setTag) ||
1230
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1231
- getTag = function(value) {
1232
- var result = objectToString.call(value),
1233
- Ctor = result == objectTag ? value.constructor : undefined,
1234
- ctorString = Ctor ? toSource(Ctor) : undefined;
1235
-
1236
- if (ctorString) {
1237
- switch (ctorString) {
1238
- case dataViewCtorString: return dataViewTag;
1239
- case mapCtorString: return mapTag;
1240
- case promiseCtorString: return promiseTag;
1241
- case setCtorString: return setTag;
1242
- case weakMapCtorString: return weakMapTag;
1243
- }
1244
- }
1245
- return result;
1246
- };
1247
- }
1248
-
1249
- /**
1250
- * Initializes an array clone.
1251
- *
1252
- * @private
1253
- * @param {Array} array The array to clone.
1254
- * @returns {Array} Returns the initialized clone.
1255
- */
1256
- function initCloneArray(array) {
1257
- var length = array.length,
1258
- result = array.constructor(length);
1259
-
1260
- // Add properties assigned by `RegExp#exec`.
1261
- if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
1262
- result.index = array.index;
1263
- result.input = array.input;
1264
- }
1265
- return result;
1266
- }
1267
-
1268
- /**
1269
- * Initializes an object clone.
1270
- *
1271
- * @private
1272
- * @param {Object} object The object to clone.
1273
- * @returns {Object} Returns the initialized clone.
1274
- */
1275
- function initCloneObject(object) {
1276
- return (typeof object.constructor == 'function' && !isPrototype(object))
1277
- ? baseCreate(getPrototype(object))
1278
- : {};
1279
- }
1280
-
1281
- /**
1282
- * Initializes an object clone based on its `toStringTag`.
1283
- *
1284
- * **Note:** This function only supports cloning values with tags of
1285
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1286
- *
1287
- * @private
1288
- * @param {Object} object The object to clone.
1289
- * @param {string} tag The `toStringTag` of the object to clone.
1290
- * @param {Function} cloneFunc The function to clone values.
1291
- * @param {boolean} [isDeep] Specify a deep clone.
1292
- * @returns {Object} Returns the initialized clone.
1293
- */
1294
- function initCloneByTag(object, tag, cloneFunc, isDeep) {
1295
- var Ctor = object.constructor;
1296
- switch (tag) {
1297
- case arrayBufferTag:
1298
- return cloneArrayBuffer(object);
1299
-
1300
- case boolTag:
1301
- case dateTag:
1302
- return new Ctor(+object);
1303
-
1304
- case dataViewTag:
1305
- return cloneDataView(object, isDeep);
1306
-
1307
- case float32Tag: case float64Tag:
1308
- case int8Tag: case int16Tag: case int32Tag:
1309
- case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
1310
- return cloneTypedArray(object, isDeep);
1311
-
1312
- case mapTag:
1313
- return cloneMap(object, isDeep, cloneFunc);
1314
-
1315
- case numberTag:
1316
- case stringTag:
1317
- return new Ctor(object);
1318
-
1319
- case regexpTag:
1320
- return cloneRegExp(object);
1321
-
1322
- case setTag:
1323
- return cloneSet(object, isDeep, cloneFunc);
1324
-
1325
- case symbolTag:
1326
- return cloneSymbol(object);
1327
- }
1328
- }
1329
-
1330
- /**
1331
- * Checks if `value` is a valid array-like index.
1332
- *
1333
- * @private
1334
- * @param {*} value The value to check.
1335
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1336
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1337
- */
1338
- function isIndex(value, length) {
1339
- length = length == null ? MAX_SAFE_INTEGER : length;
1340
- return !!length &&
1341
- (typeof value == 'number' || reIsUint.test(value)) &&
1342
- (value > -1 && value % 1 == 0 && value < length);
1343
- }
1344
-
1345
- /**
1346
- * Checks if `value` is suitable for use as unique object key.
1347
- *
1348
- * @private
1349
- * @param {*} value The value to check.
1350
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1351
- */
1352
- function isKeyable(value) {
1353
- var type = typeof value;
1354
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1355
- ? (value !== '__proto__')
1356
- : (value === null);
1357
- }
1358
-
1359
- /**
1360
- * Checks if `func` has its source masked.
1361
- *
1362
- * @private
1363
- * @param {Function} func The function to check.
1364
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1365
- */
1366
- function isMasked(func) {
1367
- return !!maskSrcKey && (maskSrcKey in func);
1368
- }
1369
-
1370
- /**
1371
- * Checks if `value` is likely a prototype object.
1372
- *
1373
- * @private
1374
- * @param {*} value The value to check.
1375
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1376
- */
1377
- function isPrototype(value) {
1378
- var Ctor = value && value.constructor,
1379
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1380
-
1381
- return value === proto;
1382
- }
1383
-
1384
- /**
1385
- * Converts `func` to its source code.
1386
- *
1387
- * @private
1388
- * @param {Function} func The function to process.
1389
- * @returns {string} Returns the source code.
1390
- */
1391
- function toSource(func) {
1392
- if (func != null) {
1393
- try {
1394
- return funcToString.call(func);
1395
- } catch (e) {}
1396
- try {
1397
- return (func + '');
1398
- } catch (e) {}
1399
- }
1400
- return '';
1401
- }
1402
-
1403
- /**
1404
- * This method is like `_.clone` except that it recursively clones `value`.
1405
- *
1406
- * @static
1407
- * @memberOf _
1408
- * @since 1.0.0
1409
- * @category Lang
1410
- * @param {*} value The value to recursively clone.
1411
- * @returns {*} Returns the deep cloned value.
1412
- * @see _.clone
1413
- * @example
1414
- *
1415
- * var objects = [{ 'a': 1 }, { 'b': 2 }];
1416
- *
1417
- * var deep = _.cloneDeep(objects);
1418
- * console.log(deep[0] === objects[0]);
1419
- * // => false
1420
- */
1421
- function cloneDeep(value) {
1422
- return baseClone(value, true, true);
1423
- }
1424
-
1425
- /**
1426
- * Performs a
1427
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1428
- * comparison between two values to determine if they are equivalent.
1429
- *
1430
- * @static
1431
- * @memberOf _
1432
- * @since 4.0.0
1433
- * @category Lang
1434
- * @param {*} value The value to compare.
1435
- * @param {*} other The other value to compare.
1436
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1437
- * @example
1438
- *
1439
- * var object = { 'a': 1 };
1440
- * var other = { 'a': 1 };
1441
- *
1442
- * _.eq(object, object);
1443
- * // => true
1444
- *
1445
- * _.eq(object, other);
1446
- * // => false
1447
- *
1448
- * _.eq('a', 'a');
1449
- * // => true
1450
- *
1451
- * _.eq('a', Object('a'));
1452
- * // => false
1453
- *
1454
- * _.eq(NaN, NaN);
1455
- * // => true
1456
- */
1457
- function eq(value, other) {
1458
- return value === other || (value !== value && other !== other);
1459
- }
1460
-
1461
- /**
1462
- * Checks if `value` is likely an `arguments` object.
1463
- *
1464
- * @static
1465
- * @memberOf _
1466
- * @since 0.1.0
1467
- * @category Lang
1468
- * @param {*} value The value to check.
1469
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1470
- * else `false`.
1471
- * @example
1472
- *
1473
- * _.isArguments(function() { return arguments; }());
1474
- * // => true
1475
- *
1476
- * _.isArguments([1, 2, 3]);
1477
- * // => false
1478
- */
1479
- function isArguments(value) {
1480
- // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1481
- return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
1482
- (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
1483
- }
1484
-
1485
- /**
1486
- * Checks if `value` is classified as an `Array` object.
1487
- *
1488
- * @static
1489
- * @memberOf _
1490
- * @since 0.1.0
1491
- * @category Lang
1492
- * @param {*} value The value to check.
1493
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1494
- * @example
1495
- *
1496
- * _.isArray([1, 2, 3]);
1497
- * // => true
1498
- *
1499
- * _.isArray(document.body.children);
1500
- * // => false
1501
- *
1502
- * _.isArray('abc');
1503
- * // => false
1504
- *
1505
- * _.isArray(_.noop);
1506
- * // => false
1507
- */
1508
- var isArray = Array.isArray;
1509
-
1510
- /**
1511
- * Checks if `value` is array-like. A value is considered array-like if it's
1512
- * not a function and has a `value.length` that's an integer greater than or
1513
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1514
- *
1515
- * @static
1516
- * @memberOf _
1517
- * @since 4.0.0
1518
- * @category Lang
1519
- * @param {*} value The value to check.
1520
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1521
- * @example
1522
- *
1523
- * _.isArrayLike([1, 2, 3]);
1524
- * // => true
1525
- *
1526
- * _.isArrayLike(document.body.children);
1527
- * // => true
1528
- *
1529
- * _.isArrayLike('abc');
1530
- * // => true
1531
- *
1532
- * _.isArrayLike(_.noop);
1533
- * // => false
1534
- */
1535
- function isArrayLike(value) {
1536
- return value != null && isLength(value.length) && !isFunction(value);
1537
- }
1538
-
1539
- /**
1540
- * This method is like `_.isArrayLike` except that it also checks if `value`
1541
- * is an object.
1542
- *
1543
- * @static
1544
- * @memberOf _
1545
- * @since 4.0.0
1546
- * @category Lang
1547
- * @param {*} value The value to check.
1548
- * @returns {boolean} Returns `true` if `value` is an array-like object,
1549
- * else `false`.
1550
- * @example
1551
- *
1552
- * _.isArrayLikeObject([1, 2, 3]);
1553
- * // => true
1554
- *
1555
- * _.isArrayLikeObject(document.body.children);
1556
- * // => true
1557
- *
1558
- * _.isArrayLikeObject('abc');
1559
- * // => false
1560
- *
1561
- * _.isArrayLikeObject(_.noop);
1562
- * // => false
1563
- */
1564
- function isArrayLikeObject(value) {
1565
- return isObjectLike(value) && isArrayLike(value);
1566
- }
1567
-
1568
- /**
1569
- * Checks if `value` is a buffer.
1570
- *
1571
- * @static
1572
- * @memberOf _
1573
- * @since 4.3.0
1574
- * @category Lang
1575
- * @param {*} value The value to check.
1576
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1577
- * @example
1578
- *
1579
- * _.isBuffer(new Buffer(2));
1580
- * // => true
1581
- *
1582
- * _.isBuffer(new Uint8Array(2));
1583
- * // => false
1584
- */
1585
- var isBuffer = nativeIsBuffer || stubFalse;
1586
-
1587
- /**
1588
- * Checks if `value` is classified as a `Function` object.
1589
- *
1590
- * @static
1591
- * @memberOf _
1592
- * @since 0.1.0
1593
- * @category Lang
1594
- * @param {*} value The value to check.
1595
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1596
- * @example
1597
- *
1598
- * _.isFunction(_);
1599
- * // => true
1600
- *
1601
- * _.isFunction(/abc/);
1602
- * // => false
1603
- */
1604
- function isFunction(value) {
1605
- // The use of `Object#toString` avoids issues with the `typeof` operator
1606
- // in Safari 8-9 which returns 'object' for typed array and other constructors.
1607
- var tag = isObject(value) ? objectToString.call(value) : '';
1608
- return tag == funcTag || tag == genTag;
1609
- }
1610
-
1611
- /**
1612
- * Checks if `value` is a valid array-like length.
1613
- *
1614
- * **Note:** This method is loosely based on
1615
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1616
- *
1617
- * @static
1618
- * @memberOf _
1619
- * @since 4.0.0
1620
- * @category Lang
1621
- * @param {*} value The value to check.
1622
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1623
- * @example
1624
- *
1625
- * _.isLength(3);
1626
- * // => true
1627
- *
1628
- * _.isLength(Number.MIN_VALUE);
1629
- * // => false
1630
- *
1631
- * _.isLength(Infinity);
1632
- * // => false
1633
- *
1634
- * _.isLength('3');
1635
- * // => false
1636
- */
1637
- function isLength(value) {
1638
- return typeof value == 'number' &&
1639
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1640
- }
1641
-
1642
- /**
1643
- * Checks if `value` is the
1644
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1645
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1646
- *
1647
- * @static
1648
- * @memberOf _
1649
- * @since 0.1.0
1650
- * @category Lang
1651
- * @param {*} value The value to check.
1652
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1653
- * @example
1654
- *
1655
- * _.isObject({});
1656
- * // => true
1657
- *
1658
- * _.isObject([1, 2, 3]);
1659
- * // => true
1660
- *
1661
- * _.isObject(_.noop);
1662
- * // => true
1663
- *
1664
- * _.isObject(null);
1665
- * // => false
1666
- */
1667
- function isObject(value) {
1668
- var type = typeof value;
1669
- return !!value && (type == 'object' || type == 'function');
1670
- }
1671
-
1672
- /**
1673
- * Checks if `value` is object-like. A value is object-like if it's not `null`
1674
- * and has a `typeof` result of "object".
1675
- *
1676
- * @static
1677
- * @memberOf _
1678
- * @since 4.0.0
1679
- * @category Lang
1680
- * @param {*} value The value to check.
1681
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1682
- * @example
1683
- *
1684
- * _.isObjectLike({});
1685
- * // => true
1686
- *
1687
- * _.isObjectLike([1, 2, 3]);
1688
- * // => true
1689
- *
1690
- * _.isObjectLike(_.noop);
1691
- * // => false
1692
- *
1693
- * _.isObjectLike(null);
1694
- * // => false
1695
- */
1696
- function isObjectLike(value) {
1697
- return !!value && typeof value == 'object';
1698
- }
1699
-
1700
- /**
1701
- * Creates an array of the own enumerable property names of `object`.
1702
- *
1703
- * **Note:** Non-object values are coerced to objects. See the
1704
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1705
- * for more details.
1706
- *
1707
- * @static
1708
- * @since 0.1.0
1709
- * @memberOf _
1710
- * @category Object
1711
- * @param {Object} object The object to query.
1712
- * @returns {Array} Returns the array of property names.
1713
- * @example
1714
- *
1715
- * function Foo() {
1716
- * this.a = 1;
1717
- * this.b = 2;
1718
- * }
1719
- *
1720
- * Foo.prototype.c = 3;
1721
- *
1722
- * _.keys(new Foo);
1723
- * // => ['a', 'b'] (iteration order is not guaranteed)
1724
- *
1725
- * _.keys('hi');
1726
- * // => ['0', '1']
1727
- */
1728
- function keys(object) {
1729
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1730
- }
1731
-
1732
- /**
1733
- * This method returns a new empty array.
1734
- *
1735
- * @static
1736
- * @memberOf _
1737
- * @since 4.13.0
1738
- * @category Util
1739
- * @returns {Array} Returns the new empty array.
1740
- * @example
1741
- *
1742
- * var arrays = _.times(2, _.stubArray);
1743
- *
1744
- * console.log(arrays);
1745
- * // => [[], []]
1746
- *
1747
- * console.log(arrays[0] === arrays[1]);
1748
- * // => false
1749
- */
1750
- function stubArray() {
1751
- return [];
1752
- }
1753
-
1754
- /**
1755
- * This method returns `false`.
1756
- *
1757
- * @static
1758
- * @memberOf _
1759
- * @since 4.13.0
1760
- * @category Util
1761
- * @returns {boolean} Returns `false`.
1762
- * @example
1763
- *
1764
- * _.times(2, _.stubFalse);
1765
- * // => [false, false]
1766
- */
1767
- function stubFalse() {
1768
- return false;
1769
- }
1770
-
1771
- module.exports = cloneDeep;
1772
- });
1773
-
1774
- /**
1775
- * @name str-indexes-of-plus
1776
- * @fileoverview Like indexOf but returns array and counts per-grapheme
1777
- * @version 3.0.16
1778
- * @author Roy Revelt, Codsen Ltd
1779
- * @license MIT
1780
- * {@link https://codsen.com/os/str-indexes-of-plus/}
1781
- */
1782
- function strIndexesOfPlus(str, searchValue, fromIndex = 0) {
1783
- if (typeof str !== "string") {
1784
- throw new TypeError(`str-indexes-of-plus/strIndexesOfPlus(): first input argument must be a string! Currently it's: ${typeof str}`);
1785
- }
1786
- if (typeof searchValue !== "string") {
1787
- throw new TypeError(`str-indexes-of-plus/strIndexesOfPlus(): second input argument must be a string! Currently it's: ${typeof searchValue}`);
1788
- }
1789
- if (isNaN(+fromIndex) || typeof fromIndex === "string" && !/^\d*$/.test(fromIndex)) {
1790
- throw new TypeError(`str-indexes-of-plus/strIndexesOfPlus(): third input argument must be a natural number! Currently it's: ${fromIndex}`);
1791
- }
1792
- const strArr = Array.from(str);
1793
- const searchValueArr = Array.from(searchValue);
1794
- if (strArr.length === 0 || searchValueArr.length === 0 || fromIndex != null && +fromIndex >= strArr.length) {
1795
- return [];
1796
- }
1797
- if (!fromIndex) {
1798
- fromIndex = 0;
1799
- }
1800
- const res = [];
1801
- let matchMode = false;
1802
- let potentialFinding;
1803
- for (let i = fromIndex, len = strArr.length; i < len; i++) {
1804
- if (matchMode) {
1805
- if (strArr[i] === searchValueArr[i - +potentialFinding]) {
1806
- if (i - +potentialFinding + 1 === searchValueArr.length) {
1807
- res.push(+potentialFinding);
1808
- }
1809
- } else {
1810
- potentialFinding = null;
1811
- matchMode = false;
1812
- }
1813
- }
1814
- if (!matchMode) {
1815
- if (strArr[i] === searchValueArr[0]) {
1816
- if (searchValueArr.length === 1) {
1817
- res.push(i);
1818
- } else {
1819
- matchMode = true;
1820
- potentialFinding = i;
1821
- }
1822
- }
1823
- }
1824
- }
1825
- return res;
1826
- }
1827
-
1828
- var escapeStringRegexp = string => {
1829
- if (typeof string !== 'string') {
1830
- throw new TypeError('Expected a string');
1831
- }
1832
-
1833
- // Escape characters with special meaning either inside or outside character sets.
1834
- // 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.
1835
- return string
1836
- .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
1837
- .replace(/-/g, '\\x2d');
1838
- };
1839
-
1840
- const regexpCache = new Map();
1841
-
1842
- function sanitizeArray(input, inputName) {
1843
- if (!Array.isArray(input)) {
1844
- switch (typeof input) {
1845
- case 'string':
1846
- input = [input];
1847
- break;
1848
- case 'undefined':
1849
- input = [];
1850
- break;
1851
- default:
1852
- throw new TypeError(`Expected '${inputName}' to be a string or an array, but got a type of '${typeof input}'`);
1853
- }
1854
- }
1855
-
1856
- return input.filter(string => {
1857
- if (typeof string !== 'string') {
1858
- if (typeof string === 'undefined') {
1859
- return false;
1860
- }
1861
-
1862
- throw new TypeError(`Expected '${inputName}' to be an array of strings, but found a type of '${typeof string}' in the array`);
1863
- }
1864
-
1865
- return true;
1866
- });
1867
- }
1868
-
1869
- function makeRegexp(pattern, options) {
1870
- options = {
1871
- caseSensitive: false,
1872
- ...options
1873
- };
1874
-
1875
- const cacheKey = pattern + JSON.stringify(options);
1876
-
1877
- if (regexpCache.has(cacheKey)) {
1878
- return regexpCache.get(cacheKey);
1879
- }
1880
-
1881
- const negated = pattern[0] === '!';
1882
-
1883
- if (negated) {
1884
- pattern = pattern.slice(1);
1885
- }
1886
-
1887
- pattern = escapeStringRegexp(pattern).replace(/\\\*/g, '[\\s\\S]*');
1888
-
1889
- const regexp = new RegExp(`^${pattern}$`, options.caseSensitive ? '' : 'i');
1890
- regexp.negated = negated;
1891
- regexpCache.set(cacheKey, regexp);
1892
-
1893
- return regexp;
1894
- }
1895
-
1896
- var matcher = (inputs, patterns, options) => {
1897
- inputs = sanitizeArray(inputs, 'inputs');
1898
- patterns = sanitizeArray(patterns, 'patterns');
1899
-
1900
- if (patterns.length === 0) {
1901
- return [];
1902
- }
1903
-
1904
- const isFirstPatternNegated = patterns[0][0] === '!';
1905
-
1906
- patterns = patterns.map(pattern => makeRegexp(pattern, options));
1907
-
1908
- const result = [];
1909
-
1910
- for (const input of inputs) {
1911
- // If first pattern is negated we include everything to match user expectation.
1912
- let matches = isFirstPatternNegated;
1913
-
1914
- for (const pattern of patterns) {
1915
- if (pattern.test(input)) {
1916
- matches = !pattern.negated;
1917
- }
1918
- }
1919
-
1920
- if (matches) {
1921
- result.push(input);
1922
- }
1923
- }
1924
-
1925
- return result;
1926
- };
1927
-
1928
- var isMatch = (inputs, patterns, options) => {
1929
- inputs = sanitizeArray(inputs, 'inputs');
1930
- patterns = sanitizeArray(patterns, 'patterns');
1931
-
1932
- if (patterns.length === 0) {
1933
- return false;
1934
- }
1935
-
1936
- return inputs.some(input => {
1937
- return patterns.every(pattern => {
1938
- const regexp = makeRegexp(pattern, options);
1939
- const matches = regexp.test(input);
1940
- return regexp.negated ? !matches : matches;
1941
- });
1942
- });
1943
- };
1944
- matcher.isMatch = isMatch;
1945
-
1946
- /**
1947
- * lodash (Custom Build) <https://lodash.com/>
1948
- * Build: `lodash modularize exports="npm" -o ./`
1949
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
1950
- * Released under MIT license <https://lodash.com/license>
1951
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1952
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1953
- */
1954
- /** `Object#toString` result references. */
1955
- var objectTag = '[object Object]';
1956
-
1957
- /**
1958
- * Checks if `value` is a host object in IE < 9.
1959
- *
1960
- * @private
1961
- * @param {*} value The value to check.
1962
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
1963
- */
1964
- function isHostObject(value) {
1965
- // Many host objects are `Object` objects that can coerce to strings
1966
- // despite having improperly defined `toString` methods.
1967
- var result = false;
1968
- if (value != null && typeof value.toString != 'function') {
1969
- try {
1970
- result = !!(value + '');
1971
- } catch (e) {}
1972
- }
1973
- return result;
1974
- }
1975
-
1976
- /**
1977
- * Creates a unary function that invokes `func` with its argument transformed.
1978
- *
1979
- * @private
1980
- * @param {Function} func The function to wrap.
1981
- * @param {Function} transform The argument transform.
1982
- * @returns {Function} Returns the new function.
1983
- */
1984
- function overArg(func, transform) {
1985
- return function(arg) {
1986
- return func(transform(arg));
1987
- };
1988
- }
1989
-
1990
- /** Used for built-in method references. */
1991
- var funcProto = Function.prototype,
1992
- objectProto = Object.prototype;
1993
-
1994
- /** Used to resolve the decompiled source of functions. */
1995
- var funcToString = funcProto.toString;
1996
-
1997
- /** Used to check objects for own properties. */
1998
- var hasOwnProperty = objectProto.hasOwnProperty;
1999
-
2000
- /** Used to infer the `Object` constructor. */
2001
- var objectCtorString = funcToString.call(Object);
2002
-
2003
- /**
2004
- * Used to resolve the
2005
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2006
- * of values.
2007
- */
2008
- var objectToString = objectProto.toString;
2009
-
2010
- /** Built-in value references. */
2011
- var getPrototype = overArg(Object.getPrototypeOf, Object);
2012
-
2013
- /**
2014
- * Checks if `value` is object-like. A value is object-like if it's not `null`
2015
- * and has a `typeof` result of "object".
2016
- *
2017
- * @static
2018
- * @memberOf _
2019
- * @since 4.0.0
2020
- * @category Lang
2021
- * @param {*} value The value to check.
2022
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2023
- * @example
2024
- *
2025
- * _.isObjectLike({});
2026
- * // => true
2027
- *
2028
- * _.isObjectLike([1, 2, 3]);
2029
- * // => true
2030
- *
2031
- * _.isObjectLike(_.noop);
2032
- * // => false
2033
- *
2034
- * _.isObjectLike(null);
2035
- * // => false
2036
- */
2037
- function isObjectLike(value) {
2038
- return !!value && typeof value == 'object';
2039
- }
2040
-
2041
- /**
2042
- * Checks if `value` is a plain object, that is, an object created by the
2043
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
2044
- *
2045
- * @static
2046
- * @memberOf _
2047
- * @since 0.8.0
2048
- * @category Lang
2049
- * @param {*} value The value to check.
2050
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
2051
- * @example
2052
- *
2053
- * function Foo() {
2054
- * this.a = 1;
2055
- * }
2056
- *
2057
- * _.isPlainObject(new Foo);
2058
- * // => false
2059
- *
2060
- * _.isPlainObject([1, 2, 3]);
2061
- * // => false
2062
- *
2063
- * _.isPlainObject({ 'x': 0, 'y': 0 });
2064
- * // => true
2065
- *
2066
- * _.isPlainObject(Object.create(null));
2067
- * // => true
2068
- */
2069
- function isPlainObject(value) {
2070
- if (!isObjectLike(value) ||
2071
- objectToString.call(value) != objectTag || isHostObject(value)) {
2072
- return false;
2073
- }
2074
- var proto = getPrototype(value);
2075
- if (proto === null) {
2076
- return true;
2077
- }
2078
- var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
2079
- return (typeof Ctor == 'function' &&
2080
- Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
2081
- }
2082
-
2083
- var lodash_isplainobject = isPlainObject;
2084
-
2085
- const defaults = {
2086
- wrapHeadsWith: "%%_",
2087
- wrapTailsWith: "_%%",
2088
- dontWrapKeys: [],
2089
- dontWrapPaths: [],
2090
- // paths exactly like for exampl: "modules[0].part2[0].ccc[0].kkk". Remember to
2091
- // put the index if it's an array, like modules[0] if key "modules" is equal to
2092
- // array and you want its first element (0-th index), hence "modules[0]".
2093
- xhtml: true,
2094
- preventDoubleWrapping: true,
2095
- preventWrappingIfContains: [],
2096
- objectKeyAndValueJoinChar: ".",
2097
- wrapGlobalFlipSwitch: true,
2098
- ignore: [],
2099
- whatToDoWhenReferenceIsMissing: 0,
2100
- // 1 = throw, 2 = flatten to string & wrap if wrapping feature is enabled
2101
- mergeArraysWithLineBreaks: true,
2102
- // add <br /> between the rows?
2103
- mergeWithoutTrailingBrIfLineContainsBr: true,
2104
- // don't add another, trailing-one
2105
- enforceStrictKeyset: true, // are you allowed to pass-in any unrecognised
2106
- // keys in an options object?
2107
- };
2108
- function isStr$1(something) {
2109
- return typeof something === "string";
2110
- }
2111
- function flattenObject(objOrig, originalOpts) {
2112
- const opts = { ...defaults, ...originalOpts };
2113
- if (arguments.length === 0 || Object.keys(objOrig).length === 0) {
2114
- return [];
2115
- }
2116
- const obj = lodash_clonedeep(objOrig);
2117
- let res = [];
2118
- if (lodash_isplainobject(obj)) {
2119
- Object.keys(obj).forEach((key) => {
2120
- if (lodash_isplainobject(obj[key])) {
2121
- obj[key] = flattenObject(obj[key], opts);
2122
- }
2123
- if (Array.isArray(obj[key])) {
2124
- res = res.concat(obj[key].map((el) => key + opts.objectKeyAndValueJoinChar + el));
2125
- }
2126
- if (isStr$1(obj[key])) {
2127
- res.push(key + opts.objectKeyAndValueJoinChar + obj[key]);
2128
- }
2129
- });
2130
- }
2131
- return res;
2132
- }
2133
- function flattenArr(arrOrig, originalOpts, wrap = false, joinArraysUsingBrs = false) {
2134
- const opts = { ...defaults, ...originalOpts };
2135
- if (arguments.length === 0 || arrOrig.length === 0) {
2136
- return "";
2137
- }
2138
- const arr = lodash_clonedeep(arrOrig);
2139
- let res = "";
2140
- if (arr.length > 0) {
2141
- if (joinArraysUsingBrs) {
2142
- for (let i = 0, len = arr.length; i < len; i++) {
2143
- if (isStr$1(arr[i])) {
2144
- let lineBreak;
2145
- lineBreak = "";
2146
- if (opts.mergeArraysWithLineBreaks &&
2147
- i > 0 &&
2148
- (!opts.mergeWithoutTrailingBrIfLineContainsBr ||
2149
- typeof arr[i - 1] !== "string" ||
2150
- (opts.mergeWithoutTrailingBrIfLineContainsBr &&
2151
- arr[i - 1] !== undefined &&
2152
- !arr[i - 1].toLowerCase().includes("<br")))) {
2153
- lineBreak = `<br${opts.xhtml ? " /" : ""}>`;
2154
- }
2155
- res +=
2156
- lineBreak +
2157
- (wrap ? opts.wrapHeadsWith : "") +
2158
- arr[i] +
2159
- (wrap ? opts.wrapTailsWith : "");
2160
- }
2161
- else if (Array.isArray(arr[i])) {
2162
- if (arr[i].length > 0 && arr[i].every(isStr$1)) {
2163
- let lineBreak = "";
2164
- if (opts.mergeArraysWithLineBreaks && res.length > 0) {
2165
- lineBreak = `<br${opts.xhtml ? " /" : ""}>`;
2166
- }
2167
- res = arr[i].reduce((acc, val, i2, arr2) => {
2168
- let trailingSpace = "";
2169
- if (i2 !== arr2.length - 1) {
2170
- trailingSpace = " ";
2171
- }
2172
- return (acc +
2173
- (i2 === 0 ? lineBreak : "") +
2174
- (wrap ? opts.wrapHeadsWith : "") +
2175
- val +
2176
- (wrap ? opts.wrapTailsWith : "") +
2177
- trailingSpace);
2178
- }, res);
2179
- }
2180
- }
2181
- }
2182
- }
2183
- else {
2184
- res = arr.reduce((acc, val, i, arr2) => {
2185
- let lineBreak = "";
2186
- if (opts.mergeArraysWithLineBreaks && i > 0) {
2187
- lineBreak = `<br${opts.xhtml ? " /" : ""}>`;
2188
- }
2189
- let trailingSpace = "";
2190
- if (i !== arr2.length - 1) {
2191
- trailingSpace = " ";
2192
- }
2193
- return (acc +
2194
- (i === 0 ? lineBreak : "") +
2195
- (wrap ? opts.wrapHeadsWith : "") +
2196
- val +
2197
- (wrap ? opts.wrapTailsWith : "") +
2198
- trailingSpace);
2199
- }, res);
2200
- }
2201
- }
2202
- return res;
2203
- }
2204
- function arrayiffyString(something) {
2205
- if (isStr$1(something)) {
2206
- if (something.length > 0) {
2207
- return [something];
2208
- }
2209
- return [];
2210
- }
2211
- return something;
2212
- }
2213
-
2214
- var version$1 = "5.0.16";
2215
-
2216
- /* eslint @typescript-eslint/explicit-module-boundary-types: 0 */
2217
- const version = version$1;
2218
- function existy(x) {
2219
- return x != null;
2220
- }
2221
- function isStr(something) {
2222
- return typeof something === "string";
2223
- }
2224
- function flattenReferencing(originalInput1, originalReference1, opts1) {
2225
- if (arguments.length === 0) {
2226
- throw new Error("object-flatten-referencing/ofr(): [THROW_ID_01] all inputs missing!");
2227
- }
2228
- if (arguments.length === 1) {
2229
- throw new Error("object-flatten-referencing/ofr(): [THROW_ID_02] reference object missing!");
2230
- }
2231
- if (existy(opts1) && !lodash_isplainobject(opts1)) {
2232
- throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_03] third input, options object must be a plain object. Currently it's: ${typeof opts1}`);
2233
- }
2234
- const originalOpts = { ...defaults, ...opts1 };
2235
- originalOpts.dontWrapKeys = arrayiffyString(originalOpts.dontWrapKeys);
2236
- originalOpts.preventWrappingIfContains = arrayiffyString(originalOpts.preventWrappingIfContains);
2237
- originalOpts.dontWrapPaths = arrayiffyString(originalOpts.dontWrapPaths);
2238
- originalOpts.ignore = arrayiffyString(originalOpts.ignore);
2239
- if (typeof originalOpts.whatToDoWhenReferenceIsMissing !== "number") {
2240
- originalOpts.whatToDoWhenReferenceIsMissing =
2241
- +originalOpts.whatToDoWhenReferenceIsMissing || 0;
2242
- }
2243
- function ofr(originalInput, originalReference, opts, wrap = true, joinArraysUsingBrs = true, currentRoot = "") {
2244
- // console.log(`\n\n* originalInput = ${JSON.stringify(originalInput, null, 4)}`)
2245
- // console.log(`* originalReference = ${JSON.stringify(originalReference, null, 4)}`)
2246
- let input = lodash_clonedeep(originalInput);
2247
- const reference = lodash_clonedeep(originalReference);
2248
- if (!opts.wrapGlobalFlipSwitch) {
2249
- wrap = false;
2250
- }
2251
- if (lodash_isplainobject(input)) {
2252
- Object.keys(input).forEach((key) => {
2253
- const currentPath = currentRoot + (currentRoot.length === 0 ? key : `.${key}`);
2254
- // console.log(`* currentPath = ${JSON.stringify(currentPath, null, 4)}\n\n`)
2255
- if (opts.ignore.length === 0 || !opts.ignore.includes(key)) {
2256
- if (opts.wrapGlobalFlipSwitch) {
2257
- wrap = true; // reset it for the new key.
2258
- if (opts.dontWrapKeys.length > 0) {
2259
- wrap =
2260
- wrap &&
2261
- !opts.dontWrapKeys.some((elem) => matcher.isMatch(key, elem, { caseSensitive: true }));
2262
- }
2263
- if (opts.dontWrapPaths.length > 0) {
2264
- wrap =
2265
- wrap &&
2266
- !opts.dontWrapPaths.some((elem) => elem === currentPath);
2267
- }
2268
- if (opts.preventWrappingIfContains.length > 0 &&
2269
- typeof input[key] === "string") {
2270
- wrap =
2271
- wrap &&
2272
- !opts.preventWrappingIfContains.some((elem) => input[key].includes(elem));
2273
- }
2274
- }
2275
- if (existy(reference[key]) ||
2276
- (!existy(reference[key]) &&
2277
- opts.whatToDoWhenReferenceIsMissing === 2)) {
2278
- if (Array.isArray(input[key])) {
2279
- if (opts.whatToDoWhenReferenceIsMissing === 2 ||
2280
- isStr(reference[key])) {
2281
- // reference is string
2282
- // that's array vs. string clash:
2283
- input[key] = flattenArr(input[key], opts, wrap, joinArraysUsingBrs);
2284
- }
2285
- else {
2286
- // reference is array as well
2287
- // that's array vs. array clash, for example
2288
- // so input[key] is array. Let's check, does it contain only strings, or
2289
- // do some elements contain array of strings? Because if so, those deeper-level
2290
- // arrays must be joined with spaces. Outermost arrays must be joined by BR's.
2291
- // We're talking about ['1111', '2222', '3333'] in:
2292
- // {
2293
- // k_key: 'k_val',
2294
- // l_key: 'l_val',
2295
- // m_key: [
2296
- // 'xxxx',
2297
- // ['1111', '2222', '3333'],
2298
- // 'yyyy',
2299
- // 'zzzz'
2300
- // ]
2301
- // }
2302
- //
2303
- // referencing above,
2304
- // ['1111', '2222', '3333'] should be joined by spaces.
2305
- // ['xxxx', [...], 'yyyy', 'zzzz'] should be joined by BR's
2306
- if (input[key].every((el) => typeof el === "string" || Array.isArray(el))) {
2307
- // check that those array elements contain only string elements:
2308
- let allOK = true;
2309
- input[key].forEach((oneOfElements) => {
2310
- // check that child arrays contain only string elements
2311
- if (Array.isArray(oneOfElements) &&
2312
- !oneOfElements.every(isStr)) {
2313
- allOK = false;
2314
- }
2315
- });
2316
- if (allOK) {
2317
- joinArraysUsingBrs = false;
2318
- }
2319
- }
2320
- input[key] = ofr(input[key], reference[key], opts, wrap, joinArraysUsingBrs, currentPath);
2321
- }
2322
- }
2323
- else if (lodash_isplainobject(input[key])) {
2324
- if (opts.whatToDoWhenReferenceIsMissing === 2 ||
2325
- isStr(reference[key])) {
2326
- input[key] = flattenArr(flattenObject(input[key], opts), opts, wrap, joinArraysUsingBrs);
2327
- }
2328
- else if (!wrap) {
2329
- // when calling recursively, the parent key might get
2330
- // identified (wrap=true) to be wrapped.
2331
- // however, that flag might get lost as its children will
2332
- // calculate the new "wrap" on its own keys, often turning off the wrap function.
2333
- // to prevent that, we flip the switch on the global wrap
2334
- // setting for all deeper child nodes.
2335
- // we also clone the options object so as not to mutate it.
2336
- input[key] = ofr(input[key], reference[key], { ...opts, wrapGlobalFlipSwitch: false }, wrap, joinArraysUsingBrs, currentPath);
2337
- }
2338
- else {
2339
- input[key] = ofr(input[key], reference[key], opts, wrap, joinArraysUsingBrs, currentPath);
2340
- }
2341
- }
2342
- else if (isStr(input[key])) {
2343
- input[key] = ofr(input[key], reference[key], opts, wrap, joinArraysUsingBrs, currentPath);
2344
- }
2345
- }
2346
- else if (typeof input[key] !== typeof reference[key]) {
2347
- if (opts.whatToDoWhenReferenceIsMissing === 1) {
2348
- throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_06] reference object does not have the key ${key} and we need it. TIP: Turn off throwing via opts.whatToDoWhenReferenceIsMissing.`);
2349
- }
2350
- // when opts.whatToDoWhenReferenceIsMissing === 2, library does nothing,
2351
- // so we simply let it slip through.
2352
- }
2353
- }
2354
- });
2355
- }
2356
- else if (Array.isArray(input)) {
2357
- if (Array.isArray(reference)) {
2358
- input.forEach((_el, i) => {
2359
- if (existy(input[i]) && existy(reference[i])) {
2360
- input[i] = ofr(input[i], reference[i], opts, wrap, joinArraysUsingBrs, `${currentRoot}[${i}]`);
2361
- }
2362
- else {
2363
- input[i] = ofr(input[i], reference[0], opts, wrap, joinArraysUsingBrs, `${currentRoot}[${i}]`);
2364
- }
2365
- });
2366
- }
2367
- else if (isStr(reference)) {
2368
- input = flattenArr(input, opts, wrap, joinArraysUsingBrs);
2369
- }
2370
- }
2371
- else if (isStr(input)) {
2372
- if (input.length > 0 && (opts.wrapHeadsWith || opts.wrapTailsWith)) {
2373
- if (!opts.preventDoubleWrapping ||
2374
- ((opts.wrapHeadsWith === "" ||
2375
- !strIndexesOfPlus(input, opts.wrapHeadsWith.trim()).length) &&
2376
- (opts.wrapTailsWith === "" ||
2377
- !strIndexesOfPlus(input, opts.wrapTailsWith.trim()).length))) {
2378
- input =
2379
- (wrap ? opts.wrapHeadsWith : "") +
2380
- input +
2381
- (wrap ? opts.wrapTailsWith : "");
2382
- }
2383
- }
2384
- }
2385
- return input;
2386
- }
2387
- return ofr(originalInput1, originalReference1, originalOpts);
2388
- }
2389
-
2390
- exports.arrayiffyString = arrayiffyString;
2391
- exports.defaults = defaults;
2392
- exports.flattenArr = flattenArr;
2393
- exports.flattenObject = flattenObject;
2394
- exports.flattenReferencing = flattenReferencing;
2395
- exports.version = version;
2396
-
2397
- Object.defineProperty(exports, '__esModule', { value: true });
2398
-
2399
- })));