immutable 5.0.3 → 5.1.1

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.
@@ -24,117 +24,162 @@
24
24
  */
25
25
  // Used for setting prototype methods that IE8 chokes on.
26
26
  var DELETE = 'delete';
27
-
28
27
  // Constants describing the size of trie nodes.
29
28
  var SHIFT = 5; // Resulted in best performance after ______?
30
29
  var SIZE = 1 << SHIFT;
31
30
  var MASK = SIZE - 1;
32
-
33
31
  // A consistent shared value representing "not set" which equals nothing other
34
32
  // than itself, and nothing that could be provided externally.
35
33
  var NOT_SET = {};
36
-
37
34
  // Boolean references, Rough equivalent of `bool &`.
38
35
  function MakeRef() {
39
- return { value: false };
36
+ return { value: false };
40
37
  }
41
-
42
38
  function SetRef(ref) {
43
- if (ref) {
44
- ref.value = true;
45
- }
39
+ if (ref) {
40
+ ref.value = true;
41
+ }
46
42
  }
47
-
48
43
  // A function which returns a value representing an "owner" for transient writes
49
44
  // to tries. The return value will only ever equal itself, and will not equal
50
45
  // the return of any subsequent call of this function.
51
- function OwnerID() {}
52
-
46
+ function OwnerID() { }
53
47
  function ensureSize(iter) {
54
- if (iter.size === undefined) {
55
- iter.size = iter.__iterate(returnTrue);
56
- }
57
- return iter.size;
48
+ // @ts-expect-error size should exists on Collection
49
+ if (iter.size === undefined) {
50
+ // @ts-expect-error size should exists on Collection, __iterate does exist on Collection
51
+ iter.size = iter.__iterate(returnTrue);
52
+ }
53
+ // @ts-expect-error size should exists on Collection
54
+ return iter.size;
58
55
  }
59
-
60
56
  function wrapIndex(iter, index) {
61
- // This implements "is array index" which the ECMAString spec defines as:
62
- //
63
- // A String property name P is an array index if and only if
64
- // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
65
- // to 2^32−1.
66
- //
67
- // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
68
- if (typeof index !== 'number') {
69
- var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
70
- if ('' + uint32Index !== index || uint32Index === 4294967295) {
71
- return NaN;
57
+ // This implements "is array index" which the ECMAString spec defines as:
58
+ //
59
+ // A String property name P is an array index if and only if
60
+ // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
61
+ // to 2^32−1.
62
+ //
63
+ // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
64
+ if (typeof index !== 'number') {
65
+ var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
66
+ if ('' + uint32Index !== index || uint32Index === 4294967295) {
67
+ return NaN;
68
+ }
69
+ index = uint32Index;
72
70
  }
73
- index = uint32Index;
74
- }
75
- return index < 0 ? ensureSize(iter) + index : index;
71
+ return index < 0 ? ensureSize(iter) + index : index;
76
72
  }
77
-
78
73
  function returnTrue() {
79
- return true;
74
+ return true;
80
75
  }
81
-
82
76
  function wholeSlice(begin, end, size) {
83
- return (
84
- ((begin === 0 && !isNeg(begin)) ||
85
- (size !== undefined && begin <= -size)) &&
86
- (end === undefined || (size !== undefined && end >= size))
87
- );
77
+ return (((begin === 0 && !isNeg(begin)) ||
78
+ (size !== undefined && begin <= -size)) &&
79
+ (end === undefined || (size !== undefined && end >= size)));
88
80
  }
89
-
90
81
  function resolveBegin(begin, size) {
91
- return resolveIndex(begin, size, 0);
82
+ return resolveIndex(begin, size, 0);
92
83
  }
93
-
94
84
  function resolveEnd(end, size) {
95
- return resolveIndex(end, size, size);
85
+ return resolveIndex(end, size, size);
96
86
  }
97
-
98
87
  function resolveIndex(index, size, defaultIndex) {
99
- // Sanitize indices using this shorthand for ToInt32(argument)
100
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
101
- return index === undefined
102
- ? defaultIndex
103
- : isNeg(index)
104
- ? size === Infinity
105
- ? size
106
- : Math.max(0, size + index) | 0
107
- : size === undefined || size === index
108
- ? index
109
- : Math.min(size, index) | 0;
88
+ // Sanitize indices using this shorthand for ToInt32(argument)
89
+ // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
90
+ return index === undefined
91
+ ? defaultIndex
92
+ : isNeg(index)
93
+ ? size === Infinity
94
+ ? size
95
+ : Math.max(0, size + index) | 0
96
+ : size === undefined || size === index
97
+ ? index
98
+ : Math.min(size, index) | 0;
110
99
  }
111
-
112
100
  function isNeg(value) {
113
- // Account for -0 which is negative, but not less than 0.
114
- return value < 0 || (value === 0 && 1 / value === -Infinity);
101
+ // Account for -0 which is negative, but not less than 0.
102
+ return value < 0 || (value === 0 && 1 / value === -Infinity);
115
103
  }
116
104
 
117
105
  // Note: value is unchanged to not break immutable-devtools.
118
106
  var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
119
-
107
+ /**
108
+ * True if `maybeCollection` is a Collection, or any of its subclasses.
109
+ *
110
+ * ```js
111
+ * import { isCollection, Map, List, Stack } from 'immutable';
112
+ *
113
+ * isCollection([]); // false
114
+ * isCollection({}); // false
115
+ * isCollection(Map()); // true
116
+ * isCollection(List()); // true
117
+ * isCollection(Stack()); // true
118
+ * ```
119
+ */
120
120
  function isCollection(maybeCollection) {
121
- return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
121
+ return Boolean(maybeCollection &&
122
+ // @ts-expect-error: maybeCollection is typed as `{}`, need to change in 6.0 to `maybeCollection && typeof maybeCollection === 'object' && IS_COLLECTION_SYMBOL in maybeCollection`
123
+ maybeCollection[IS_COLLECTION_SYMBOL]);
122
124
  }
123
125
 
124
126
  var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';
125
-
127
+ /**
128
+ * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses.
129
+ *
130
+ * ```js
131
+ * import { isKeyed, Map, List, Stack } from 'immutable';
132
+ *
133
+ * isKeyed([]); // false
134
+ * isKeyed({}); // false
135
+ * isKeyed(Map()); // true
136
+ * isKeyed(List()); // false
137
+ * isKeyed(Stack()); // false
138
+ * ```
139
+ */
126
140
  function isKeyed(maybeKeyed) {
127
- return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
141
+ return Boolean(maybeKeyed &&
142
+ // @ts-expect-error: maybeKeyed is typed as `{}`, need to change in 6.0 to `maybeKeyed && typeof maybeKeyed === 'object' && IS_KEYED_SYMBOL in maybeKeyed`
143
+ maybeKeyed[IS_KEYED_SYMBOL]);
128
144
  }
129
145
 
130
146
  var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';
131
-
147
+ /**
148
+ * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses.
149
+ *
150
+ * ```js
151
+ * import { isIndexed, Map, List, Stack, Set } from 'immutable';
152
+ *
153
+ * isIndexed([]); // false
154
+ * isIndexed({}); // false
155
+ * isIndexed(Map()); // false
156
+ * isIndexed(List()); // true
157
+ * isIndexed(Stack()); // true
158
+ * isIndexed(Set()); // false
159
+ * ```
160
+ */
132
161
  function isIndexed(maybeIndexed) {
133
- return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
162
+ return Boolean(maybeIndexed &&
163
+ // @ts-expect-error: maybeIndexed is typed as `{}`, need to change in 6.0 to `maybeIndexed && typeof maybeIndexed === 'object' && IS_INDEXED_SYMBOL in maybeIndexed`
164
+ maybeIndexed[IS_INDEXED_SYMBOL]);
134
165
  }
135
166
 
167
+ /**
168
+ * True if `maybeAssociative` is either a Keyed or Indexed Collection.
169
+ *
170
+ * ```js
171
+ * import { isAssociative, Map, List, Stack, Set } from 'immutable';
172
+ *
173
+ * isAssociative([]); // false
174
+ * isAssociative({}); // false
175
+ * isAssociative(Map()); // true
176
+ * isAssociative(List()); // true
177
+ * isAssociative(Stack()); // true
178
+ * isAssociative(Set()); // false
179
+ * ```
180
+ */
136
181
  function isAssociative(maybeAssociative) {
137
- return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
182
+ return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
138
183
  }
139
184
 
140
185
  var Collection = function Collection(value) {
@@ -186,25 +231,49 @@ Collection.Indexed = IndexedCollection;
186
231
  Collection.Set = SetCollection;
187
232
 
188
233
  var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';
189
-
234
+ /**
235
+ * True if `maybeSeq` is a Seq.
236
+ */
190
237
  function isSeq(maybeSeq) {
191
- return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
238
+ return Boolean(maybeSeq &&
239
+ // @ts-expect-error: maybeSeq is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSeq === 'object' && MAYBE_SEQ_SYMBOL in maybeSeq`
240
+ maybeSeq[IS_SEQ_SYMBOL]);
192
241
  }
193
242
 
194
243
  var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
195
-
244
+ /**
245
+ * True if `maybeRecord` is a Record.
246
+ */
196
247
  function isRecord(maybeRecord) {
197
- return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
248
+ return Boolean(maybeRecord &&
249
+ // @ts-expect-error: maybeRecord is typed as `{}`, need to change in 6.0 to `maybeRecord && typeof maybeRecord === 'object' && IS_RECORD_SYMBOL in maybeRecord`
250
+ maybeRecord[IS_RECORD_SYMBOL]);
198
251
  }
199
252
 
253
+ /**
254
+ * True if `maybeImmutable` is an Immutable Collection or Record.
255
+ *
256
+ * Note: Still returns true even if the collections is within a `withMutations()`.
257
+ *
258
+ * ```js
259
+ * import { isImmutable, Map, List, Stack } from 'immutable';
260
+ * isImmutable([]); // false
261
+ * isImmutable({}); // false
262
+ * isImmutable(Map()); // true
263
+ * isImmutable(List()); // true
264
+ * isImmutable(Stack()); // true
265
+ * isImmutable(Map().asMutable()); // true
266
+ * ```
267
+ */
200
268
  function isImmutable(maybeImmutable) {
201
- return isCollection(maybeImmutable) || isRecord(maybeImmutable);
269
+ return isCollection(maybeImmutable) || isRecord(maybeImmutable);
202
270
  }
203
271
 
204
272
  var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';
205
-
206
273
  function isOrdered(maybeOrdered) {
207
- return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
274
+ return Boolean(maybeOrdered &&
275
+ // @ts-expect-error: maybeOrdered is typed as `{}`, need to change in 6.0 to `maybeOrdered && typeof maybeOrdered === 'object' && IS_ORDERED_SYMBOL in maybeOrdered`
276
+ maybeOrdered[IS_ORDERED_SYMBOL]);
208
277
  }
209
278
 
210
279
  var ITERATE_KEYS = 0;
@@ -236,7 +305,9 @@ Iterator.prototype[ITERATOR_SYMBOL] = function () {
236
305
  };
237
306
 
238
307
  function iteratorValue(type, k, v, iteratorResult) {
239
- var value = type === 0 ? k : type === 1 ? v : [k, v];
308
+ var value =
309
+ type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v];
310
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
240
311
  iteratorResult
241
312
  ? (iteratorResult.value = value)
242
313
  : (iteratorResult = {
@@ -291,22 +362,24 @@ function isKeysIterable(maybeIterable) {
291
362
  var hasOwnProperty = Object.prototype.hasOwnProperty;
292
363
 
293
364
  function isArrayLike(value) {
294
- if (Array.isArray(value) || typeof value === 'string') {
295
- return true;
296
- }
297
-
298
- return (
299
- value &&
300
- typeof value === 'object' &&
301
- Number.isInteger(value.length) &&
302
- value.length >= 0 &&
303
- (value.length === 0
304
- ? // Only {length: 0} is considered Array-like.
305
- Object.keys(value).length === 1
306
- : // An object is only Array-like if it has a property where the last value
307
- // in the array-like may be found (which could be undefined).
308
- value.hasOwnProperty(value.length - 1))
309
- );
365
+ if (Array.isArray(value) || typeof value === 'string') {
366
+ return true;
367
+ }
368
+ // @ts-expect-error "Type 'unknown' is not assignable to type 'boolean'" : convert to Boolean
369
+ return (value &&
370
+ typeof value === 'object' &&
371
+ // @ts-expect-error check that `'length' in value &&`
372
+ Number.isInteger(value.length) &&
373
+ // @ts-expect-error check that `'length' in value &&`
374
+ value.length >= 0 &&
375
+ // @ts-expect-error check that `'length' in value &&`
376
+ (value.length === 0
377
+ ? // Only {length: 0} is considered Array-like.
378
+ Object.keys(value).length === 1
379
+ : // An object is only Array-like if it has a property where the last value
380
+ // in the array-like may be found (which could be undefined).
381
+ // @ts-expect-error check that `'length' in value &&`
382
+ value.hasOwnProperty(value.length - 1)));
310
383
  }
311
384
 
312
385
  var Seq = /*@__PURE__*/(function (Collection) {
@@ -315,8 +388,8 @@ var Seq = /*@__PURE__*/(function (Collection) {
315
388
  return value === undefined || value === null
316
389
  ? emptySequence()
317
390
  : isImmutable(value)
318
- ? value.toSeq()
319
- : seqFromValue(value);
391
+ ? value.toSeq()
392
+ : seqFromValue(value);
320
393
  }
321
394
 
322
395
  if ( Collection ) Seq.__proto__ = Collection;
@@ -384,12 +457,12 @@ var KeyedSeq = /*@__PURE__*/(function (Seq) {
384
457
  return value === undefined || value === null
385
458
  ? emptySequence().toKeyedSeq()
386
459
  : isCollection(value)
387
- ? isKeyed(value)
388
- ? value.toSeq()
389
- : value.fromEntrySeq()
390
- : isRecord(value)
391
- ? value.toSeq()
392
- : keyedSeqFromValue(value);
460
+ ? isKeyed(value)
461
+ ? value.toSeq()
462
+ : value.fromEntrySeq()
463
+ : isRecord(value)
464
+ ? value.toSeq()
465
+ : keyedSeqFromValue(value);
393
466
  }
394
467
 
395
468
  if ( Seq ) KeyedSeq.__proto__ = Seq;
@@ -409,12 +482,12 @@ var IndexedSeq = /*@__PURE__*/(function (Seq) {
409
482
  return value === undefined || value === null
410
483
  ? emptySequence()
411
484
  : isCollection(value)
412
- ? isKeyed(value)
413
- ? value.entrySeq()
414
- : value.toIndexedSeq()
415
- : isRecord(value)
416
- ? value.toSeq().entrySeq()
417
- : indexedSeqFromValue(value);
485
+ ? isKeyed(value)
486
+ ? value.entrySeq()
487
+ : value.toIndexedSeq()
488
+ : isRecord(value)
489
+ ? value.toSeq().entrySeq()
490
+ : indexedSeqFromValue(value);
418
491
  }
419
492
 
420
493
  if ( Seq ) IndexedSeq.__proto__ = Seq;
@@ -653,8 +726,8 @@ function seqFromValue(value) {
653
726
  return isEntriesIterable(value)
654
727
  ? seq.fromEntrySeq()
655
728
  : isKeysIterable(value)
656
- ? seq.toSetSeq()
657
- : seq;
729
+ ? seq.toSetSeq()
730
+ : seq;
658
731
  }
659
732
  if (typeof value === 'object') {
660
733
  return new ObjectSeq(value);
@@ -668,26 +741,42 @@ function maybeIndexedSeqFromValue(value) {
668
741
  return isArrayLike(value)
669
742
  ? new ArraySeq(value)
670
743
  : hasIterator(value)
671
- ? new CollectionSeq(value)
672
- : undefined;
744
+ ? new CollectionSeq(value)
745
+ : undefined;
673
746
  }
674
747
 
675
748
  var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@';
676
-
749
+ /**
750
+ * True if `maybeMap` is a Map.
751
+ *
752
+ * Also true for OrderedMaps.
753
+ */
677
754
  function isMap(maybeMap) {
678
- return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
755
+ return Boolean(maybeMap &&
756
+ // @ts-expect-error: maybeMap is typed as `{}`, need to change in 6.0 to `maybeMap && typeof maybeMap === 'object' && IS_MAP_SYMBOL in maybeMap`
757
+ maybeMap[IS_MAP_SYMBOL]);
679
758
  }
680
759
 
760
+ /**
761
+ * True if `maybeOrderedMap` is an OrderedMap.
762
+ */
681
763
  function isOrderedMap(maybeOrderedMap) {
682
- return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
764
+ return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
683
765
  }
684
766
 
767
+ /**
768
+ * True if `maybeValue` is a JavaScript Object which has *both* `equals()`
769
+ * and `hashCode()` methods.
770
+ *
771
+ * Any two instances of *value objects* can be compared for value equality with
772
+ * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`.
773
+ */
685
774
  function isValueObject(maybeValue) {
686
- return Boolean(
687
- maybeValue &&
688
- typeof maybeValue.equals === 'function' &&
689
- typeof maybeValue.hashCode === 'function'
690
- );
775
+ return Boolean(maybeValue &&
776
+ // @ts-expect-error: maybeValue is typed as `{}`
777
+ typeof maybeValue.equals === 'function' &&
778
+ // @ts-expect-error: maybeValue is typed as `{}`
779
+ typeof maybeValue.hashCode === 'function');
691
780
  }
692
781
 
693
782
  /**
@@ -745,30 +834,26 @@ function isValueObject(maybeValue) {
745
834
  * and `hashCode()`.
746
835
  */
747
836
  function is(valueA, valueB) {
748
- if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
749
- return true;
750
- }
751
- if (!valueA || !valueB) {
752
- return false;
753
- }
754
- if (
755
- typeof valueA.valueOf === 'function' &&
756
- typeof valueB.valueOf === 'function'
757
- ) {
758
- valueA = valueA.valueOf();
759
- valueB = valueB.valueOf();
760
837
  if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
761
- return true;
838
+ return true;
762
839
  }
763
840
  if (!valueA || !valueB) {
764
- return false;
841
+ return false;
765
842
  }
766
- }
767
- return !!(
768
- isValueObject(valueA) &&
769
- isValueObject(valueB) &&
770
- valueA.equals(valueB)
771
- );
843
+ if (typeof valueA.valueOf === 'function' &&
844
+ typeof valueB.valueOf === 'function') {
845
+ valueA = valueA.valueOf();
846
+ valueB = valueB.valueOf();
847
+ if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
848
+ return true;
849
+ }
850
+ if (!valueA || !valueB) {
851
+ return false;
852
+ }
853
+ }
854
+ return !!(isValueObject(valueA) &&
855
+ isValueObject(valueB) &&
856
+ valueA.equals(valueB));
772
857
  }
773
858
 
774
859
  var imul =
@@ -794,6 +879,7 @@ function smi(i32) {
794
879
  var defaultValueOf = Object.prototype.valueOf;
795
880
 
796
881
  function hash(o) {
882
+ // eslint-disable-next-line eqeqeq
797
883
  if (o == null) {
798
884
  return hashNullish(o);
799
885
  }
@@ -805,6 +891,7 @@ function hash(o) {
805
891
 
806
892
  var v = valueOf(o);
807
893
 
894
+ // eslint-disable-next-line eqeqeq
808
895
  if (v == null) {
809
896
  return hashNullish(v);
810
897
  }
@@ -971,6 +1058,7 @@ var canDefineProperty = (function () {
971
1058
  try {
972
1059
  Object.defineProperty({}, '@', {});
973
1060
  return true;
1061
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
974
1062
  } catch (e) {
975
1063
  return false;
976
1064
  }
@@ -1099,6 +1187,7 @@ var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) {
1099
1187
  var this$1$1 = this;
1100
1188
 
1101
1189
  var i = 0;
1190
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
1102
1191
  reverse && ensureSize(this);
1103
1192
  return this._iter.__iterate(
1104
1193
  function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); },
@@ -1111,6 +1200,7 @@ var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) {
1111
1200
 
1112
1201
  var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
1113
1202
  var i = 0;
1203
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
1114
1204
  reverse && ensureSize(this);
1115
1205
  return new Iterator(function () {
1116
1206
  var step = iterator.next();
@@ -1326,6 +1416,7 @@ function reverseFactory(collection, useKeys) {
1326
1416
  var this$1$1 = this;
1327
1417
 
1328
1418
  var i = 0;
1419
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
1329
1420
  reverse && ensureSize(collection);
1330
1421
  return collection.__iterate(
1331
1422
  function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); },
@@ -1334,6 +1425,7 @@ function reverseFactory(collection, useKeys) {
1334
1425
  };
1335
1426
  reversedSequence.__iterator = function (type, reverse) {
1336
1427
  var i = 0;
1428
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
1337
1429
  reverse && ensureSize(collection);
1338
1430
  var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse);
1339
1431
  return new Iterator(function () {
@@ -1620,6 +1712,7 @@ function skipWhileFactory(collection, predicate, context, useKeys) {
1620
1712
  var entry = step.value;
1621
1713
  k = entry[0];
1622
1714
  v = entry[1];
1715
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
1623
1716
  skipping && (skipping = predicate.call(context, v, k, this$1$1));
1624
1717
  } while (skipping);
1625
1718
  return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
@@ -1628,6 +1721,108 @@ function skipWhileFactory(collection, predicate, context, useKeys) {
1628
1721
  return skipSequence;
1629
1722
  }
1630
1723
 
1724
+ var ConcatSeq = /*@__PURE__*/(function (Seq) {
1725
+ function ConcatSeq(iterables) {
1726
+ this._wrappedIterables = iterables.flatMap(function (iterable) {
1727
+ if (iterable._wrappedIterables) {
1728
+ return iterable._wrappedIterables;
1729
+ }
1730
+ return [iterable];
1731
+ });
1732
+ this.size = this._wrappedIterables.reduce(function (sum, iterable) {
1733
+ if (sum !== undefined) {
1734
+ var size = iterable.size;
1735
+ if (size !== undefined) {
1736
+ return sum + size;
1737
+ }
1738
+ }
1739
+ }, 0);
1740
+ this[IS_KEYED_SYMBOL] = this._wrappedIterables[0][IS_KEYED_SYMBOL];
1741
+ this[IS_INDEXED_SYMBOL] = this._wrappedIterables[0][IS_INDEXED_SYMBOL];
1742
+ this[IS_ORDERED_SYMBOL] = this._wrappedIterables[0][IS_ORDERED_SYMBOL];
1743
+ }
1744
+
1745
+ if ( Seq ) ConcatSeq.__proto__ = Seq;
1746
+ ConcatSeq.prototype = Object.create( Seq && Seq.prototype );
1747
+ ConcatSeq.prototype.constructor = ConcatSeq;
1748
+
1749
+ ConcatSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
1750
+ if (this._wrappedIterables.length === 0) {
1751
+ return;
1752
+ }
1753
+
1754
+ if (reverse) {
1755
+ return this.cacheResult().__iterate(fn, reverse);
1756
+ }
1757
+
1758
+ var iterableIndex = 0;
1759
+ var useKeys = isKeyed(this);
1760
+ var iteratorType = useKeys ? ITERATE_ENTRIES : ITERATE_VALUES;
1761
+ var currentIterator = this._wrappedIterables[iterableIndex].__iterator(
1762
+ iteratorType,
1763
+ reverse
1764
+ );
1765
+
1766
+ var keepGoing = true;
1767
+ var index = 0;
1768
+ while (keepGoing) {
1769
+ var next = currentIterator.next();
1770
+ while (next.done) {
1771
+ iterableIndex++;
1772
+ if (iterableIndex === this._wrappedIterables.length) {
1773
+ return index;
1774
+ }
1775
+ currentIterator = this._wrappedIterables[iterableIndex].__iterator(
1776
+ iteratorType,
1777
+ reverse
1778
+ );
1779
+ next = currentIterator.next();
1780
+ }
1781
+ var fnResult = useKeys
1782
+ ? fn(next.value[1], next.value[0], this)
1783
+ : fn(next.value, index, this);
1784
+ keepGoing = fnResult !== false;
1785
+ index++;
1786
+ }
1787
+ return index;
1788
+ };
1789
+
1790
+ ConcatSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {
1791
+ var this$1$1 = this;
1792
+
1793
+ if (this._wrappedIterables.length === 0) {
1794
+ return new Iterator(iteratorDone);
1795
+ }
1796
+
1797
+ if (reverse) {
1798
+ return this.cacheResult().__iterator(type, reverse);
1799
+ }
1800
+
1801
+ var iterableIndex = 0;
1802
+ var currentIterator = this._wrappedIterables[iterableIndex].__iterator(
1803
+ type,
1804
+ reverse
1805
+ );
1806
+ return new Iterator(function () {
1807
+ var next = currentIterator.next();
1808
+ while (next.done) {
1809
+ iterableIndex++;
1810
+ if (iterableIndex === this$1$1._wrappedIterables.length) {
1811
+ return next;
1812
+ }
1813
+ currentIterator = this$1$1._wrappedIterables[iterableIndex].__iterator(
1814
+ type,
1815
+ reverse
1816
+ );
1817
+ next = currentIterator.next();
1818
+ }
1819
+ return next;
1820
+ });
1821
+ };
1822
+
1823
+ return ConcatSeq;
1824
+ }(Seq));
1825
+
1631
1826
  function concatFactory(collection, values) {
1632
1827
  var isKeyedCollection = isKeyed(collection);
1633
1828
  var iters = [collection]
@@ -1659,22 +1854,7 @@ function concatFactory(collection, values) {
1659
1854
  }
1660
1855
  }
1661
1856
 
1662
- var concatSeq = new ArraySeq(iters);
1663
- if (isKeyedCollection) {
1664
- concatSeq = concatSeq.toKeyedSeq();
1665
- } else if (!isIndexed(collection)) {
1666
- concatSeq = concatSeq.toSetSeq();
1667
- }
1668
- concatSeq = concatSeq.flatten(true);
1669
- concatSeq.size = iters.reduce(function (sum, seq) {
1670
- if (sum !== undefined) {
1671
- var size = seq.size;
1672
- if (size !== undefined) {
1673
- return sum + size;
1674
- }
1675
- }
1676
- }, 0);
1677
- return concatSeq;
1857
+ return new ConcatSeq(iters);
1678
1858
  }
1679
1859
 
1680
1860
  function flattenFactory(collection, depth, useKeys) {
@@ -1798,8 +1978,8 @@ function sortFactory(collection, comparator, mapper) {
1798
1978
  return isKeyedCollection
1799
1979
  ? KeyedSeq(entries)
1800
1980
  : isIndexed(collection)
1801
- ? IndexedSeq(entries)
1802
- : SetSeq(entries);
1981
+ ? IndexedSeq(entries)
1982
+ : SetSeq(entries);
1803
1983
  }
1804
1984
 
1805
1985
  function maxFactory(collection, comparator, mapper) {
@@ -1866,7 +2046,9 @@ function zipWithFactory(keyIter, zipper, iters, zipAll) {
1866
2046
  var steps;
1867
2047
  if (!isDone) {
1868
2048
  steps = iterators.map(function (i) { return i.next(); });
1869
- isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; });
2049
+ isDone = zipAll
2050
+ ? steps.every(function (s) { return s.done; })
2051
+ : steps.some(function (s) { return s.done; });
1870
2052
  }
1871
2053
  if (isDone) {
1872
2054
  return iteratorDone();
@@ -1900,8 +2082,8 @@ function collectionClass(collection) {
1900
2082
  return isKeyed(collection)
1901
2083
  ? KeyedCollection
1902
2084
  : isIndexed(collection)
1903
- ? IndexedCollection
1904
- : SetCollection;
2085
+ ? IndexedCollection
2086
+ : SetCollection;
1905
2087
  }
1906
2088
 
1907
2089
  function makeSequence(collection) {
@@ -1909,8 +2091,8 @@ function makeSequence(collection) {
1909
2091
  (isKeyed(collection)
1910
2092
  ? KeyedSeq
1911
2093
  : isIndexed(collection)
1912
- ? IndexedSeq
1913
- : SetSeq
2094
+ ? IndexedSeq
2095
+ : SetSeq
1914
2096
  ).prototype
1915
2097
  );
1916
2098
  }
@@ -1942,63 +2124,55 @@ function defaultComparator(a, b) {
1942
2124
 
1943
2125
  // http://jsperf.com/copy-array-inline
1944
2126
  function arrCopy(arr, offset) {
1945
- offset = offset || 0;
1946
- var len = Math.max(0, arr.length - offset);
1947
- var newArr = new Array(len);
1948
- for (var ii = 0; ii < len; ii++) {
1949
- newArr[ii] = arr[ii + offset];
1950
- }
1951
- return newArr;
2127
+ offset = offset || 0;
2128
+ var len = Math.max(0, arr.length - offset);
2129
+ var newArr = new Array(len);
2130
+ for (var ii = 0; ii < len; ii++) {
2131
+ // @ts-expect-error We may want to guard for undefined values with `if (arr[ii + offset] !== undefined`, but ths should not happen by design
2132
+ newArr[ii] = arr[ii + offset];
2133
+ }
2134
+ return newArr;
1952
2135
  }
1953
2136
 
1954
2137
  function invariant(condition, error) {
1955
- if (!condition) { throw new Error(error); }
2138
+ if (!condition)
2139
+ { throw new Error(error); }
1956
2140
  }
1957
2141
 
1958
2142
  function assertNotInfinite(size) {
1959
- invariant(
1960
- size !== Infinity,
1961
- 'Cannot perform this action with an infinite size.'
1962
- );
2143
+ invariant(size !== Infinity, 'Cannot perform this action with an infinite size.');
1963
2144
  }
1964
2145
 
1965
2146
  function coerceKeyPath(keyPath) {
1966
- if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
1967
- return keyPath;
1968
- }
1969
- if (isOrdered(keyPath)) {
1970
- return keyPath.toArray();
1971
- }
1972
- throw new TypeError(
1973
- 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath
1974
- );
2147
+ if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
2148
+ return keyPath;
2149
+ }
2150
+ if (isOrdered(keyPath)) {
2151
+ return keyPath.toArray();
2152
+ }
2153
+ throw new TypeError('Invalid keyPath: expected Ordered Collection or Array: ' + keyPath);
1975
2154
  }
1976
2155
 
1977
2156
  var toString = Object.prototype.toString;
1978
-
1979
2157
  function isPlainObject(value) {
1980
- // The base prototype's toString deals with Argument objects and native namespaces like Math
1981
- if (
1982
- !value ||
1983
- typeof value !== 'object' ||
1984
- toString.call(value) !== '[object Object]'
1985
- ) {
1986
- return false;
1987
- }
1988
-
1989
- var proto = Object.getPrototypeOf(value);
1990
- if (proto === null) {
1991
- return true;
1992
- }
1993
-
1994
- // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc)
1995
- var parentProto = proto;
1996
- var nextProto = Object.getPrototypeOf(proto);
1997
- while (nextProto !== null) {
1998
- parentProto = nextProto;
1999
- nextProto = Object.getPrototypeOf(parentProto);
2000
- }
2001
- return parentProto === proto;
2158
+ // The base prototype's toString deals with Argument objects and native namespaces like Math
2159
+ if (!value ||
2160
+ typeof value !== 'object' ||
2161
+ toString.call(value) !== '[object Object]') {
2162
+ return false;
2163
+ }
2164
+ var proto = Object.getPrototypeOf(value);
2165
+ if (proto === null) {
2166
+ return true;
2167
+ }
2168
+ // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc)
2169
+ var parentProto = proto;
2170
+ var nextProto = Object.getPrototypeOf(proto);
2171
+ while (nextProto !== null) {
2172
+ parentProto = nextProto;
2173
+ nextProto = Object.getPrototypeOf(parentProto);
2174
+ }
2175
+ return parentProto === proto;
2002
2176
  }
2003
2177
 
2004
2178
  /**
@@ -2006,169 +2180,206 @@ function isPlainObject(value) {
2006
2180
  * provided by Immutable.js or a plain Array or Object.
2007
2181
  */
2008
2182
  function isDataStructure(value) {
2009
- return (
2010
- typeof value === 'object' &&
2011
- (isImmutable(value) || Array.isArray(value) || isPlainObject(value))
2012
- );
2183
+ return (typeof value === 'object' &&
2184
+ (isImmutable(value) || Array.isArray(value) || isPlainObject(value)));
2013
2185
  }
2014
2186
 
2015
2187
  /**
2016
2188
  * Converts a value to a string, adding quotes if a string was provided.
2017
2189
  */
2018
2190
  function quoteString(value) {
2019
- try {
2020
- return typeof value === 'string' ? JSON.stringify(value) : String(value);
2021
- } catch (_ignoreError) {
2022
- return JSON.stringify(value);
2023
- }
2191
+ try {
2192
+ return typeof value === 'string' ? JSON.stringify(value) : String(value);
2193
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2194
+ }
2195
+ catch (_ignoreError) {
2196
+ return JSON.stringify(value);
2197
+ }
2024
2198
  }
2025
2199
 
2200
+ /**
2201
+ * Returns true if the key is defined in the provided collection.
2202
+ *
2203
+ * A functional alternative to `collection.has(key)` which will also work with
2204
+ * plain Objects and Arrays as an alternative for
2205
+ * `collection.hasOwnProperty(key)`.
2206
+ *
2207
+ * <!-- runkit:activate -->
2208
+ * ```js
2209
+ * import { has } from 'immutable';
2210
+ *
2211
+ * has([ 'dog', 'frog', 'cat' ], 2) // true
2212
+ * has([ 'dog', 'frog', 'cat' ], 5) // false
2213
+ * has({ x: 123, y: 456 }, 'x') // true
2214
+ * has({ x: 123, y: 456 }, 'z') // false
2215
+ * ```
2216
+ */
2026
2217
  function has(collection, key) {
2027
- return isImmutable(collection)
2028
- ? collection.has(key)
2029
- : isDataStructure(collection) && hasOwnProperty.call(collection, key);
2218
+ return isImmutable(collection)
2219
+ ? // @ts-expect-error key might be a number or symbol, which is not handled be Record key type
2220
+ collection.has(key)
2221
+ : // @ts-expect-error key might be anything else than PropertyKey, and will return false in that case but runtime is OK
2222
+ isDataStructure(collection) && hasOwnProperty.call(collection, key);
2030
2223
  }
2031
2224
 
2032
2225
  function get(collection, key, notSetValue) {
2033
- return isImmutable(collection)
2034
- ? collection.get(key, notSetValue)
2035
- : !has(collection, key)
2036
- ? notSetValue
2037
- : typeof collection.get === 'function'
2038
- ? collection.get(key)
2039
- : collection[key];
2226
+ return isImmutable(collection)
2227
+ ? collection.get(key, notSetValue)
2228
+ : !has(collection, key)
2229
+ ? notSetValue
2230
+ : // @ts-expect-error weird "get" here,
2231
+ typeof collection.get === 'function'
2232
+ ? // @ts-expect-error weird "get" here,
2233
+ collection.get(key)
2234
+ : // @ts-expect-error key is unknown here,
2235
+ collection[key];
2040
2236
  }
2041
2237
 
2042
2238
  function shallowCopy(from) {
2043
- if (Array.isArray(from)) {
2044
- return arrCopy(from);
2045
- }
2046
- var to = {};
2047
- for (var key in from) {
2048
- if (hasOwnProperty.call(from, key)) {
2049
- to[key] = from[key];
2239
+ if (Array.isArray(from)) {
2240
+ return arrCopy(from);
2050
2241
  }
2051
- }
2052
- return to;
2242
+ var to = {};
2243
+ for (var key in from) {
2244
+ if (hasOwnProperty.call(from, key)) {
2245
+ to[key] = from[key];
2246
+ }
2247
+ }
2248
+ return to;
2053
2249
  }
2054
2250
 
2055
2251
  function remove(collection, key) {
2056
- if (!isDataStructure(collection)) {
2057
- throw new TypeError(
2058
- 'Cannot update non-data-structure value: ' + collection
2059
- );
2060
- }
2061
- if (isImmutable(collection)) {
2062
- if (!collection.remove) {
2063
- throw new TypeError(
2064
- 'Cannot update immutable value without .remove() method: ' + collection
2065
- );
2252
+ if (!isDataStructure(collection)) {
2253
+ throw new TypeError('Cannot update non-data-structure value: ' + collection);
2066
2254
  }
2067
- return collection.remove(key);
2068
- }
2069
- if (!hasOwnProperty.call(collection, key)) {
2070
- return collection;
2071
- }
2072
- var collectionCopy = shallowCopy(collection);
2073
- if (Array.isArray(collectionCopy)) {
2074
- collectionCopy.splice(key, 1);
2075
- } else {
2076
- delete collectionCopy[key];
2077
- }
2078
- return collectionCopy;
2255
+ if (isImmutable(collection)) {
2256
+ // @ts-expect-error weird "remove" here,
2257
+ if (!collection.remove) {
2258
+ throw new TypeError('Cannot update immutable value without .remove() method: ' + collection);
2259
+ }
2260
+ // @ts-expect-error weird "remove" here,
2261
+ return collection.remove(key);
2262
+ }
2263
+ if (!hasOwnProperty.call(collection, key)) {
2264
+ return collection;
2265
+ }
2266
+ var collectionCopy = shallowCopy(collection);
2267
+ if (Array.isArray(collectionCopy)) {
2268
+ // @ts-expect-error assert that key is a number here
2269
+ collectionCopy.splice(key, 1);
2270
+ }
2271
+ else {
2272
+ delete collectionCopy[key];
2273
+ }
2274
+ return collectionCopy;
2079
2275
  }
2080
2276
 
2081
2277
  function set(collection, key, value) {
2082
- if (!isDataStructure(collection)) {
2083
- throw new TypeError(
2084
- 'Cannot update non-data-structure value: ' + collection
2085
- );
2086
- }
2087
- if (isImmutable(collection)) {
2088
- if (!collection.set) {
2089
- throw new TypeError(
2090
- 'Cannot update immutable value without .set() method: ' + collection
2091
- );
2278
+ if (!isDataStructure(collection)) {
2279
+ throw new TypeError('Cannot update non-data-structure value: ' + collection);
2092
2280
  }
2093
- return collection.set(key, value);
2094
- }
2095
- if (hasOwnProperty.call(collection, key) && value === collection[key]) {
2096
- return collection;
2097
- }
2098
- var collectionCopy = shallowCopy(collection);
2099
- collectionCopy[key] = value;
2100
- return collectionCopy;
2281
+ if (isImmutable(collection)) {
2282
+ // @ts-expect-error weird "set" here,
2283
+ if (!collection.set) {
2284
+ throw new TypeError('Cannot update immutable value without .set() method: ' + collection);
2285
+ }
2286
+ // @ts-expect-error weird "set" here,
2287
+ return collection.set(key, value);
2288
+ }
2289
+ // @ts-expect-error mix of key and string here. Probably need a more fine type here
2290
+ if (hasOwnProperty.call(collection, key) && value === collection[key]) {
2291
+ return collection;
2292
+ }
2293
+ var collectionCopy = shallowCopy(collection);
2294
+ // @ts-expect-error mix of key and string here. Probably need a more fine type here
2295
+ collectionCopy[key] = value;
2296
+ return collectionCopy;
2101
2297
  }
2102
2298
 
2103
2299
  function updateIn$1(collection, keyPath, notSetValue, updater) {
2104
- if (!updater) {
2105
- updater = notSetValue;
2106
- notSetValue = undefined;
2107
- }
2108
- var updatedValue = updateInDeeply(
2109
- isImmutable(collection),
2110
- collection,
2111
- coerceKeyPath(keyPath),
2112
- 0,
2113
- notSetValue,
2114
- updater
2115
- );
2116
- return updatedValue === NOT_SET ? notSetValue : updatedValue;
2117
- }
2118
-
2119
- function updateInDeeply(
2120
- inImmutable,
2121
- existing,
2122
- keyPath,
2123
- i,
2124
- notSetValue,
2125
- updater
2126
- ) {
2127
- var wasNotSet = existing === NOT_SET;
2128
- if (i === keyPath.length) {
2129
- var existingValue = wasNotSet ? notSetValue : existing;
2130
- var newValue = updater(existingValue);
2131
- return newValue === existingValue ? existing : newValue;
2132
- }
2133
- if (!wasNotSet && !isDataStructure(existing)) {
2134
- throw new TypeError(
2135
- 'Cannot update within non-data-structure value in path [' +
2136
- keyPath.slice(0, i).map(quoteString) +
2137
- ']: ' +
2138
- existing
2139
- );
2140
- }
2141
- var key = keyPath[i];
2142
- var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
2143
- var nextUpdated = updateInDeeply(
2144
- nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
2145
- nextExisting,
2146
- keyPath,
2147
- i + 1,
2148
- notSetValue,
2149
- updater
2150
- );
2151
- return nextUpdated === nextExisting
2152
- ? existing
2153
- : nextUpdated === NOT_SET
2154
- ? remove(existing, key)
2155
- : set(
2156
- wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
2157
- key,
2158
- nextUpdated
2159
- );
2300
+ if (!updater) {
2301
+ // handle the fact that `notSetValue` is optional here, in that case `updater` is the updater function
2302
+ // @ts-expect-error updater is a function here
2303
+ updater = notSetValue;
2304
+ notSetValue = undefined;
2305
+ }
2306
+ var updatedValue = updateInDeeply(isImmutable(collection),
2307
+ // @ts-expect-error type issues with Record and mixed types
2308
+ collection, coerceKeyPath(keyPath), 0, notSetValue, updater);
2309
+ // @ts-expect-error mixed return type
2310
+ return updatedValue === NOT_SET ? notSetValue : updatedValue;
2311
+ }
2312
+ function updateInDeeply(inImmutable, existing, keyPath, i, notSetValue, updater) {
2313
+ var wasNotSet = existing === NOT_SET;
2314
+ if (i === keyPath.length) {
2315
+ var existingValue = wasNotSet ? notSetValue : existing;
2316
+ // @ts-expect-error mixed type with optional value
2317
+ var newValue = updater(existingValue);
2318
+ // @ts-expect-error mixed type
2319
+ return newValue === existingValue ? existing : newValue;
2320
+ }
2321
+ if (!wasNotSet && !isDataStructure(existing)) {
2322
+ throw new TypeError('Cannot update within non-data-structure value in path [' +
2323
+ Array.from(keyPath).slice(0, i).map(quoteString) +
2324
+ ']: ' +
2325
+ existing);
2326
+ }
2327
+ var key = keyPath[i];
2328
+ if (typeof key === 'undefined') {
2329
+ throw new TypeError('Index can not be undefined in updateIn(). This should not happen');
2330
+ }
2331
+ var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
2332
+ var nextUpdated = updateInDeeply(nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
2333
+ // @ts-expect-error mixed type
2334
+ nextExisting, keyPath, i + 1, notSetValue, updater);
2335
+ return nextUpdated === nextExisting
2336
+ ? existing
2337
+ : nextUpdated === NOT_SET
2338
+ ? remove(existing, key)
2339
+ : set(wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, key, nextUpdated);
2160
2340
  }
2161
2341
 
2342
+ /**
2343
+ * Returns a copy of the collection with the value at the key path set to the
2344
+ * provided value.
2345
+ *
2346
+ * A functional alternative to `collection.setIn(keypath)` which will also
2347
+ * work with plain Objects and Arrays.
2348
+ *
2349
+ * <!-- runkit:activate -->
2350
+ * ```js
2351
+ * import { setIn } from 'immutable';
2352
+ *
2353
+ * const original = { x: { y: { z: 123 }}}
2354
+ * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}}
2355
+ * console.log(original) // { x: { y: { z: 123 }}}
2356
+ * ```
2357
+ */
2162
2358
  function setIn$1(collection, keyPath, value) {
2163
- return updateIn$1(collection, keyPath, NOT_SET, function () { return value; });
2359
+ return updateIn$1(collection, keyPath, NOT_SET, function () { return value; });
2164
2360
  }
2165
2361
 
2166
2362
  function setIn(keyPath, v) {
2167
2363
  return setIn$1(this, keyPath, v);
2168
2364
  }
2169
2365
 
2366
+ /**
2367
+ * Returns a copy of the collection with the value at the key path removed.
2368
+ *
2369
+ * A functional alternative to `collection.removeIn(keypath)` which will also
2370
+ * work with plain Objects and Arrays.
2371
+ *
2372
+ * <!-- runkit:activate -->
2373
+ * ```js
2374
+ * import { removeIn } from 'immutable';
2375
+ *
2376
+ * const original = { x: { y: { z: 123 }}}
2377
+ * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}}
2378
+ * console.log(original) // { x: { y: { z: 123 }}}
2379
+ * ```
2380
+ */
2170
2381
  function removeIn(collection, keyPath) {
2171
- return updateIn$1(collection, keyPath, function () { return NOT_SET; });
2382
+ return updateIn$1(collection, keyPath, function () { return NOT_SET; });
2172
2383
  }
2173
2384
 
2174
2385
  function deleteIn(keyPath) {
@@ -2176,7 +2387,9 @@ function deleteIn(keyPath) {
2176
2387
  }
2177
2388
 
2178
2389
  function update$1(collection, key, notSetValue, updater) {
2179
- return updateIn$1(collection, [key], notSetValue, updater);
2390
+ return updateIn$1(
2391
+ // @ts-expect-error Index signature for type string is missing in type V[]
2392
+ collection, [key], notSetValue, updater);
2180
2393
  }
2181
2394
 
2182
2395
  function update(key, notSetValue, updater) {
@@ -2281,8 +2494,8 @@ function mergeWithSources(collection, sources, merger) {
2281
2494
  return typeof merger === 'function' && collection.mergeWith
2282
2495
  ? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
2283
2496
  : collection.merge
2284
- ? collection.merge.apply(collection, sources)
2285
- : collection.concat.apply(collection, sources);
2497
+ ? collection.merge.apply(collection, sources)
2498
+ : collection.concat.apply(collection, sources);
2286
2499
  }
2287
2500
  var isArray = Array.isArray(collection);
2288
2501
  var merged = collection;
@@ -2320,8 +2533,8 @@ function deepMergerWith(merger) {
2320
2533
  areMergeable(oldValue, newValue)
2321
2534
  ? mergeWithSources(oldValue, [newValue], deepMerger)
2322
2535
  : merger
2323
- ? merger(oldValue, newValue, key)
2324
- : newValue;
2536
+ ? merger(oldValue, newValue, key)
2537
+ : newValue;
2325
2538
  }
2326
2539
  return deepMerger;
2327
2540
  }
@@ -2395,12 +2608,12 @@ var Map = /*@__PURE__*/(function (KeyedCollection) {
2395
2608
  return value === undefined || value === null
2396
2609
  ? emptyMap()
2397
2610
  : isMap(value) && !isOrdered(value)
2398
- ? value
2399
- : emptyMap().withMutations(function (map) {
2400
- var iter = KeyedCollection(value);
2401
- assertNotInfinite(iter.size);
2402
- iter.forEach(function (v, k) { return map.set(k, v); });
2403
- });
2611
+ ? value
2612
+ : emptyMap().withMutations(function (map) {
2613
+ var iter = KeyedCollection(value);
2614
+ assertNotInfinite(iter.size);
2615
+ iter.forEach(function (v, k) { return map.set(k, v); });
2616
+ });
2404
2617
  }
2405
2618
 
2406
2619
  if ( KeyedCollection ) Map.__proto__ = KeyedCollection;
@@ -2487,6 +2700,7 @@ var Map = /*@__PURE__*/(function (KeyedCollection) {
2487
2700
  var this$1$1 = this;
2488
2701
 
2489
2702
  var iterations = 0;
2703
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
2490
2704
  this._root &&
2491
2705
  this._root.iterate(function (entry) {
2492
2706
  iterations++;
@@ -2575,6 +2789,7 @@ ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, v
2575
2789
  }
2576
2790
 
2577
2791
  SetRef(didAlter);
2792
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
2578
2793
  (removed || !exists) && SetRef(didChangeSize);
2579
2794
 
2580
2795
  if (removed && entries.length === 1) {
@@ -2590,6 +2805,7 @@ ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, v
2590
2805
 
2591
2806
  if (exists) {
2592
2807
  if (removed) {
2808
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
2593
2809
  idx === len - 1
2594
2810
  ? newEntries.pop()
2595
2811
  : (newEntries[idx] = newEntries.pop());
@@ -2808,6 +3024,7 @@ HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, k
2808
3024
  }
2809
3025
 
2810
3026
  SetRef(didAlter);
3027
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
2811
3028
  (removed || !exists) && SetRef(didChangeSize);
2812
3029
 
2813
3030
  if (removed && len === 2) {
@@ -2819,6 +3036,7 @@ HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, k
2819
3036
 
2820
3037
  if (exists) {
2821
3038
  if (removed) {
3039
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
2822
3040
  idx === len - 1
2823
3041
  ? newEntries.pop()
2824
3042
  : (newEntries[idx] = newEntries.pop());
@@ -3161,9 +3379,13 @@ var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
3161
3379
  var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
3162
3380
 
3163
3381
  var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@';
3164
-
3382
+ /**
3383
+ * True if `maybeList` is a List.
3384
+ */
3165
3385
  function isList(maybeList) {
3166
- return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
3386
+ return Boolean(maybeList &&
3387
+ // @ts-expect-error: maybeList is typed as `{}`, need to change in 6.0 to `maybeList && typeof maybeList === 'object' && IS_LIST_SYMBOL in maybeList`
3388
+ maybeList[IS_LIST_SYMBOL]);
3167
3389
  }
3168
3390
 
3169
3391
  var List = /*@__PURE__*/(function (IndexedCollection) {
@@ -3229,10 +3451,10 @@ var List = /*@__PURE__*/(function (IndexedCollection) {
3229
3451
  return !this.has(index)
3230
3452
  ? this
3231
3453
  : index === 0
3232
- ? this.shift()
3233
- : index === this.size - 1
3234
- ? this.pop()
3235
- : this.splice(index, 1);
3454
+ ? this.shift()
3455
+ : index === this.size - 1
3456
+ ? this.pop()
3457
+ : this.splice(index, 1);
3236
3458
  };
3237
3459
 
3238
3460
  List.prototype.insert = function insert (index, value) {
@@ -3282,6 +3504,25 @@ var List = /*@__PURE__*/(function (IndexedCollection) {
3282
3504
  return setListBounds(this, 1);
3283
3505
  };
3284
3506
 
3507
+ List.prototype.shuffle = function shuffle (random) {
3508
+ if ( random === void 0 ) random = Math.random;
3509
+
3510
+ return this.withMutations(function (mutable) {
3511
+ // implementation of the Fisher-Yates shuffle: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
3512
+ var current = mutable.size;
3513
+ var destination;
3514
+ var tmp;
3515
+
3516
+ while (current) {
3517
+ destination = Math.floor(random() * current--);
3518
+
3519
+ tmp = mutable.get(destination);
3520
+ mutable.set(destination, mutable.get(current));
3521
+ mutable.set(current, tmp);
3522
+ }
3523
+ });
3524
+ };
3525
+
3285
3526
  // @pragma Composition
3286
3527
 
3287
3528
  List.prototype.concat = function concat (/*...collections*/) {
@@ -3573,6 +3814,7 @@ function updateList(list, index, value) {
3573
3814
 
3574
3815
  if (index >= list.size || index < 0) {
3575
3816
  return list.withMutations(function (list) {
3817
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
3576
3818
  index < 0
3577
3819
  ? setListBounds(list, index).set(0, value)
3578
3820
  : setListBounds(list, 0, index + 1).set(index, value);
@@ -3694,8 +3936,8 @@ function setListBounds(list, begin, end) {
3694
3936
  end === undefined
3695
3937
  ? oldCapacity
3696
3938
  : end < 0
3697
- ? oldCapacity + end
3698
- : oldOrigin + end;
3939
+ ? oldCapacity + end
3940
+ : oldOrigin + end;
3699
3941
  if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
3700
3942
  return list;
3701
3943
  }
@@ -3743,8 +3985,8 @@ function setListBounds(list, begin, end) {
3743
3985
  newTailOffset < oldTailOffset
3744
3986
  ? listNodeFor(list, newCapacity - 1)
3745
3987
  : newTailOffset > oldTailOffset
3746
- ? new VNode([], owner)
3747
- : oldTail;
3988
+ ? new VNode([], owner)
3989
+ : oldTail;
3748
3990
 
3749
3991
  // Merge Tail into tree.
3750
3992
  if (
@@ -3833,12 +4075,12 @@ var OrderedMap = /*@__PURE__*/(function (Map) {
3833
4075
  return value === undefined || value === null
3834
4076
  ? emptyOrderedMap()
3835
4077
  : isOrderedMap(value)
3836
- ? value
3837
- : emptyOrderedMap().withMutations(function (map) {
3838
- var iter = KeyedCollection(value);
3839
- assertNotInfinite(iter.size);
3840
- iter.forEach(function (v, k) { return map.set(k, v); });
3841
- });
4078
+ ? value
4079
+ : emptyOrderedMap().withMutations(function (map) {
4080
+ var iter = KeyedCollection(value);
4081
+ assertNotInfinite(iter.size);
4082
+ iter.forEach(function (v, k) { return map.set(k, v); });
4083
+ });
3842
4084
  }
3843
4085
 
3844
4086
  if ( Map ) OrderedMap.__proto__ = Map;
@@ -3991,9 +4233,13 @@ function updateOrderedMap(omap, k, v) {
3991
4233
  }
3992
4234
 
3993
4235
  var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@';
3994
-
4236
+ /**
4237
+ * True if `maybeStack` is a Stack.
4238
+ */
3995
4239
  function isStack(maybeStack) {
3996
- return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
4240
+ return Boolean(maybeStack &&
4241
+ // @ts-expect-error: maybeStack is typed as `{}`, need to change in 6.0 to `maybeStack && typeof maybeStack === 'object' && MAYBE_STACK_SYMBOL in maybeStack`
4242
+ maybeStack[IS_STACK_SYMBOL]);
3997
4243
  }
3998
4244
 
3999
4245
  var Stack = /*@__PURE__*/(function (IndexedCollection) {
@@ -4002,8 +4248,8 @@ var Stack = /*@__PURE__*/(function (IndexedCollection) {
4002
4248
  return value === undefined || value === null
4003
4249
  ? emptyStack()
4004
4250
  : isStack(value)
4005
- ? value
4006
- : emptyStack().pushAll(value);
4251
+ ? value
4252
+ : emptyStack().pushAll(value);
4007
4253
  }
4008
4254
 
4009
4255
  if ( IndexedCollection ) Stack.__proto__ = IndexedCollection;
@@ -4222,92 +4468,108 @@ function emptyStack() {
4222
4468
  }
4223
4469
 
4224
4470
  var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@';
4225
-
4471
+ /**
4472
+ * True if `maybeSet` is a Set.
4473
+ *
4474
+ * Also true for OrderedSets.
4475
+ */
4226
4476
  function isSet(maybeSet) {
4227
- return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
4477
+ return Boolean(maybeSet &&
4478
+ // @ts-expect-error: maybeSet is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSet === 'object' && MAYBE_SET_SYMBOL in maybeSet`
4479
+ maybeSet[IS_SET_SYMBOL]);
4228
4480
  }
4229
4481
 
4482
+ /**
4483
+ * True if `maybeOrderedSet` is an OrderedSet.
4484
+ */
4230
4485
  function isOrderedSet(maybeOrderedSet) {
4231
- return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
4486
+ return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
4232
4487
  }
4233
4488
 
4234
4489
  function deepEqual(a, b) {
4235
- if (a === b) {
4236
- return true;
4237
- }
4238
-
4239
- if (
4240
- !isCollection(b) ||
4241
- (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
4242
- (a.__hash !== undefined &&
4243
- b.__hash !== undefined &&
4244
- a.__hash !== b.__hash) ||
4245
- isKeyed(a) !== isKeyed(b) ||
4246
- isIndexed(a) !== isIndexed(b) ||
4247
- isOrdered(a) !== isOrdered(b)
4248
- ) {
4249
- return false;
4250
- }
4251
-
4252
- if (a.size === 0 && b.size === 0) {
4253
- return true;
4254
- }
4255
-
4256
- var notAssociative = !isAssociative(a);
4257
-
4258
- if (isOrdered(a)) {
4259
- var entries = a.entries();
4260
- return (
4261
- b.every(function (v, k) {
4262
- var entry = entries.next().value;
4263
- return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
4264
- }) && entries.next().done
4265
- );
4266
- }
4267
-
4268
- var flipped = false;
4269
-
4270
- if (a.size === undefined) {
4271
- if (b.size === undefined) {
4272
- if (typeof a.cacheResult === 'function') {
4273
- a.cacheResult();
4274
- }
4275
- } else {
4276
- flipped = true;
4277
- var _ = a;
4278
- a = b;
4279
- b = _;
4490
+ if (a === b) {
4491
+ return true;
4492
+ }
4493
+ if (!isCollection(b) ||
4494
+ // @ts-expect-error size should exists on Collection
4495
+ (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
4496
+ // @ts-expect-error __hash exists on Collection
4497
+ (a.__hash !== undefined &&
4498
+ // @ts-expect-error __hash exists on Collection
4499
+ b.__hash !== undefined &&
4500
+ // @ts-expect-error __hash exists on Collection
4501
+ a.__hash !== b.__hash) ||
4502
+ isKeyed(a) !== isKeyed(b) ||
4503
+ isIndexed(a) !== isIndexed(b) ||
4504
+ // @ts-expect-error Range extends Collection, which implements [Symbol.iterator], so it is valid
4505
+ isOrdered(a) !== isOrdered(b)) {
4506
+ return false;
4280
4507
  }
4281
- }
4282
-
4283
- var allEqual = true;
4284
- var bSize = b.__iterate(function (v, k) {
4285
- if (
4286
- notAssociative
4287
- ? !a.has(v)
4288
- : flipped
4289
- ? !is(v, a.get(k, NOT_SET))
4290
- : !is(a.get(k, NOT_SET), v)
4291
- ) {
4292
- allEqual = false;
4293
- return false;
4508
+ // @ts-expect-error size should exists on Collection
4509
+ if (a.size === 0 && b.size === 0) {
4510
+ return true;
4511
+ }
4512
+ var notAssociative = !isAssociative(a);
4513
+ // @ts-expect-error Range extends Collection, which implements [Symbol.iterator], so it is valid
4514
+ if (isOrdered(a)) {
4515
+ var entries = a.entries();
4516
+ // @ts-expect-error need to cast as boolean
4517
+ return (b.every(function (v, k) {
4518
+ var entry = entries.next().value;
4519
+ return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
4520
+ }) && entries.next().done);
4521
+ }
4522
+ var flipped = false;
4523
+ if (a.size === undefined) {
4524
+ // @ts-expect-error size should exists on Collection
4525
+ if (b.size === undefined) {
4526
+ if (typeof a.cacheResult === 'function') {
4527
+ a.cacheResult();
4528
+ }
4529
+ }
4530
+ else {
4531
+ flipped = true;
4532
+ var _ = a;
4533
+ a = b;
4534
+ b = _;
4535
+ }
4294
4536
  }
4295
- });
4296
-
4297
- return allEqual && a.size === bSize;
4537
+ var allEqual = true;
4538
+ var bSize =
4539
+ // @ts-expect-error b is Range | Repeat | Collection<unknown, unknown> as it may have been flipped, and __iterate is valid
4540
+ b.__iterate(function (v, k) {
4541
+ if (notAssociative
4542
+ ? // @ts-expect-error has exists on Collection
4543
+ !a.has(v)
4544
+ : flipped
4545
+ ? // @ts-expect-error type of `get` does not "catch" the version with `notSetValue`
4546
+ !is(v, a.get(k, NOT_SET))
4547
+ : // @ts-expect-error type of `get` does not "catch" the version with `notSetValue`
4548
+ !is(a.get(k, NOT_SET), v)) {
4549
+ allEqual = false;
4550
+ return false;
4551
+ }
4552
+ });
4553
+ return (allEqual &&
4554
+ // @ts-expect-error size should exists on Collection
4555
+ a.size === bSize);
4298
4556
  }
4299
4557
 
4300
4558
  /**
4301
4559
  * Contributes additional methods to a constructor
4302
4560
  */
4303
- function mixin(ctor, methods) {
4304
- var keyCopier = function (key) {
4305
- ctor.prototype[key] = methods[key];
4306
- };
4307
- Object.keys(methods).forEach(keyCopier);
4308
- Object.getOwnPropertySymbols &&
4309
- Object.getOwnPropertySymbols(methods).forEach(keyCopier);
4310
- return ctor;
4561
+ function mixin(ctor,
4562
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
4563
+ methods) {
4564
+ var keyCopier = function (key) {
4565
+ // @ts-expect-error how to handle symbol ?
4566
+ ctor.prototype[key] = methods[key];
4567
+ };
4568
+ Object.keys(methods).forEach(keyCopier);
4569
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
4570
+ Object.getOwnPropertySymbols &&
4571
+ Object.getOwnPropertySymbols(methods).forEach(keyCopier);
4572
+ return ctor;
4311
4573
  }
4312
4574
 
4313
4575
  function toJS(value) {
@@ -4340,12 +4602,12 @@ var Set = /*@__PURE__*/(function (SetCollection) {
4340
4602
  return value === undefined || value === null
4341
4603
  ? emptySet()
4342
4604
  : isSet(value) && !isOrdered(value)
4343
- ? value
4344
- : emptySet().withMutations(function (set) {
4345
- var iter = SetCollection(value);
4346
- assertNotInfinite(iter.size);
4347
- iter.forEach(function (v) { return set.add(v); });
4348
- });
4605
+ ? value
4606
+ : emptySet().withMutations(function (set) {
4607
+ var iter = SetCollection(value);
4608
+ assertNotInfinite(iter.size);
4609
+ iter.forEach(function (v) { return set.add(v); });
4610
+ });
4349
4611
  }
4350
4612
 
4351
4613
  if ( SetCollection ) Set.__proto__ = SetCollection;
@@ -4559,8 +4821,8 @@ function updateSet(set, newMap) {
4559
4821
  return newMap === set._map
4560
4822
  ? set
4561
4823
  : newMap.size === 0
4562
- ? set.__empty()
4563
- : set.__make(newMap);
4824
+ ? set.__empty()
4825
+ : set.__make(newMap);
4564
4826
  }
4565
4827
 
4566
4828
  function makeSet(map, ownerID) {
@@ -4622,17 +4884,9 @@ var Range = /*@__PURE__*/(function (IndexedSeq) {
4622
4884
  Range.prototype.constructor = Range;
4623
4885
 
4624
4886
  Range.prototype.toString = function toString () {
4625
- if (this.size === 0) {
4626
- return 'Range []';
4627
- }
4628
- return (
4629
- 'Range [ ' +
4630
- this._start +
4631
- '...' +
4632
- this._end +
4633
- (this._step !== 1 ? ' by ' + this._step : '') +
4634
- ' ]'
4635
- );
4887
+ return this.size === 0
4888
+ ? 'Range []'
4889
+ : ("Range [ " + (this._start) + "..." + (this._end) + (this._step !== 1 ? ' by ' + this._step : '') + " ]");
4636
4890
  };
4637
4891
 
4638
4892
  Range.prototype.get = function get (index, notSetValue) {
@@ -4723,24 +4977,54 @@ var Range = /*@__PURE__*/(function (IndexedSeq) {
4723
4977
 
4724
4978
  var EMPTY_RANGE;
4725
4979
 
4980
+ /**
4981
+ * Returns the value at the provided key path starting at the provided
4982
+ * collection, or notSetValue if the key path is not defined.
4983
+ *
4984
+ * A functional alternative to `collection.getIn(keypath)` which will also
4985
+ * work with plain Objects and Arrays.
4986
+ *
4987
+ * <!-- runkit:activate -->
4988
+ * ```js
4989
+ * import { getIn } from 'immutable';
4990
+ *
4991
+ * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123
4992
+ * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet'
4993
+ * ```
4994
+ */
4726
4995
  function getIn$1(collection, searchKeyPath, notSetValue) {
4727
- var keyPath = coerceKeyPath(searchKeyPath);
4728
- var i = 0;
4729
- while (i !== keyPath.length) {
4730
- collection = get(collection, keyPath[i++], NOT_SET);
4731
- if (collection === NOT_SET) {
4732
- return notSetValue;
4996
+ var keyPath = coerceKeyPath(searchKeyPath);
4997
+ var i = 0;
4998
+ while (i !== keyPath.length) {
4999
+ // @ts-expect-error keyPath[i++] can not be undefined by design
5000
+ collection = get(collection, keyPath[i++], NOT_SET);
5001
+ if (collection === NOT_SET) {
5002
+ return notSetValue;
5003
+ }
4733
5004
  }
4734
- }
4735
- return collection;
5005
+ return collection;
4736
5006
  }
4737
5007
 
4738
5008
  function getIn(searchKeyPath, notSetValue) {
4739
5009
  return getIn$1(this, searchKeyPath, notSetValue);
4740
5010
  }
4741
5011
 
5012
+ /**
5013
+ * Returns true if the key path is defined in the provided collection.
5014
+ *
5015
+ * A functional alternative to `collection.hasIn(keypath)` which will also
5016
+ * work with plain Objects and Arrays.
5017
+ *
5018
+ * <!-- runkit:activate -->
5019
+ * ```js
5020
+ * import { hasIn } from 'immutable';
5021
+ *
5022
+ * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true
5023
+ * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false
5024
+ * ```
5025
+ */
4742
5026
  function hasIn$1(collection, keyPath) {
4743
- return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET;
5027
+ return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET;
4744
5028
  }
4745
5029
 
4746
5030
  function hasIn(searchKeyPath) {
@@ -4815,8 +5099,8 @@ mixin(Collection, {
4815
5099
  return isIndexed(this)
4816
5100
  ? this.toIndexedSeq()
4817
5101
  : isKeyed(this)
4818
- ? this.toKeyedSeq()
4819
- : this.toSetSeq();
5102
+ ? this.toKeyedSeq()
5103
+ : this.toSetSeq();
4820
5104
  },
4821
5105
 
4822
5106
  toStack: function toStack() {
@@ -4901,6 +5185,7 @@ mixin(Collection, {
4901
5185
  var joined = '';
4902
5186
  var isFirst = true;
4903
5187
  this.__iterate(function (v) {
5188
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
4904
5189
  isFirst ? (isFirst = false) : (joined += separator);
4905
5190
  joined += v !== null && v !== undefined ? v.toString() : '';
4906
5191
  });
@@ -5452,12 +5737,12 @@ function hashCollection(collection) {
5452
5737
  h = (h + hashMerge(hash(v), hash(k))) | 0;
5453
5738
  }
5454
5739
  : ordered
5455
- ? function (v) {
5456
- h = (31 * h + hash(v)) | 0;
5457
- }
5458
- : function (v) {
5459
- h = (h + hash(v)) | 0;
5460
- }
5740
+ ? function (v) {
5741
+ h = (31 * h + hash(v)) | 0;
5742
+ }
5743
+ : function (v) {
5744
+ h = (h + hash(v)) | 0;
5745
+ }
5461
5746
  );
5462
5747
 
5463
5748
  return murmurHashOfSize(collection.size, h);
@@ -5484,12 +5769,12 @@ var OrderedSet = /*@__PURE__*/(function (Set) {
5484
5769
  return value === undefined || value === null
5485
5770
  ? emptyOrderedSet()
5486
5771
  : isOrderedSet(value)
5487
- ? value
5488
- : emptyOrderedSet().withMutations(function (set) {
5489
- var iter = SetCollection(value);
5490
- assertNotInfinite(iter.size);
5491
- iter.forEach(function (v) { return set.add(v); });
5492
- });
5772
+ ? value
5773
+ : emptyOrderedSet().withMutations(function (set) {
5774
+ var iter = SetCollection(value);
5775
+ assertNotInfinite(iter.size);
5776
+ iter.forEach(function (v) { return set.add(v); });
5777
+ });
5493
5778
  }
5494
5779
 
5495
5780
  if ( Set ) OrderedSet.__proto__ = Set;
@@ -5539,7 +5824,7 @@ function emptyOrderedSet() {
5539
5824
 
5540
5825
  var PairSorting = {
5541
5826
  LeftThenRight: -1,
5542
- RightThenLeft: +1,
5827
+ RightThenLeft: 1,
5543
5828
  };
5544
5829
 
5545
5830
  function throwOnInvalidDefaultValues(defaultValues) {
@@ -5591,6 +5876,7 @@ var Record = function Record(defaultValues, name) {
5591
5876
  indices[propName] = i;
5592
5877
  if (RecordTypePrototype[propName]) {
5593
5878
  /* eslint-disable no-console */
5879
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
5594
5880
  typeof console === 'object' &&
5595
5881
  console.warn &&
5596
5882
  console.warn(
@@ -5780,6 +6066,7 @@ function setProp(prototype, name) {
5780
6066
  this.set(name, value);
5781
6067
  },
5782
6068
  });
6069
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO enable eslint here
5783
6070
  } catch (error) {
5784
6071
  // Object.defineProperty failed. Probably IE8.
5785
6072
  }
@@ -5908,6 +6195,7 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
5908
6195
  throw new TypeError('Cannot convert circular structure to Immutable');
5909
6196
  }
5910
6197
  stack.push(value);
6198
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
5911
6199
  keyPath && key !== '' && keyPath.push(key);
5912
6200
  var converted = converter.call(
5913
6201
  parentValue,
@@ -5917,6 +6205,7 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
5917
6205
  keyPath && keyPath.slice()
5918
6206
  );
5919
6207
  stack.pop();
6208
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here
5920
6209
  keyPath && keyPath.pop();
5921
6210
  return converted;
5922
6211
  }
@@ -5928,7 +6217,7 @@ function defaultConverter(k, v) {
5928
6217
  return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet();
5929
6218
  }
5930
6219
 
5931
- var version = "5.0.3";
6220
+ var version = "5.1.1";
5932
6221
 
5933
6222
  // Note: Iterable is deprecated
5934
6223
  var Iterable = Collection;