immutable 4.0.0-rc.12 → 4.0.0-rc.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +111 -97
- package/dist/immutable-nonambient.d.ts +713 -443
- package/dist/immutable.d.ts +715 -445
- package/dist/immutable.es.js +521 -446
- package/dist/immutable.js +552 -468
- package/dist/immutable.js.flow +928 -262
- package/dist/immutable.min.js +53 -36
- package/package.json +6 -94
- package/contrib/cursor/README.md +0 -43
- package/contrib/cursor/__tests__/Cursor.ts.skip +0 -395
- package/contrib/cursor/index.d.ts +0 -287
- package/contrib/cursor/index.js +0 -360
package/dist/immutable.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
2
|
* Immutable data encourages pure functions (data-in, data-out) and lends itself
|
|
10
3
|
* to much simpler application development and enabling techniques from
|
|
@@ -73,7 +66,7 @@
|
|
|
73
66
|
* `getIn` which expects an `Iterable` path:
|
|
74
67
|
*
|
|
75
68
|
* ```
|
|
76
|
-
* getIn(path: Iterable<string | number>):
|
|
69
|
+
* getIn(path: Iterable<string | number>): unknown
|
|
77
70
|
* ```
|
|
78
71
|
*
|
|
79
72
|
* To use this method, we could pass an array: `data.getIn([ "key", 2 ])`.
|
|
@@ -92,13 +85,12 @@
|
|
|
92
85
|
* ```
|
|
93
86
|
*
|
|
94
87
|
* [ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla
|
|
95
|
-
* [TypeScript]:
|
|
88
|
+
* [TypeScript]: https://www.typescriptlang.org/
|
|
96
89
|
* [Flow]: https://flowtype.org/
|
|
97
90
|
* [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
|
|
98
91
|
*/
|
|
99
92
|
|
|
100
93
|
declare module Immutable {
|
|
101
|
-
|
|
102
94
|
/**
|
|
103
95
|
* Lists are ordered indexed dense collections, much like a JavaScript
|
|
104
96
|
* Array.
|
|
@@ -114,7 +106,6 @@ declare module Immutable {
|
|
|
114
106
|
* indices from 0 to size, regardless of whether they were explicitly defined.
|
|
115
107
|
*/
|
|
116
108
|
export module List {
|
|
117
|
-
|
|
118
109
|
/**
|
|
119
110
|
* True if the provided value is a List
|
|
120
111
|
*
|
|
@@ -125,7 +116,7 @@ declare module Immutable {
|
|
|
125
116
|
* List.isList(List()); // true
|
|
126
117
|
* ```
|
|
127
118
|
*/
|
|
128
|
-
function isList(maybeList:
|
|
119
|
+
function isList(maybeList: unknown): maybeList is List<unknown>;
|
|
129
120
|
|
|
130
121
|
/**
|
|
131
122
|
* Creates a new List containing `values`.
|
|
@@ -180,12 +171,11 @@ declare module Immutable {
|
|
|
180
171
|
* listFromPlainSet.equals(listFromPlainArray) // true
|
|
181
172
|
* ```
|
|
182
173
|
*/
|
|
183
|
-
export function List(): List<any>;
|
|
184
|
-
export function List<T>(): List<T>;
|
|
185
174
|
export function List<T>(collection: Iterable<T>): List<T>;
|
|
175
|
+
export function List<T>(): List<T>;
|
|
176
|
+
export function List(): List<unknown>;
|
|
186
177
|
|
|
187
178
|
export interface List<T> extends Collection.Indexed<T> {
|
|
188
|
-
|
|
189
179
|
/**
|
|
190
180
|
* The number of items in this List.
|
|
191
181
|
*/
|
|
@@ -402,7 +392,7 @@ declare module Immutable {
|
|
|
402
392
|
* @see `Map#update`
|
|
403
393
|
*/
|
|
404
394
|
update(index: number, notSetValue: T, updater: (value: T) => T): this;
|
|
405
|
-
update(index: number, updater: (value: T) => T): this;
|
|
395
|
+
update(index: number, updater: (value: T | undefined) => T): this;
|
|
406
396
|
update<R>(updater: (value: this) => R): R;
|
|
407
397
|
|
|
408
398
|
/**
|
|
@@ -417,7 +407,6 @@ declare module Immutable {
|
|
|
417
407
|
*/
|
|
418
408
|
setSize(size: number): List<T>;
|
|
419
409
|
|
|
420
|
-
|
|
421
410
|
// Deep persistent changes
|
|
422
411
|
|
|
423
412
|
/**
|
|
@@ -449,7 +438,7 @@ declare module Immutable {
|
|
|
449
438
|
*
|
|
450
439
|
* Note: `setIn` can be used in `withMutations`.
|
|
451
440
|
*/
|
|
452
|
-
setIn(keyPath: Iterable<
|
|
441
|
+
setIn(keyPath: Iterable<unknown>, value: unknown): this;
|
|
453
442
|
|
|
454
443
|
/**
|
|
455
444
|
* Returns a new List having removed the value at this `keyPath`. If any
|
|
@@ -479,30 +468,40 @@ declare module Immutable {
|
|
|
479
468
|
*
|
|
480
469
|
* @alias removeIn
|
|
481
470
|
*/
|
|
482
|
-
deleteIn(keyPath: Iterable<
|
|
483
|
-
removeIn(keyPath: Iterable<
|
|
471
|
+
deleteIn(keyPath: Iterable<unknown>): this;
|
|
472
|
+
removeIn(keyPath: Iterable<unknown>): this;
|
|
484
473
|
|
|
485
474
|
/**
|
|
486
475
|
* Note: `updateIn` can be used in `withMutations`.
|
|
487
476
|
*
|
|
488
477
|
* @see `Map#updateIn`
|
|
489
478
|
*/
|
|
490
|
-
updateIn(
|
|
491
|
-
|
|
479
|
+
updateIn(
|
|
480
|
+
keyPath: Iterable<unknown>,
|
|
481
|
+
notSetValue: unknown,
|
|
482
|
+
updater: (value: unknown) => unknown
|
|
483
|
+
): this;
|
|
484
|
+
updateIn(
|
|
485
|
+
keyPath: Iterable<unknown>,
|
|
486
|
+
updater: (value: unknown) => unknown
|
|
487
|
+
): this;
|
|
492
488
|
|
|
493
489
|
/**
|
|
494
490
|
* Note: `mergeIn` can be used in `withMutations`.
|
|
495
491
|
*
|
|
496
492
|
* @see `Map#mergeIn`
|
|
497
493
|
*/
|
|
498
|
-
mergeIn(keyPath: Iterable<
|
|
494
|
+
mergeIn(keyPath: Iterable<unknown>, ...collections: Array<unknown>): this;
|
|
499
495
|
|
|
500
496
|
/**
|
|
501
497
|
* Note: `mergeDeepIn` can be used in `withMutations`.
|
|
502
498
|
*
|
|
503
499
|
* @see `Map#mergeDeepIn`
|
|
504
500
|
*/
|
|
505
|
-
mergeDeepIn(
|
|
501
|
+
mergeDeepIn(
|
|
502
|
+
keyPath: Iterable<unknown>,
|
|
503
|
+
...collections: Array<unknown>
|
|
504
|
+
): this;
|
|
506
505
|
|
|
507
506
|
// Transient changes
|
|
508
507
|
|
|
@@ -513,7 +512,7 @@ declare module Immutable {
|
|
|
513
512
|
*
|
|
514
513
|
* @see `Map#withMutations`
|
|
515
514
|
*/
|
|
516
|
-
withMutations(mutator: (mutable: this) =>
|
|
515
|
+
withMutations(mutator: (mutable: this) => unknown): this;
|
|
517
516
|
|
|
518
517
|
/**
|
|
519
518
|
* An alternative API for withMutations()
|
|
@@ -562,7 +561,7 @@ declare module Immutable {
|
|
|
562
561
|
*/
|
|
563
562
|
map<M>(
|
|
564
563
|
mapper: (value: T, key: number, iter: this) => M,
|
|
565
|
-
context?:
|
|
564
|
+
context?: unknown
|
|
566
565
|
): List<M>;
|
|
567
566
|
|
|
568
567
|
/**
|
|
@@ -572,7 +571,7 @@ declare module Immutable {
|
|
|
572
571
|
*/
|
|
573
572
|
flatMap<M>(
|
|
574
573
|
mapper: (value: T, key: number, iter: this) => Iterable<M>,
|
|
575
|
-
context?:
|
|
574
|
+
context?: unknown
|
|
576
575
|
): List<M>;
|
|
577
576
|
|
|
578
577
|
/**
|
|
@@ -584,11 +583,11 @@ declare module Immutable {
|
|
|
584
583
|
*/
|
|
585
584
|
filter<F extends T>(
|
|
586
585
|
predicate: (value: T, index: number, iter: this) => value is F,
|
|
587
|
-
context?:
|
|
586
|
+
context?: unknown
|
|
588
587
|
): List<F>;
|
|
589
588
|
filter(
|
|
590
|
-
predicate: (value: T, index: number, iter: this) =>
|
|
591
|
-
context?:
|
|
589
|
+
predicate: (value: T, index: number, iter: this) => unknown,
|
|
590
|
+
context?: unknown
|
|
592
591
|
): this;
|
|
593
592
|
|
|
594
593
|
/**
|
|
@@ -605,9 +604,12 @@ declare module Immutable {
|
|
|
605
604
|
* const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
|
|
606
605
|
* ```
|
|
607
606
|
*/
|
|
608
|
-
zip<U>(other: Collection<
|
|
609
|
-
zip<U,V>(
|
|
610
|
-
|
|
607
|
+
zip<U>(other: Collection<unknown, U>): List<[T, U]>;
|
|
608
|
+
zip<U, V>(
|
|
609
|
+
other: Collection<unknown, U>,
|
|
610
|
+
other2: Collection<unknown, V>
|
|
611
|
+
): List<[T, U, V]>;
|
|
612
|
+
zip(...collections: Array<Collection<unknown, unknown>>): List<unknown>;
|
|
611
613
|
|
|
612
614
|
/**
|
|
613
615
|
* Returns a List "zipped" with the provided collections.
|
|
@@ -628,9 +630,12 @@ declare module Immutable {
|
|
|
628
630
|
* input, some results may contain undefined values. TypeScript cannot
|
|
629
631
|
* account for these without cases (as of v2.5).
|
|
630
632
|
*/
|
|
631
|
-
zipAll<U>(other: Collection<
|
|
632
|
-
zipAll<U,V>(
|
|
633
|
-
|
|
633
|
+
zipAll<U>(other: Collection<unknown, U>): List<[T, U]>;
|
|
634
|
+
zipAll<U, V>(
|
|
635
|
+
other: Collection<unknown, U>,
|
|
636
|
+
other2: Collection<unknown, V>
|
|
637
|
+
): List<[T, U, V]>;
|
|
638
|
+
zipAll(...collections: Array<Collection<unknown, unknown>>): List<unknown>;
|
|
634
639
|
|
|
635
640
|
/**
|
|
636
641
|
* Returns a List "zipped" with the provided collections by using a
|
|
@@ -648,20 +653,19 @@ declare module Immutable {
|
|
|
648
653
|
*/
|
|
649
654
|
zipWith<U, Z>(
|
|
650
655
|
zipper: (value: T, otherValue: U) => Z,
|
|
651
|
-
otherCollection: Collection<
|
|
656
|
+
otherCollection: Collection<unknown, U>
|
|
652
657
|
): List<Z>;
|
|
653
658
|
zipWith<U, V, Z>(
|
|
654
659
|
zipper: (value: T, otherValue: U, thirdValue: V) => Z,
|
|
655
|
-
otherCollection: Collection<
|
|
656
|
-
thirdCollection: Collection<
|
|
660
|
+
otherCollection: Collection<unknown, U>,
|
|
661
|
+
thirdCollection: Collection<unknown, V>
|
|
657
662
|
): List<Z>;
|
|
658
663
|
zipWith<Z>(
|
|
659
|
-
zipper: (...any: Array<
|
|
660
|
-
...collections: Array<Collection<
|
|
664
|
+
zipper: (...any: Array<unknown>) => Z,
|
|
665
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
661
666
|
): List<Z>;
|
|
662
667
|
}
|
|
663
668
|
|
|
664
|
-
|
|
665
669
|
/**
|
|
666
670
|
* Immutable Map is an unordered Collection.Keyed of (key, value) pairs with
|
|
667
671
|
* `O(log32 N)` gets and `O(log32 N)` persistent sets.
|
|
@@ -690,7 +694,6 @@ declare module Immutable {
|
|
|
690
694
|
* Implemented by a hash-array mapped trie.
|
|
691
695
|
*/
|
|
692
696
|
export module Map {
|
|
693
|
-
|
|
694
697
|
/**
|
|
695
698
|
* True if the provided value is a Map
|
|
696
699
|
*
|
|
@@ -701,7 +704,7 @@ declare module Immutable {
|
|
|
701
704
|
* Map.isMap(Map()) // true
|
|
702
705
|
* ```
|
|
703
706
|
*/
|
|
704
|
-
function isMap(maybeMap:
|
|
707
|
+
function isMap(maybeMap: unknown): maybeMap is Map<unknown, unknown>;
|
|
705
708
|
|
|
706
709
|
/**
|
|
707
710
|
* Creates a new Map from alternating keys and values
|
|
@@ -719,7 +722,7 @@ declare module Immutable {
|
|
|
719
722
|
*
|
|
720
723
|
* @deprecated Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' })
|
|
721
724
|
*/
|
|
722
|
-
function of(...keyValues: Array<
|
|
725
|
+
function of(...keyValues: Array<unknown>): Map<unknown, unknown>;
|
|
723
726
|
}
|
|
724
727
|
|
|
725
728
|
/**
|
|
@@ -758,13 +761,13 @@ declare module Immutable {
|
|
|
758
761
|
* but since Immutable Map keys can be of any type the argument to `get()` is
|
|
759
762
|
* not altered.
|
|
760
763
|
*/
|
|
761
|
-
export function Map
|
|
762
|
-
export function Map<V>(obj: {[key: string]: V}): Map<string, V>;
|
|
764
|
+
export function Map(): Map<unknown, unknown>;
|
|
763
765
|
export function Map<K, V>(): Map<K, V>;
|
|
764
|
-
export function Map(): Map<
|
|
766
|
+
export function Map<K, V>(collection: Iterable<[K, V]>): Map<K, V>;
|
|
767
|
+
export function Map<V>(obj: { [key: string]: V }): Map<string, V>;
|
|
768
|
+
export function Map<K extends string, V>(obj: { [P in K]?: V }): Map<K, V>;
|
|
765
769
|
|
|
766
770
|
export interface Map<K, V> extends Collection.Keyed<K, V> {
|
|
767
|
-
|
|
768
771
|
/**
|
|
769
772
|
* The number of entries in this Map.
|
|
770
773
|
*/
|
|
@@ -955,7 +958,7 @@ declare module Immutable {
|
|
|
955
958
|
* Note: `update(key)` can be used in `withMutations`.
|
|
956
959
|
*/
|
|
957
960
|
update(key: K, notSetValue: V, updater: (value: V) => V): this;
|
|
958
|
-
update(key: K, updater: (value: V) => V): this;
|
|
961
|
+
update(key: K, updater: (value: V | undefined) => V): this;
|
|
959
962
|
update<R>(updater: (value: this) => R): R;
|
|
960
963
|
|
|
961
964
|
/**
|
|
@@ -979,10 +982,18 @@ declare module Immutable {
|
|
|
979
982
|
*
|
|
980
983
|
* @alias concat
|
|
981
984
|
*/
|
|
982
|
-
merge<KC, VC>(
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
985
|
+
merge<KC, VC>(
|
|
986
|
+
...collections: Array<Iterable<[KC, VC]>>
|
|
987
|
+
): Map<K | KC, V | VC>;
|
|
988
|
+
merge<C>(
|
|
989
|
+
...collections: Array<{ [key: string]: C }>
|
|
990
|
+
): Map<K | string, V | C>;
|
|
991
|
+
concat<KC, VC>(
|
|
992
|
+
...collections: Array<Iterable<[KC, VC]>>
|
|
993
|
+
): Map<K | KC, V | VC>;
|
|
994
|
+
concat<C>(
|
|
995
|
+
...collections: Array<{ [key: string]: C }>
|
|
996
|
+
): Map<K | string, V | C>;
|
|
986
997
|
|
|
987
998
|
/**
|
|
988
999
|
* Like `merge()`, `mergeWith()` returns a new Map resulting from merging
|
|
@@ -1004,7 +1015,7 @@ declare module Immutable {
|
|
|
1004
1015
|
*/
|
|
1005
1016
|
mergeWith(
|
|
1006
1017
|
merger: (oldVal: V, newVal: V, key: K) => V,
|
|
1007
|
-
...collections: Array<Iterable<[K, V]> | {[key: string]: V}>
|
|
1018
|
+
...collections: Array<Iterable<[K, V]> | { [key: string]: V }>
|
|
1008
1019
|
): this;
|
|
1009
1020
|
|
|
1010
1021
|
/**
|
|
@@ -1030,7 +1041,9 @@ declare module Immutable {
|
|
|
1030
1041
|
*
|
|
1031
1042
|
* Note: `mergeDeep` can be used in `withMutations`.
|
|
1032
1043
|
*/
|
|
1033
|
-
mergeDeep(
|
|
1044
|
+
mergeDeep(
|
|
1045
|
+
...collections: Array<Iterable<[K, V]> | { [key: string]: V }>
|
|
1046
|
+
): this;
|
|
1034
1047
|
|
|
1035
1048
|
/**
|
|
1036
1049
|
* Like `mergeDeep()`, but when two non-Collections conflict, it uses the
|
|
@@ -1052,11 +1065,10 @@ declare module Immutable {
|
|
|
1052
1065
|
* Note: `mergeDeepWith` can be used in `withMutations`.
|
|
1053
1066
|
*/
|
|
1054
1067
|
mergeDeepWith(
|
|
1055
|
-
merger: (oldVal:
|
|
1056
|
-
...collections: Array<Iterable<[K, V]> | {[key: string]: V}>
|
|
1068
|
+
merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
|
|
1069
|
+
...collections: Array<Iterable<[K, V]> | { [key: string]: V }>
|
|
1057
1070
|
): this;
|
|
1058
1071
|
|
|
1059
|
-
|
|
1060
1072
|
// Deep persistent changes
|
|
1061
1073
|
|
|
1062
1074
|
/**
|
|
@@ -1125,7 +1137,7 @@ declare module Immutable {
|
|
|
1125
1137
|
*
|
|
1126
1138
|
* Note: `setIn` can be used in `withMutations`.
|
|
1127
1139
|
*/
|
|
1128
|
-
setIn(keyPath: Iterable<
|
|
1140
|
+
setIn(keyPath: Iterable<unknown>, value: unknown): this;
|
|
1129
1141
|
|
|
1130
1142
|
/**
|
|
1131
1143
|
* Returns a new Map having removed the value at this `keyPath`. If any keys
|
|
@@ -1135,8 +1147,8 @@ declare module Immutable {
|
|
|
1135
1147
|
*
|
|
1136
1148
|
* @alias removeIn
|
|
1137
1149
|
*/
|
|
1138
|
-
deleteIn(keyPath: Iterable<
|
|
1139
|
-
removeIn(keyPath: Iterable<
|
|
1150
|
+
deleteIn(keyPath: Iterable<unknown>): this;
|
|
1151
|
+
removeIn(keyPath: Iterable<unknown>): this;
|
|
1140
1152
|
|
|
1141
1153
|
/**
|
|
1142
1154
|
* Returns a new Map having applied the `updater` to the entry found at the
|
|
@@ -1214,8 +1226,15 @@ declare module Immutable {
|
|
|
1214
1226
|
*
|
|
1215
1227
|
* Note: `updateIn` can be used in `withMutations`.
|
|
1216
1228
|
*/
|
|
1217
|
-
updateIn(
|
|
1218
|
-
|
|
1229
|
+
updateIn(
|
|
1230
|
+
keyPath: Iterable<unknown>,
|
|
1231
|
+
notSetValue: unknown,
|
|
1232
|
+
updater: (value: unknown) => unknown
|
|
1233
|
+
): this;
|
|
1234
|
+
updateIn(
|
|
1235
|
+
keyPath: Iterable<unknown>,
|
|
1236
|
+
updater: (value: unknown) => unknown
|
|
1237
|
+
): this;
|
|
1219
1238
|
|
|
1220
1239
|
/**
|
|
1221
1240
|
* A combination of `updateIn` and `merge`, returning a new Map, but
|
|
@@ -1229,7 +1248,7 @@ declare module Immutable {
|
|
|
1229
1248
|
*
|
|
1230
1249
|
* Note: `mergeIn` can be used in `withMutations`.
|
|
1231
1250
|
*/
|
|
1232
|
-
mergeIn(keyPath: Iterable<
|
|
1251
|
+
mergeIn(keyPath: Iterable<unknown>, ...collections: Array<unknown>): this;
|
|
1233
1252
|
|
|
1234
1253
|
/**
|
|
1235
1254
|
* A combination of `updateIn` and `mergeDeep`, returning a new Map, but
|
|
@@ -1243,7 +1262,10 @@ declare module Immutable {
|
|
|
1243
1262
|
*
|
|
1244
1263
|
* Note: `mergeDeepIn` can be used in `withMutations`.
|
|
1245
1264
|
*/
|
|
1246
|
-
mergeDeepIn(
|
|
1265
|
+
mergeDeepIn(
|
|
1266
|
+
keyPath: Iterable<unknown>,
|
|
1267
|
+
...collections: Array<unknown>
|
|
1268
|
+
): this;
|
|
1247
1269
|
|
|
1248
1270
|
// Transient changes
|
|
1249
1271
|
|
|
@@ -1275,7 +1297,7 @@ declare module Immutable {
|
|
|
1275
1297
|
* `withMutations`! Read the documentation for each method to see if it
|
|
1276
1298
|
* is safe to use in `withMutations`.
|
|
1277
1299
|
*/
|
|
1278
|
-
withMutations(mutator: (mutable: this) =>
|
|
1300
|
+
withMutations(mutator: (mutable: this) => unknown): this;
|
|
1279
1301
|
|
|
1280
1302
|
/**
|
|
1281
1303
|
* Another way to avoid creation of intermediate Immutable maps is to create
|
|
@@ -1330,7 +1352,7 @@ declare module Immutable {
|
|
|
1330
1352
|
*/
|
|
1331
1353
|
map<M>(
|
|
1332
1354
|
mapper: (value: V, key: K, iter: this) => M,
|
|
1333
|
-
context?:
|
|
1355
|
+
context?: unknown
|
|
1334
1356
|
): Map<K, M>;
|
|
1335
1357
|
|
|
1336
1358
|
/**
|
|
@@ -1338,15 +1360,15 @@ declare module Immutable {
|
|
|
1338
1360
|
*/
|
|
1339
1361
|
mapKeys<M>(
|
|
1340
1362
|
mapper: (key: K, value: V, iter: this) => M,
|
|
1341
|
-
context?:
|
|
1363
|
+
context?: unknown
|
|
1342
1364
|
): Map<M, V>;
|
|
1343
1365
|
|
|
1344
1366
|
/**
|
|
1345
1367
|
* @see Collection.Keyed.mapEntries
|
|
1346
1368
|
*/
|
|
1347
1369
|
mapEntries<KM, VM>(
|
|
1348
|
-
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
|
|
1349
|
-
context?:
|
|
1370
|
+
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined,
|
|
1371
|
+
context?: unknown
|
|
1350
1372
|
): Map<KM, VM>;
|
|
1351
1373
|
|
|
1352
1374
|
/**
|
|
@@ -1356,7 +1378,7 @@ declare module Immutable {
|
|
|
1356
1378
|
*/
|
|
1357
1379
|
flatMap<KM, VM>(
|
|
1358
1380
|
mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
|
|
1359
|
-
context?:
|
|
1381
|
+
context?: unknown
|
|
1360
1382
|
): Map<KM, VM>;
|
|
1361
1383
|
|
|
1362
1384
|
/**
|
|
@@ -1368,11 +1390,11 @@ declare module Immutable {
|
|
|
1368
1390
|
*/
|
|
1369
1391
|
filter<F extends V>(
|
|
1370
1392
|
predicate: (value: V, key: K, iter: this) => value is F,
|
|
1371
|
-
context?:
|
|
1393
|
+
context?: unknown
|
|
1372
1394
|
): Map<K, F>;
|
|
1373
1395
|
filter(
|
|
1374
|
-
predicate: (value: V, key: K, iter: this) =>
|
|
1375
|
-
context?:
|
|
1396
|
+
predicate: (value: V, key: K, iter: this) => unknown,
|
|
1397
|
+
context?: unknown
|
|
1376
1398
|
): this;
|
|
1377
1399
|
|
|
1378
1400
|
/**
|
|
@@ -1381,7 +1403,6 @@ declare module Immutable {
|
|
|
1381
1403
|
flip(): Map<V, K>;
|
|
1382
1404
|
}
|
|
1383
1405
|
|
|
1384
|
-
|
|
1385
1406
|
/**
|
|
1386
1407
|
* A type of Map that has the additional guarantee that the iteration order of
|
|
1387
1408
|
* entries will be the order in which they were set().
|
|
@@ -1395,11 +1416,12 @@ declare module Immutable {
|
|
|
1395
1416
|
*/
|
|
1396
1417
|
|
|
1397
1418
|
export module OrderedMap {
|
|
1398
|
-
|
|
1399
1419
|
/**
|
|
1400
1420
|
* True if the provided value is an OrderedMap.
|
|
1401
1421
|
*/
|
|
1402
|
-
function isOrderedMap(
|
|
1422
|
+
function isOrderedMap(
|
|
1423
|
+
maybeOrderedMap: unknown
|
|
1424
|
+
): maybeOrderedMap is OrderedMap<unknown, unknown>;
|
|
1403
1425
|
}
|
|
1404
1426
|
|
|
1405
1427
|
/**
|
|
@@ -1417,13 +1439,16 @@ declare module Immutable {
|
|
|
1417
1439
|
* Note: `OrderedMap` is a factory function and not a class, and does not use
|
|
1418
1440
|
* the `new` keyword during construction.
|
|
1419
1441
|
*/
|
|
1420
|
-
export function OrderedMap
|
|
1421
|
-
export function OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V>;
|
|
1442
|
+
export function OrderedMap(): OrderedMap<unknown, unknown>;
|
|
1422
1443
|
export function OrderedMap<K, V>(): OrderedMap<K, V>;
|
|
1423
|
-
export function OrderedMap
|
|
1444
|
+
export function OrderedMap<K, V>(
|
|
1445
|
+
collection: Iterable<[K, V]>
|
|
1446
|
+
): OrderedMap<K, V>;
|
|
1447
|
+
export function OrderedMap<V>(obj: {
|
|
1448
|
+
[key: string]: V;
|
|
1449
|
+
}): OrderedMap<string, V>;
|
|
1424
1450
|
|
|
1425
1451
|
export interface OrderedMap<K, V> extends Map<K, V> {
|
|
1426
|
-
|
|
1427
1452
|
/**
|
|
1428
1453
|
* The number of entries in this OrderedMap.
|
|
1429
1454
|
*/
|
|
@@ -1471,10 +1496,18 @@ declare module Immutable {
|
|
|
1471
1496
|
*
|
|
1472
1497
|
* @alias concat
|
|
1473
1498
|
*/
|
|
1474
|
-
merge<KC, VC>(
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1499
|
+
merge<KC, VC>(
|
|
1500
|
+
...collections: Array<Iterable<[KC, VC]>>
|
|
1501
|
+
): OrderedMap<K | KC, V | VC>;
|
|
1502
|
+
merge<C>(
|
|
1503
|
+
...collections: Array<{ [key: string]: C }>
|
|
1504
|
+
): OrderedMap<K | string, V | C>;
|
|
1505
|
+
concat<KC, VC>(
|
|
1506
|
+
...collections: Array<Iterable<[KC, VC]>>
|
|
1507
|
+
): OrderedMap<K | KC, V | VC>;
|
|
1508
|
+
concat<C>(
|
|
1509
|
+
...collections: Array<{ [key: string]: C }>
|
|
1510
|
+
): OrderedMap<K | string, V | C>;
|
|
1478
1511
|
|
|
1479
1512
|
// Sequence algorithms
|
|
1480
1513
|
|
|
@@ -1490,7 +1523,7 @@ declare module Immutable {
|
|
|
1490
1523
|
*/
|
|
1491
1524
|
map<M>(
|
|
1492
1525
|
mapper: (value: V, key: K, iter: this) => M,
|
|
1493
|
-
context?:
|
|
1526
|
+
context?: unknown
|
|
1494
1527
|
): OrderedMap<K, M>;
|
|
1495
1528
|
|
|
1496
1529
|
/**
|
|
@@ -1498,15 +1531,15 @@ declare module Immutable {
|
|
|
1498
1531
|
*/
|
|
1499
1532
|
mapKeys<M>(
|
|
1500
1533
|
mapper: (key: K, value: V, iter: this) => M,
|
|
1501
|
-
context?:
|
|
1534
|
+
context?: unknown
|
|
1502
1535
|
): OrderedMap<M, V>;
|
|
1503
1536
|
|
|
1504
1537
|
/**
|
|
1505
1538
|
* @see Collection.Keyed.mapEntries
|
|
1506
1539
|
*/
|
|
1507
1540
|
mapEntries<KM, VM>(
|
|
1508
|
-
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
|
|
1509
|
-
context?:
|
|
1541
|
+
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined,
|
|
1542
|
+
context?: unknown
|
|
1510
1543
|
): OrderedMap<KM, VM>;
|
|
1511
1544
|
|
|
1512
1545
|
/**
|
|
@@ -1516,7 +1549,7 @@ declare module Immutable {
|
|
|
1516
1549
|
*/
|
|
1517
1550
|
flatMap<KM, VM>(
|
|
1518
1551
|
mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
|
|
1519
|
-
context?:
|
|
1552
|
+
context?: unknown
|
|
1520
1553
|
): OrderedMap<KM, VM>;
|
|
1521
1554
|
|
|
1522
1555
|
/**
|
|
@@ -1528,11 +1561,11 @@ declare module Immutable {
|
|
|
1528
1561
|
*/
|
|
1529
1562
|
filter<F extends V>(
|
|
1530
1563
|
predicate: (value: V, key: K, iter: this) => value is F,
|
|
1531
|
-
context?:
|
|
1564
|
+
context?: unknown
|
|
1532
1565
|
): OrderedMap<K, F>;
|
|
1533
1566
|
filter(
|
|
1534
|
-
predicate: (value: V, key: K, iter: this) =>
|
|
1535
|
-
context?:
|
|
1567
|
+
predicate: (value: V, key: K, iter: this) => unknown,
|
|
1568
|
+
context?: unknown
|
|
1536
1569
|
): this;
|
|
1537
1570
|
|
|
1538
1571
|
/**
|
|
@@ -1541,7 +1574,6 @@ declare module Immutable {
|
|
|
1541
1574
|
flip(): OrderedMap<V, K>;
|
|
1542
1575
|
}
|
|
1543
1576
|
|
|
1544
|
-
|
|
1545
1577
|
/**
|
|
1546
1578
|
* A Collection of unique values with `O(log32 N)` adds and has.
|
|
1547
1579
|
*
|
|
@@ -1554,11 +1586,10 @@ declare module Immutable {
|
|
|
1554
1586
|
* collections, custom value types, and NaN.
|
|
1555
1587
|
*/
|
|
1556
1588
|
export module Set {
|
|
1557
|
-
|
|
1558
1589
|
/**
|
|
1559
1590
|
* True if the provided value is a Set
|
|
1560
1591
|
*/
|
|
1561
|
-
function isSet(maybeSet:
|
|
1592
|
+
function isSet(maybeSet: unknown): maybeSet is Set<unknown>;
|
|
1562
1593
|
|
|
1563
1594
|
/**
|
|
1564
1595
|
* Creates a new Set containing `values`.
|
|
@@ -1569,8 +1600,8 @@ declare module Immutable {
|
|
|
1569
1600
|
* `Set.fromKeys()` creates a new immutable Set containing the keys from
|
|
1570
1601
|
* this Collection or JavaScript Object.
|
|
1571
1602
|
*/
|
|
1572
|
-
function fromKeys<T>(iter: Collection<T,
|
|
1573
|
-
function fromKeys(obj: {[key: string]:
|
|
1603
|
+
function fromKeys<T>(iter: Collection<T, unknown>): Set<T>;
|
|
1604
|
+
function fromKeys(obj: { [key: string]: unknown }): Set<string>;
|
|
1574
1605
|
|
|
1575
1606
|
/**
|
|
1576
1607
|
* `Set.intersect()` creates a new immutable Set that is the intersection of
|
|
@@ -1582,7 +1613,7 @@ declare module Immutable {
|
|
|
1582
1613
|
* Set([ 'a', 'b', 'c' ])
|
|
1583
1614
|
* Set([ 'c', 'a', 't' ])
|
|
1584
1615
|
* ])
|
|
1585
|
-
* // Set [ "a", "c"
|
|
1616
|
+
* // Set [ "a", "c" ]
|
|
1586
1617
|
* ```
|
|
1587
1618
|
*/
|
|
1588
1619
|
function intersect<T>(sets: Iterable<Iterable<T>>): Set<T>;
|
|
@@ -1597,7 +1628,7 @@ declare module Immutable {
|
|
|
1597
1628
|
* Set([ 'a', 'b', 'c' ])
|
|
1598
1629
|
* Set([ 'c', 'a', 't' ])
|
|
1599
1630
|
* ])
|
|
1600
|
-
* // Set [ "a", "b", "c", "t"
|
|
1631
|
+
* // Set [ "a", "b", "c", "t" ]
|
|
1601
1632
|
* ```
|
|
1602
1633
|
*/
|
|
1603
1634
|
function union<T>(sets: Iterable<Iterable<T>>): Set<T>;
|
|
@@ -1610,12 +1641,11 @@ declare module Immutable {
|
|
|
1610
1641
|
* Note: `Set` is a factory function and not a class, and does not use the
|
|
1611
1642
|
* `new` keyword during construction.
|
|
1612
1643
|
*/
|
|
1613
|
-
export function Set(): Set<any>;
|
|
1614
|
-
export function Set<T>(): Set<T>;
|
|
1615
1644
|
export function Set<T>(collection: Iterable<T>): Set<T>;
|
|
1645
|
+
export function Set<T>(): Set<T>;
|
|
1646
|
+
export function Set(): Set<unknown>;
|
|
1616
1647
|
|
|
1617
1648
|
export interface Set<T> extends Collection.Set<T> {
|
|
1618
|
-
|
|
1619
1649
|
/**
|
|
1620
1650
|
* The number of items in this Set.
|
|
1621
1651
|
*/
|
|
@@ -1684,7 +1714,6 @@ declare module Immutable {
|
|
|
1684
1714
|
*/
|
|
1685
1715
|
subtract(...collections: Array<Iterable<T>>): this;
|
|
1686
1716
|
|
|
1687
|
-
|
|
1688
1717
|
// Transient changes
|
|
1689
1718
|
|
|
1690
1719
|
/**
|
|
@@ -1694,7 +1723,7 @@ declare module Immutable {
|
|
|
1694
1723
|
*
|
|
1695
1724
|
* @see `Map#withMutations`
|
|
1696
1725
|
*/
|
|
1697
|
-
withMutations(mutator: (mutable: this) =>
|
|
1726
|
+
withMutations(mutator: (mutable: this) => unknown): this;
|
|
1698
1727
|
|
|
1699
1728
|
/**
|
|
1700
1729
|
* Note: Not all methods can be used on a mutable collection or within
|
|
@@ -1726,7 +1755,7 @@ declare module Immutable {
|
|
|
1726
1755
|
*/
|
|
1727
1756
|
map<M>(
|
|
1728
1757
|
mapper: (value: T, key: T, iter: this) => M,
|
|
1729
|
-
context?:
|
|
1758
|
+
context?: unknown
|
|
1730
1759
|
): Set<M>;
|
|
1731
1760
|
|
|
1732
1761
|
/**
|
|
@@ -1736,7 +1765,7 @@ declare module Immutable {
|
|
|
1736
1765
|
*/
|
|
1737
1766
|
flatMap<M>(
|
|
1738
1767
|
mapper: (value: T, key: T, iter: this) => Iterable<M>,
|
|
1739
|
-
context?:
|
|
1768
|
+
context?: unknown
|
|
1740
1769
|
): Set<M>;
|
|
1741
1770
|
|
|
1742
1771
|
/**
|
|
@@ -1748,15 +1777,14 @@ declare module Immutable {
|
|
|
1748
1777
|
*/
|
|
1749
1778
|
filter<F extends T>(
|
|
1750
1779
|
predicate: (value: T, key: T, iter: this) => value is F,
|
|
1751
|
-
context?:
|
|
1780
|
+
context?: unknown
|
|
1752
1781
|
): Set<F>;
|
|
1753
1782
|
filter(
|
|
1754
|
-
predicate: (value: T, key: T, iter: this) =>
|
|
1755
|
-
context?:
|
|
1783
|
+
predicate: (value: T, key: T, iter: this) => unknown,
|
|
1784
|
+
context?: unknown
|
|
1756
1785
|
): this;
|
|
1757
1786
|
}
|
|
1758
1787
|
|
|
1759
|
-
|
|
1760
1788
|
/**
|
|
1761
1789
|
* A type of Set that has the additional guarantee that the iteration order of
|
|
1762
1790
|
* values will be the order in which they were `add`ed.
|
|
@@ -1768,11 +1796,10 @@ declare module Immutable {
|
|
|
1768
1796
|
* stable.
|
|
1769
1797
|
*/
|
|
1770
1798
|
export module OrderedSet {
|
|
1771
|
-
|
|
1772
1799
|
/**
|
|
1773
1800
|
* True if the provided value is an OrderedSet.
|
|
1774
1801
|
*/
|
|
1775
|
-
function isOrderedSet(maybeOrderedSet:
|
|
1802
|
+
function isOrderedSet(maybeOrderedSet: unknown): boolean;
|
|
1776
1803
|
|
|
1777
1804
|
/**
|
|
1778
1805
|
* Creates a new OrderedSet containing `values`.
|
|
@@ -1783,8 +1810,8 @@ declare module Immutable {
|
|
|
1783
1810
|
* `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing
|
|
1784
1811
|
* the keys from this Collection or JavaScript Object.
|
|
1785
1812
|
*/
|
|
1786
|
-
function fromKeys<T>(iter: Collection<T,
|
|
1787
|
-
function fromKeys(obj: {[key: string]:
|
|
1813
|
+
function fromKeys<T>(iter: Collection<T, unknown>): OrderedSet<T>;
|
|
1814
|
+
function fromKeys(obj: { [key: string]: unknown }): OrderedSet<string>;
|
|
1788
1815
|
}
|
|
1789
1816
|
|
|
1790
1817
|
/**
|
|
@@ -1794,12 +1821,11 @@ declare module Immutable {
|
|
|
1794
1821
|
* Note: `OrderedSet` is a factory function and not a class, and does not use
|
|
1795
1822
|
* the `new` keyword during construction.
|
|
1796
1823
|
*/
|
|
1797
|
-
export function OrderedSet(): OrderedSet<any>;
|
|
1798
|
-
export function OrderedSet<T>(): OrderedSet<T>;
|
|
1799
1824
|
export function OrderedSet<T>(collection: Iterable<T>): OrderedSet<T>;
|
|
1825
|
+
export function OrderedSet<T>(): OrderedSet<T>;
|
|
1826
|
+
export function OrderedSet(): OrderedSet<unknown>;
|
|
1800
1827
|
|
|
1801
1828
|
export interface OrderedSet<T> extends Set<T> {
|
|
1802
|
-
|
|
1803
1829
|
/**
|
|
1804
1830
|
* The number of items in this OrderedSet.
|
|
1805
1831
|
*/
|
|
@@ -1828,7 +1854,7 @@ declare module Immutable {
|
|
|
1828
1854
|
*/
|
|
1829
1855
|
map<M>(
|
|
1830
1856
|
mapper: (value: T, key: T, iter: this) => M,
|
|
1831
|
-
context?:
|
|
1857
|
+
context?: unknown
|
|
1832
1858
|
): OrderedSet<M>;
|
|
1833
1859
|
|
|
1834
1860
|
/**
|
|
@@ -1838,7 +1864,7 @@ declare module Immutable {
|
|
|
1838
1864
|
*/
|
|
1839
1865
|
flatMap<M>(
|
|
1840
1866
|
mapper: (value: T, key: T, iter: this) => Iterable<M>,
|
|
1841
|
-
context?:
|
|
1867
|
+
context?: unknown
|
|
1842
1868
|
): OrderedSet<M>;
|
|
1843
1869
|
|
|
1844
1870
|
/**
|
|
@@ -1850,11 +1876,11 @@ declare module Immutable {
|
|
|
1850
1876
|
*/
|
|
1851
1877
|
filter<F extends T>(
|
|
1852
1878
|
predicate: (value: T, key: T, iter: this) => value is F,
|
|
1853
|
-
context?:
|
|
1879
|
+
context?: unknown
|
|
1854
1880
|
): OrderedSet<F>;
|
|
1855
1881
|
filter(
|
|
1856
|
-
predicate: (value: T, key: T, iter: this) =>
|
|
1857
|
-
context?:
|
|
1882
|
+
predicate: (value: T, key: T, iter: this) => unknown,
|
|
1883
|
+
context?: unknown
|
|
1858
1884
|
): this;
|
|
1859
1885
|
|
|
1860
1886
|
/**
|
|
@@ -1870,9 +1896,14 @@ declare module Immutable {
|
|
|
1870
1896
|
* // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
|
|
1871
1897
|
* ```
|
|
1872
1898
|
*/
|
|
1873
|
-
zip<U>(other: Collection<
|
|
1874
|
-
zip<U,V>(
|
|
1875
|
-
|
|
1899
|
+
zip<U>(other: Collection<unknown, U>): OrderedSet<[T, U]>;
|
|
1900
|
+
zip<U, V>(
|
|
1901
|
+
other1: Collection<unknown, U>,
|
|
1902
|
+
other2: Collection<unknown, V>
|
|
1903
|
+
): OrderedSet<[T, U, V]>;
|
|
1904
|
+
zip(
|
|
1905
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
1906
|
+
): OrderedSet<unknown>;
|
|
1876
1907
|
|
|
1877
1908
|
/**
|
|
1878
1909
|
* Returns a OrderedSet of the same type "zipped" with the provided
|
|
@@ -1891,9 +1922,14 @@ declare module Immutable {
|
|
|
1891
1922
|
* input, some results may contain undefined values. TypeScript cannot
|
|
1892
1923
|
* account for these without cases (as of v2.5).
|
|
1893
1924
|
*/
|
|
1894
|
-
zipAll<U>(other: Collection<
|
|
1895
|
-
zipAll<U,V>(
|
|
1896
|
-
|
|
1925
|
+
zipAll<U>(other: Collection<unknown, U>): OrderedSet<[T, U]>;
|
|
1926
|
+
zipAll<U, V>(
|
|
1927
|
+
other1: Collection<unknown, U>,
|
|
1928
|
+
other2: Collection<unknown, V>
|
|
1929
|
+
): OrderedSet<[T, U, V]>;
|
|
1930
|
+
zipAll(
|
|
1931
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
1932
|
+
): OrderedSet<unknown>;
|
|
1897
1933
|
|
|
1898
1934
|
/**
|
|
1899
1935
|
* Returns an OrderedSet of the same type "zipped" with the provided
|
|
@@ -1903,21 +1939,19 @@ declare module Immutable {
|
|
|
1903
1939
|
*/
|
|
1904
1940
|
zipWith<U, Z>(
|
|
1905
1941
|
zipper: (value: T, otherValue: U) => Z,
|
|
1906
|
-
otherCollection: Collection<
|
|
1942
|
+
otherCollection: Collection<unknown, U>
|
|
1907
1943
|
): OrderedSet<Z>;
|
|
1908
1944
|
zipWith<U, V, Z>(
|
|
1909
1945
|
zipper: (value: T, otherValue: U, thirdValue: V) => Z,
|
|
1910
|
-
otherCollection: Collection<
|
|
1911
|
-
thirdCollection: Collection<
|
|
1946
|
+
otherCollection: Collection<unknown, U>,
|
|
1947
|
+
thirdCollection: Collection<unknown, V>
|
|
1912
1948
|
): OrderedSet<Z>;
|
|
1913
1949
|
zipWith<Z>(
|
|
1914
|
-
zipper: (...any: Array<
|
|
1915
|
-
...collections: Array<Collection<
|
|
1950
|
+
zipper: (...any: Array<unknown>) => Z,
|
|
1951
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
1916
1952
|
): OrderedSet<Z>;
|
|
1917
|
-
|
|
1918
1953
|
}
|
|
1919
1954
|
|
|
1920
|
-
|
|
1921
1955
|
/**
|
|
1922
1956
|
* Stacks are indexed collections which support very efficient O(1) addition
|
|
1923
1957
|
* and removal from the front using `unshift(v)` and `shift()`.
|
|
@@ -1932,11 +1966,10 @@ declare module Immutable {
|
|
|
1932
1966
|
* Stack is implemented with a Single-Linked List.
|
|
1933
1967
|
*/
|
|
1934
1968
|
export module Stack {
|
|
1935
|
-
|
|
1936
1969
|
/**
|
|
1937
1970
|
* True if the provided value is a Stack
|
|
1938
1971
|
*/
|
|
1939
|
-
function isStack(maybeStack:
|
|
1972
|
+
function isStack(maybeStack: unknown): maybeStack is Stack<unknown>;
|
|
1940
1973
|
|
|
1941
1974
|
/**
|
|
1942
1975
|
* Creates a new Stack containing `values`.
|
|
@@ -1954,12 +1987,11 @@ declare module Immutable {
|
|
|
1954
1987
|
* Note: `Stack` is a factory function and not a class, and does not use the
|
|
1955
1988
|
* `new` keyword during construction.
|
|
1956
1989
|
*/
|
|
1957
|
-
export function Stack(): Stack<any>;
|
|
1958
|
-
export function Stack<T>(): Stack<T>;
|
|
1959
1990
|
export function Stack<T>(collection: Iterable<T>): Stack<T>;
|
|
1991
|
+
export function Stack<T>(): Stack<T>;
|
|
1992
|
+
export function Stack(): Stack<unknown>;
|
|
1960
1993
|
|
|
1961
1994
|
export interface Stack<T> extends Collection.Indexed<T> {
|
|
1962
|
-
|
|
1963
1995
|
/**
|
|
1964
1996
|
* The number of items in this Stack.
|
|
1965
1997
|
*/
|
|
@@ -1972,7 +2004,6 @@ declare module Immutable {
|
|
|
1972
2004
|
*/
|
|
1973
2005
|
peek(): T | undefined;
|
|
1974
2006
|
|
|
1975
|
-
|
|
1976
2007
|
// Persistent changes
|
|
1977
2008
|
|
|
1978
2009
|
/**
|
|
@@ -2026,7 +2057,6 @@ declare module Immutable {
|
|
|
2026
2057
|
*/
|
|
2027
2058
|
pop(): Stack<T>;
|
|
2028
2059
|
|
|
2029
|
-
|
|
2030
2060
|
// Transient changes
|
|
2031
2061
|
|
|
2032
2062
|
/**
|
|
@@ -2036,7 +2066,7 @@ declare module Immutable {
|
|
|
2036
2066
|
*
|
|
2037
2067
|
* @see `Map#withMutations`
|
|
2038
2068
|
*/
|
|
2039
|
-
withMutations(mutator: (mutable: this) =>
|
|
2069
|
+
withMutations(mutator: (mutable: this) => unknown): this;
|
|
2040
2070
|
|
|
2041
2071
|
/**
|
|
2042
2072
|
* Note: Not all methods can be used on a mutable collection or within
|
|
@@ -2076,7 +2106,7 @@ declare module Immutable {
|
|
|
2076
2106
|
*/
|
|
2077
2107
|
map<M>(
|
|
2078
2108
|
mapper: (value: T, key: number, iter: this) => M,
|
|
2079
|
-
context?:
|
|
2109
|
+
context?: unknown
|
|
2080
2110
|
): Stack<M>;
|
|
2081
2111
|
|
|
2082
2112
|
/**
|
|
@@ -2086,7 +2116,7 @@ declare module Immutable {
|
|
|
2086
2116
|
*/
|
|
2087
2117
|
flatMap<M>(
|
|
2088
2118
|
mapper: (value: T, key: number, iter: this) => Iterable<M>,
|
|
2089
|
-
context?:
|
|
2119
|
+
context?: unknown
|
|
2090
2120
|
): Stack<M>;
|
|
2091
2121
|
|
|
2092
2122
|
/**
|
|
@@ -2098,11 +2128,11 @@ declare module Immutable {
|
|
|
2098
2128
|
*/
|
|
2099
2129
|
filter<F extends T>(
|
|
2100
2130
|
predicate: (value: T, index: number, iter: this) => value is F,
|
|
2101
|
-
context?:
|
|
2131
|
+
context?: unknown
|
|
2102
2132
|
): Set<F>;
|
|
2103
2133
|
filter(
|
|
2104
|
-
predicate: (value: T, index: number, iter: this) =>
|
|
2105
|
-
context?:
|
|
2134
|
+
predicate: (value: T, index: number, iter: this) => unknown,
|
|
2135
|
+
context?: unknown
|
|
2106
2136
|
): this;
|
|
2107
2137
|
|
|
2108
2138
|
/**
|
|
@@ -2116,9 +2146,12 @@ declare module Immutable {
|
|
|
2116
2146
|
* const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
|
|
2117
2147
|
* ```
|
|
2118
2148
|
*/
|
|
2119
|
-
zip<U>(other: Collection<
|
|
2120
|
-
zip<U,V>(
|
|
2121
|
-
|
|
2149
|
+
zip<U>(other: Collection<unknown, U>): Stack<[T, U]>;
|
|
2150
|
+
zip<U, V>(
|
|
2151
|
+
other: Collection<unknown, U>,
|
|
2152
|
+
other2: Collection<unknown, V>
|
|
2153
|
+
): Stack<[T, U, V]>;
|
|
2154
|
+
zip(...collections: Array<Collection<unknown, unknown>>): Stack<unknown>;
|
|
2122
2155
|
|
|
2123
2156
|
/**
|
|
2124
2157
|
* Returns a Stack "zipped" with the provided collections.
|
|
@@ -2136,9 +2169,12 @@ declare module Immutable {
|
|
|
2136
2169
|
* input, some results may contain undefined values. TypeScript cannot
|
|
2137
2170
|
* account for these without cases (as of v2.5).
|
|
2138
2171
|
*/
|
|
2139
|
-
zipAll<U>(other: Collection<
|
|
2140
|
-
zipAll<U,V>(
|
|
2141
|
-
|
|
2172
|
+
zipAll<U>(other: Collection<unknown, U>): Stack<[T, U]>;
|
|
2173
|
+
zipAll<U, V>(
|
|
2174
|
+
other: Collection<unknown, U>,
|
|
2175
|
+
other2: Collection<unknown, V>
|
|
2176
|
+
): Stack<[T, U, V]>;
|
|
2177
|
+
zipAll(...collections: Array<Collection<unknown, unknown>>): Stack<unknown>;
|
|
2142
2178
|
|
|
2143
2179
|
/**
|
|
2144
2180
|
* Returns a Stack "zipped" with the provided collections by using a
|
|
@@ -2153,20 +2189,19 @@ declare module Immutable {
|
|
|
2153
2189
|
*/
|
|
2154
2190
|
zipWith<U, Z>(
|
|
2155
2191
|
zipper: (value: T, otherValue: U) => Z,
|
|
2156
|
-
otherCollection: Collection<
|
|
2192
|
+
otherCollection: Collection<unknown, U>
|
|
2157
2193
|
): Stack<Z>;
|
|
2158
2194
|
zipWith<U, V, Z>(
|
|
2159
2195
|
zipper: (value: T, otherValue: U, thirdValue: V) => Z,
|
|
2160
|
-
otherCollection: Collection<
|
|
2161
|
-
thirdCollection: Collection<
|
|
2196
|
+
otherCollection: Collection<unknown, U>,
|
|
2197
|
+
thirdCollection: Collection<unknown, V>
|
|
2162
2198
|
): Stack<Z>;
|
|
2163
2199
|
zipWith<Z>(
|
|
2164
|
-
zipper: (...any: Array<
|
|
2165
|
-
...collections: Array<Collection<
|
|
2200
|
+
zipper: (...any: Array<unknown>) => Z,
|
|
2201
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
2166
2202
|
): Stack<Z>;
|
|
2167
2203
|
}
|
|
2168
2204
|
|
|
2169
|
-
|
|
2170
2205
|
/**
|
|
2171
2206
|
* Returns a Seq.Indexed of numbers from `start` (inclusive) to `end`
|
|
2172
2207
|
* (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to
|
|
@@ -2185,8 +2220,11 @@ declare module Immutable {
|
|
|
2185
2220
|
* Range(30, 30, 5) // []
|
|
2186
2221
|
* ```
|
|
2187
2222
|
*/
|
|
2188
|
-
export function Range(
|
|
2189
|
-
|
|
2223
|
+
export function Range(
|
|
2224
|
+
start?: number,
|
|
2225
|
+
end?: number,
|
|
2226
|
+
step?: number
|
|
2227
|
+
): Seq.Indexed<number>;
|
|
2190
2228
|
|
|
2191
2229
|
/**
|
|
2192
2230
|
* Returns a Seq.Indexed of `value` repeated `times` times. When `times` is
|
|
@@ -2203,7 +2241,6 @@ declare module Immutable {
|
|
|
2203
2241
|
*/
|
|
2204
2242
|
export function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
|
|
2205
2243
|
|
|
2206
|
-
|
|
2207
2244
|
/**
|
|
2208
2245
|
* A record is similar to a JS object, but enforces a specific set of allowed
|
|
2209
2246
|
* string keys, and has default values.
|
|
@@ -2221,12 +2258,10 @@ declare module Immutable {
|
|
|
2221
2258
|
* from a record simply resets it to the default value for that key.
|
|
2222
2259
|
*
|
|
2223
2260
|
* ```js
|
|
2224
|
-
* myRecord.size // 2
|
|
2225
2261
|
* myRecord.get('a') // 1
|
|
2226
2262
|
* myRecord.get('b') // 3
|
|
2227
2263
|
* const myRecordWithoutB = myRecord.remove('b')
|
|
2228
2264
|
* myRecordWithoutB.get('b') // 2
|
|
2229
|
-
* myRecordWithoutB.size // 2
|
|
2230
2265
|
* ```
|
|
2231
2266
|
*
|
|
2232
2267
|
* Values provided to the constructor not found in the Record type will
|
|
@@ -2366,11 +2401,10 @@ declare module Immutable {
|
|
|
2366
2401
|
* consider sticking with plain objects to begin with.
|
|
2367
2402
|
*/
|
|
2368
2403
|
export module Record {
|
|
2369
|
-
|
|
2370
2404
|
/**
|
|
2371
2405
|
* True if `maybeRecord` is an instance of a Record.
|
|
2372
2406
|
*/
|
|
2373
|
-
export function isRecord(maybeRecord:
|
|
2407
|
+
export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>;
|
|
2374
2408
|
|
|
2375
2409
|
/**
|
|
2376
2410
|
* Records allow passing a second parameter to supply a descriptive name
|
|
@@ -2442,8 +2476,12 @@ declare module Immutable {
|
|
|
2442
2476
|
export module Factory {}
|
|
2443
2477
|
|
|
2444
2478
|
export interface Factory<TProps extends Object> {
|
|
2445
|
-
(values?: Partial<TProps> | Iterable<[string,
|
|
2446
|
-
|
|
2479
|
+
(values?: Partial<TProps> | Iterable<[string, unknown]>): Record<TProps> &
|
|
2480
|
+
Readonly<TProps>;
|
|
2481
|
+
new (values?: Partial<TProps> | Iterable<[string, unknown]>): Record<
|
|
2482
|
+
TProps
|
|
2483
|
+
> &
|
|
2484
|
+
Readonly<TProps>;
|
|
2447
2485
|
|
|
2448
2486
|
/**
|
|
2449
2487
|
* The name provided to `Record(values, name)` can be accessed with
|
|
@@ -2452,7 +2490,9 @@ declare module Immutable {
|
|
|
2452
2490
|
displayName: string;
|
|
2453
2491
|
}
|
|
2454
2492
|
|
|
2455
|
-
export function Factory<TProps extends Object>(
|
|
2493
|
+
export function Factory<TProps extends Object>(
|
|
2494
|
+
values?: Partial<TProps> | Iterable<[string, unknown]>
|
|
2495
|
+
): Record<TProps> & Readonly<TProps>;
|
|
2456
2496
|
}
|
|
2457
2497
|
|
|
2458
2498
|
/**
|
|
@@ -2464,10 +2504,12 @@ declare module Immutable {
|
|
|
2464
2504
|
* Note: `Record` is a factory function and not a class, and does not use the
|
|
2465
2505
|
* `new` keyword during construction.
|
|
2466
2506
|
*/
|
|
2467
|
-
export function Record<TProps>(
|
|
2507
|
+
export function Record<TProps>(
|
|
2508
|
+
defaultValues: TProps,
|
|
2509
|
+
name?: string
|
|
2510
|
+
): Record.Factory<TProps>;
|
|
2468
2511
|
|
|
2469
2512
|
export interface Record<TProps extends Object> {
|
|
2470
|
-
|
|
2471
2513
|
// Reading values
|
|
2472
2514
|
|
|
2473
2515
|
has(key: string): key is keyof TProps & string;
|
|
@@ -2480,33 +2522,40 @@ declare module Immutable {
|
|
|
2480
2522
|
* notSetValue will be returned if provided. Note that this scenario would
|
|
2481
2523
|
* produce an error when using Flow or TypeScript.
|
|
2482
2524
|
*/
|
|
2483
|
-
get<K extends keyof TProps>(key: K, notSetValue?:
|
|
2525
|
+
get<K extends keyof TProps>(key: K, notSetValue?: unknown): TProps[K];
|
|
2484
2526
|
get<T>(key: string, notSetValue: T): T;
|
|
2485
2527
|
|
|
2486
2528
|
// Reading deep values
|
|
2487
2529
|
|
|
2488
|
-
hasIn(keyPath: Iterable<
|
|
2489
|
-
getIn(keyPath: Iterable<
|
|
2530
|
+
hasIn(keyPath: Iterable<unknown>): boolean;
|
|
2531
|
+
getIn(keyPath: Iterable<unknown>): unknown;
|
|
2490
2532
|
|
|
2491
2533
|
// Value equality
|
|
2492
2534
|
|
|
2493
|
-
equals(other:
|
|
2535
|
+
equals(other: unknown): boolean;
|
|
2494
2536
|
hashCode(): number;
|
|
2495
2537
|
|
|
2496
2538
|
// Persistent changes
|
|
2497
2539
|
|
|
2498
2540
|
set<K extends keyof TProps>(key: K, value: TProps[K]): this;
|
|
2499
|
-
update<K extends keyof TProps>(
|
|
2500
|
-
|
|
2501
|
-
|
|
2541
|
+
update<K extends keyof TProps>(
|
|
2542
|
+
key: K,
|
|
2543
|
+
updater: (value: TProps[K]) => TProps[K]
|
|
2544
|
+
): this;
|
|
2545
|
+
merge(
|
|
2546
|
+
...collections: Array<Partial<TProps> | Iterable<[string, unknown]>>
|
|
2547
|
+
): this;
|
|
2548
|
+
mergeDeep(
|
|
2549
|
+
...collections: Array<Partial<TProps> | Iterable<[string, unknown]>>
|
|
2550
|
+
): this;
|
|
2502
2551
|
|
|
2503
2552
|
mergeWith(
|
|
2504
|
-
merger: (oldVal:
|
|
2505
|
-
...collections: Array<Partial<TProps> | Iterable<[string,
|
|
2553
|
+
merger: (oldVal: unknown, newVal: unknown, key: keyof TProps) => unknown,
|
|
2554
|
+
...collections: Array<Partial<TProps> | Iterable<[string, unknown]>>
|
|
2506
2555
|
): this;
|
|
2507
2556
|
mergeDeepWith(
|
|
2508
|
-
merger: (oldVal:
|
|
2509
|
-
...collections: Array<Partial<TProps> | Iterable<[string,
|
|
2557
|
+
merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
|
|
2558
|
+
...collections: Array<Partial<TProps> | Iterable<[string, unknown]>>
|
|
2510
2559
|
): this;
|
|
2511
2560
|
|
|
2512
2561
|
/**
|
|
@@ -2526,16 +2575,22 @@ declare module Immutable {
|
|
|
2526
2575
|
|
|
2527
2576
|
// Deep persistent changes
|
|
2528
2577
|
|
|
2529
|
-
setIn(keyPath: Iterable<
|
|
2530
|
-
updateIn(
|
|
2531
|
-
|
|
2532
|
-
|
|
2578
|
+
setIn(keyPath: Iterable<unknown>, value: unknown): this;
|
|
2579
|
+
updateIn(
|
|
2580
|
+
keyPath: Iterable<unknown>,
|
|
2581
|
+
updater: (value: unknown) => unknown
|
|
2582
|
+
): this;
|
|
2583
|
+
mergeIn(keyPath: Iterable<unknown>, ...collections: Array<unknown>): this;
|
|
2584
|
+
mergeDeepIn(
|
|
2585
|
+
keyPath: Iterable<unknown>,
|
|
2586
|
+
...collections: Array<unknown>
|
|
2587
|
+
): this;
|
|
2533
2588
|
|
|
2534
2589
|
/**
|
|
2535
2590
|
* @alias removeIn
|
|
2536
2591
|
*/
|
|
2537
|
-
deleteIn(keyPath: Iterable<
|
|
2538
|
-
removeIn(keyPath: Iterable<
|
|
2592
|
+
deleteIn(keyPath: Iterable<unknown>): this;
|
|
2593
|
+
removeIn(keyPath: Iterable<unknown>): this;
|
|
2539
2594
|
|
|
2540
2595
|
// Conversion to JavaScript types
|
|
2541
2596
|
|
|
@@ -2545,7 +2600,7 @@ declare module Immutable {
|
|
|
2545
2600
|
* Note: This method may not be overridden. Objects with custom
|
|
2546
2601
|
* serialization to plain JS may override toJSON() instead.
|
|
2547
2602
|
*/
|
|
2548
|
-
toJS(): { [K in keyof TProps]:
|
|
2603
|
+
toJS(): { [K in keyof TProps]: unknown };
|
|
2549
2604
|
|
|
2550
2605
|
/**
|
|
2551
2606
|
* Shallowly converts this Record to equivalent native JavaScript Object.
|
|
@@ -2565,7 +2620,7 @@ declare module Immutable {
|
|
|
2565
2620
|
*
|
|
2566
2621
|
* @see `Map#withMutations`
|
|
2567
2622
|
*/
|
|
2568
|
-
withMutations(mutator: (mutable: this) =>
|
|
2623
|
+
withMutations(mutator: (mutable: this) => unknown): this;
|
|
2569
2624
|
|
|
2570
2625
|
/**
|
|
2571
2626
|
* @see `Map#asMutable`
|
|
@@ -2635,7 +2690,7 @@ declare module Immutable {
|
|
|
2635
2690
|
* <!-- runkit:activate -->
|
|
2636
2691
|
* ```js
|
|
2637
2692
|
* const { Map } = require('immutable')
|
|
2638
|
-
* const map = Map({ a: 1, b: 2, c: 3 }
|
|
2693
|
+
* const map = Map({ a: 1, b: 2, c: 3 })
|
|
2639
2694
|
* const lazySeq = Seq(map)
|
|
2640
2695
|
* ```
|
|
2641
2696
|
*
|
|
@@ -2678,8 +2733,12 @@ declare module Immutable {
|
|
|
2678
2733
|
* True if `maybeSeq` is a Seq, it is not backed by a concrete
|
|
2679
2734
|
* structure such as Map, List, or Set.
|
|
2680
2735
|
*/
|
|
2681
|
-
function isSeq(
|
|
2682
|
-
|
|
2736
|
+
function isSeq(
|
|
2737
|
+
maybeSeq: unknown
|
|
2738
|
+
): maybeSeq is
|
|
2739
|
+
| Seq.Indexed<unknown>
|
|
2740
|
+
| Seq.Keyed<unknown, unknown>
|
|
2741
|
+
| Seq.Set<unknown>;
|
|
2683
2742
|
|
|
2684
2743
|
/**
|
|
2685
2744
|
* `Seq` which represents key-value pairs.
|
|
@@ -2694,9 +2753,9 @@ declare module Immutable {
|
|
|
2694
2753
|
* use the `new` keyword during construction.
|
|
2695
2754
|
*/
|
|
2696
2755
|
export function Keyed<K, V>(collection: Iterable<[K, V]>): Seq.Keyed<K, V>;
|
|
2697
|
-
export function Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
|
|
2756
|
+
export function Keyed<V>(obj: { [key: string]: V }): Seq.Keyed<string, V>;
|
|
2698
2757
|
export function Keyed<K, V>(): Seq.Keyed<K, V>;
|
|
2699
|
-
export function Keyed(): Seq.Keyed<
|
|
2758
|
+
export function Keyed(): Seq.Keyed<unknown, unknown>;
|
|
2700
2759
|
|
|
2701
2760
|
export interface Keyed<K, V> extends Seq<K, V>, Collection.Keyed<K, V> {
|
|
2702
2761
|
/**
|
|
@@ -2704,7 +2763,7 @@ declare module Immutable {
|
|
|
2704
2763
|
*
|
|
2705
2764
|
* Converts keys to Strings.
|
|
2706
2765
|
*/
|
|
2707
|
-
toJS():
|
|
2766
|
+
toJS(): { [key: string]: unknown };
|
|
2708
2767
|
|
|
2709
2768
|
/**
|
|
2710
2769
|
* Shallowly converts this Keyed Seq to equivalent native JavaScript Object.
|
|
@@ -2729,8 +2788,12 @@ declare module Immutable {
|
|
|
2729
2788
|
* All entries will be present in the resulting Seq, even if they
|
|
2730
2789
|
* have the same key.
|
|
2731
2790
|
*/
|
|
2732
|
-
concat<KC, VC>(
|
|
2733
|
-
|
|
2791
|
+
concat<KC, VC>(
|
|
2792
|
+
...collections: Array<Iterable<[KC, VC]>>
|
|
2793
|
+
): Seq.Keyed<K | KC, V | VC>;
|
|
2794
|
+
concat<C>(
|
|
2795
|
+
...collections: Array<{ [key: string]: C }>
|
|
2796
|
+
): Seq.Keyed<K | string, V | C>;
|
|
2734
2797
|
|
|
2735
2798
|
/**
|
|
2736
2799
|
* Returns a new Seq.Keyed with values passed through a
|
|
@@ -2747,7 +2810,7 @@ declare module Immutable {
|
|
|
2747
2810
|
*/
|
|
2748
2811
|
map<M>(
|
|
2749
2812
|
mapper: (value: V, key: K, iter: this) => M,
|
|
2750
|
-
context?:
|
|
2813
|
+
context?: unknown
|
|
2751
2814
|
): Seq.Keyed<K, M>;
|
|
2752
2815
|
|
|
2753
2816
|
/**
|
|
@@ -2755,15 +2818,15 @@ declare module Immutable {
|
|
|
2755
2818
|
*/
|
|
2756
2819
|
mapKeys<M>(
|
|
2757
2820
|
mapper: (key: K, value: V, iter: this) => M,
|
|
2758
|
-
context?:
|
|
2821
|
+
context?: unknown
|
|
2759
2822
|
): Seq.Keyed<M, V>;
|
|
2760
2823
|
|
|
2761
2824
|
/**
|
|
2762
2825
|
* @see Collection.Keyed.mapEntries
|
|
2763
2826
|
*/
|
|
2764
2827
|
mapEntries<KM, VM>(
|
|
2765
|
-
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
|
|
2766
|
-
context?:
|
|
2828
|
+
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined,
|
|
2829
|
+
context?: unknown
|
|
2767
2830
|
): Seq.Keyed<KM, VM>;
|
|
2768
2831
|
|
|
2769
2832
|
/**
|
|
@@ -2773,7 +2836,7 @@ declare module Immutable {
|
|
|
2773
2836
|
*/
|
|
2774
2837
|
flatMap<KM, VM>(
|
|
2775
2838
|
mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
|
|
2776
|
-
context?:
|
|
2839
|
+
context?: unknown
|
|
2777
2840
|
): Seq.Keyed<KM, VM>;
|
|
2778
2841
|
|
|
2779
2842
|
/**
|
|
@@ -2785,11 +2848,11 @@ declare module Immutable {
|
|
|
2785
2848
|
*/
|
|
2786
2849
|
filter<F extends V>(
|
|
2787
2850
|
predicate: (value: V, key: K, iter: this) => value is F,
|
|
2788
|
-
context?:
|
|
2851
|
+
context?: unknown
|
|
2789
2852
|
): Seq.Keyed<K, F>;
|
|
2790
2853
|
filter(
|
|
2791
|
-
predicate: (value: V, key: K, iter: this) =>
|
|
2792
|
-
context?:
|
|
2854
|
+
predicate: (value: V, key: K, iter: this) => unknown,
|
|
2855
|
+
context?: unknown
|
|
2793
2856
|
): this;
|
|
2794
2857
|
|
|
2795
2858
|
/**
|
|
@@ -2798,12 +2861,10 @@ declare module Immutable {
|
|
|
2798
2861
|
flip(): Seq.Keyed<V, K>;
|
|
2799
2862
|
}
|
|
2800
2863
|
|
|
2801
|
-
|
|
2802
2864
|
/**
|
|
2803
2865
|
* `Seq` which represents an ordered indexed list of values.
|
|
2804
2866
|
*/
|
|
2805
2867
|
module Indexed {
|
|
2806
|
-
|
|
2807
2868
|
/**
|
|
2808
2869
|
* Provides an Seq.Indexed of the values provided.
|
|
2809
2870
|
*/
|
|
@@ -2817,15 +2878,15 @@ declare module Immutable {
|
|
|
2817
2878
|
* Note: `Seq.Indexed` is a conversion function and not a class, and does
|
|
2818
2879
|
* not use the `new` keyword during construction.
|
|
2819
2880
|
*/
|
|
2820
|
-
export function Indexed(): Seq.Indexed<any>;
|
|
2821
|
-
export function Indexed<T>(): Seq.Indexed<T>;
|
|
2822
2881
|
export function Indexed<T>(collection: Iterable<T>): Seq.Indexed<T>;
|
|
2882
|
+
export function Indexed<T>(): Seq.Indexed<T>;
|
|
2883
|
+
export function Indexed(): Seq.Indexed<unknown>;
|
|
2823
2884
|
|
|
2824
2885
|
export interface Indexed<T> extends Seq<number, T>, Collection.Indexed<T> {
|
|
2825
2886
|
/**
|
|
2826
2887
|
* Deeply converts this Indexed Seq to equivalent native JavaScript Array.
|
|
2827
2888
|
*/
|
|
2828
|
-
toJS(): Array<
|
|
2889
|
+
toJS(): Array<unknown>;
|
|
2829
2890
|
|
|
2830
2891
|
/**
|
|
2831
2892
|
* Shallowly converts this Indexed Seq to equivalent native JavaScript Array.
|
|
@@ -2840,12 +2901,14 @@ declare module Immutable {
|
|
|
2840
2901
|
/**
|
|
2841
2902
|
* Returns itself
|
|
2842
2903
|
*/
|
|
2843
|
-
toSeq(): this
|
|
2904
|
+
toSeq(): this;
|
|
2844
2905
|
|
|
2845
2906
|
/**
|
|
2846
2907
|
* Returns a new Seq with other collections concatenated to this one.
|
|
2847
2908
|
*/
|
|
2848
|
-
concat<C>(
|
|
2909
|
+
concat<C>(
|
|
2910
|
+
...valuesOrCollections: Array<Iterable<C> | C>
|
|
2911
|
+
): Seq.Indexed<T | C>;
|
|
2849
2912
|
|
|
2850
2913
|
/**
|
|
2851
2914
|
* Returns a new Seq.Indexed with values passed through a
|
|
@@ -2862,7 +2925,7 @@ declare module Immutable {
|
|
|
2862
2925
|
*/
|
|
2863
2926
|
map<M>(
|
|
2864
2927
|
mapper: (value: T, key: number, iter: this) => M,
|
|
2865
|
-
context?:
|
|
2928
|
+
context?: unknown
|
|
2866
2929
|
): Seq.Indexed<M>;
|
|
2867
2930
|
|
|
2868
2931
|
/**
|
|
@@ -2872,7 +2935,7 @@ declare module Immutable {
|
|
|
2872
2935
|
*/
|
|
2873
2936
|
flatMap<M>(
|
|
2874
2937
|
mapper: (value: T, key: number, iter: this) => Iterable<M>,
|
|
2875
|
-
context?:
|
|
2938
|
+
context?: unknown
|
|
2876
2939
|
): Seq.Indexed<M>;
|
|
2877
2940
|
|
|
2878
2941
|
/**
|
|
@@ -2884,11 +2947,11 @@ declare module Immutable {
|
|
|
2884
2947
|
*/
|
|
2885
2948
|
filter<F extends T>(
|
|
2886
2949
|
predicate: (value: T, index: number, iter: this) => value is F,
|
|
2887
|
-
context?:
|
|
2950
|
+
context?: unknown
|
|
2888
2951
|
): Seq.Indexed<F>;
|
|
2889
2952
|
filter(
|
|
2890
|
-
predicate: (value: T, index: number, iter: this) =>
|
|
2891
|
-
context?:
|
|
2953
|
+
predicate: (value: T, index: number, iter: this) => unknown,
|
|
2954
|
+
context?: unknown
|
|
2892
2955
|
): this;
|
|
2893
2956
|
|
|
2894
2957
|
/**
|
|
@@ -2902,9 +2965,14 @@ declare module Immutable {
|
|
|
2902
2965
|
* const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
|
|
2903
2966
|
* ```
|
|
2904
2967
|
*/
|
|
2905
|
-
zip<U>(other: Collection<
|
|
2906
|
-
zip<U,V>(
|
|
2907
|
-
|
|
2968
|
+
zip<U>(other: Collection<unknown, U>): Seq.Indexed<[T, U]>;
|
|
2969
|
+
zip<U, V>(
|
|
2970
|
+
other: Collection<unknown, U>,
|
|
2971
|
+
other2: Collection<unknown, V>
|
|
2972
|
+
): Seq.Indexed<[T, U, V]>;
|
|
2973
|
+
zip(
|
|
2974
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
2975
|
+
): Seq.Indexed<unknown>;
|
|
2908
2976
|
|
|
2909
2977
|
/**
|
|
2910
2978
|
* Returns a Seq "zipped" with the provided collections.
|
|
@@ -2918,9 +2986,14 @@ declare module Immutable {
|
|
|
2918
2986
|
* const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
|
|
2919
2987
|
* ```
|
|
2920
2988
|
*/
|
|
2921
|
-
zipAll<U>(other: Collection<
|
|
2922
|
-
zipAll<U,V>(
|
|
2923
|
-
|
|
2989
|
+
zipAll<U>(other: Collection<unknown, U>): Seq.Indexed<[T, U]>;
|
|
2990
|
+
zipAll<U, V>(
|
|
2991
|
+
other: Collection<unknown, U>,
|
|
2992
|
+
other2: Collection<unknown, V>
|
|
2993
|
+
): Seq.Indexed<[T, U, V]>;
|
|
2994
|
+
zipAll(
|
|
2995
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
2996
|
+
): Seq.Indexed<unknown>;
|
|
2924
2997
|
|
|
2925
2998
|
/**
|
|
2926
2999
|
* Returns a Seq "zipped" with the provided collections by using a
|
|
@@ -2935,20 +3008,19 @@ declare module Immutable {
|
|
|
2935
3008
|
*/
|
|
2936
3009
|
zipWith<U, Z>(
|
|
2937
3010
|
zipper: (value: T, otherValue: U) => Z,
|
|
2938
|
-
otherCollection: Collection<
|
|
3011
|
+
otherCollection: Collection<unknown, U>
|
|
2939
3012
|
): Seq.Indexed<Z>;
|
|
2940
3013
|
zipWith<U, V, Z>(
|
|
2941
3014
|
zipper: (value: T, otherValue: U, thirdValue: V) => Z,
|
|
2942
|
-
otherCollection: Collection<
|
|
2943
|
-
thirdCollection: Collection<
|
|
3015
|
+
otherCollection: Collection<unknown, U>,
|
|
3016
|
+
thirdCollection: Collection<unknown, V>
|
|
2944
3017
|
): Seq.Indexed<Z>;
|
|
2945
3018
|
zipWith<Z>(
|
|
2946
|
-
zipper: (...any: Array<
|
|
2947
|
-
...collections: Array<Collection<
|
|
3019
|
+
zipper: (...any: Array<unknown>) => Z,
|
|
3020
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
2948
3021
|
): Seq.Indexed<Z>;
|
|
2949
3022
|
}
|
|
2950
3023
|
|
|
2951
|
-
|
|
2952
3024
|
/**
|
|
2953
3025
|
* `Seq` which represents a set of values.
|
|
2954
3026
|
*
|
|
@@ -2956,7 +3028,6 @@ declare module Immutable {
|
|
|
2956
3028
|
* of value uniqueness as the concrete `Set`.
|
|
2957
3029
|
*/
|
|
2958
3030
|
export module Set {
|
|
2959
|
-
|
|
2960
3031
|
/**
|
|
2961
3032
|
* Returns a Seq.Set of the provided values
|
|
2962
3033
|
*/
|
|
@@ -2969,15 +3040,15 @@ declare module Immutable {
|
|
|
2969
3040
|
* Note: `Seq.Set` is a conversion function and not a class, and does not
|
|
2970
3041
|
* use the `new` keyword during construction.
|
|
2971
3042
|
*/
|
|
2972
|
-
export function Set(): Seq.Set<any>;
|
|
2973
|
-
export function Set<T>(): Seq.Set<T>;
|
|
2974
3043
|
export function Set<T>(collection: Iterable<T>): Seq.Set<T>;
|
|
3044
|
+
export function Set<T>(): Seq.Set<T>;
|
|
3045
|
+
export function Set(): Seq.Set<unknown>;
|
|
2975
3046
|
|
|
2976
3047
|
export interface Set<T> extends Seq<T, T>, Collection.Set<T> {
|
|
2977
3048
|
/**
|
|
2978
3049
|
* Deeply converts this Set Seq to equivalent native JavaScript Array.
|
|
2979
3050
|
*/
|
|
2980
|
-
toJS(): Array<
|
|
3051
|
+
toJS(): Array<unknown>;
|
|
2981
3052
|
|
|
2982
3053
|
/**
|
|
2983
3054
|
* Shallowly converts this Set Seq to equivalent native JavaScript Array.
|
|
@@ -2992,7 +3063,7 @@ declare module Immutable {
|
|
|
2992
3063
|
/**
|
|
2993
3064
|
* Returns itself
|
|
2994
3065
|
*/
|
|
2995
|
-
toSeq(): this
|
|
3066
|
+
toSeq(): this;
|
|
2996
3067
|
|
|
2997
3068
|
/**
|
|
2998
3069
|
* Returns a new Seq with other collections concatenated to this one.
|
|
@@ -3016,7 +3087,7 @@ declare module Immutable {
|
|
|
3016
3087
|
*/
|
|
3017
3088
|
map<M>(
|
|
3018
3089
|
mapper: (value: T, key: T, iter: this) => M,
|
|
3019
|
-
context?:
|
|
3090
|
+
context?: unknown
|
|
3020
3091
|
): Seq.Set<M>;
|
|
3021
3092
|
|
|
3022
3093
|
/**
|
|
@@ -3026,7 +3097,7 @@ declare module Immutable {
|
|
|
3026
3097
|
*/
|
|
3027
3098
|
flatMap<M>(
|
|
3028
3099
|
mapper: (value: T, key: T, iter: this) => Iterable<M>,
|
|
3029
|
-
context?:
|
|
3100
|
+
context?: unknown
|
|
3030
3101
|
): Seq.Set<M>;
|
|
3031
3102
|
|
|
3032
3103
|
/**
|
|
@@ -3038,14 +3109,13 @@ declare module Immutable {
|
|
|
3038
3109
|
*/
|
|
3039
3110
|
filter<F extends T>(
|
|
3040
3111
|
predicate: (value: T, key: T, iter: this) => value is F,
|
|
3041
|
-
context?:
|
|
3112
|
+
context?: unknown
|
|
3042
3113
|
): Seq.Set<F>;
|
|
3043
3114
|
filter(
|
|
3044
|
-
predicate: (value: T, key: T, iter: this) =>
|
|
3045
|
-
context?:
|
|
3115
|
+
predicate: (value: T, key: T, iter: this) => unknown,
|
|
3116
|
+
context?: unknown
|
|
3046
3117
|
): this;
|
|
3047
3118
|
}
|
|
3048
|
-
|
|
3049
3119
|
}
|
|
3050
3120
|
|
|
3051
3121
|
/**
|
|
@@ -3067,16 +3137,17 @@ declare module Immutable {
|
|
|
3067
3137
|
* Note: `Seq` is a conversion function and not a class, and does not use the
|
|
3068
3138
|
* `new` keyword during construction.
|
|
3069
3139
|
*/
|
|
3070
|
-
export function Seq<S extends Seq<
|
|
3071
|
-
export function Seq<K, V>(
|
|
3140
|
+
export function Seq<S extends Seq<unknown, unknown>>(seq: S): S;
|
|
3141
|
+
export function Seq<K, V>(
|
|
3142
|
+
collection: Collection.Keyed<K, V>
|
|
3143
|
+
): Seq.Keyed<K, V>;
|
|
3072
3144
|
export function Seq<T>(collection: Collection.Indexed<T>): Seq.Indexed<T>;
|
|
3073
3145
|
export function Seq<T>(collection: Collection.Set<T>): Seq.Set<T>;
|
|
3074
3146
|
export function Seq<T>(collection: Iterable<T>): Seq.Indexed<T>;
|
|
3075
|
-
export function Seq<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
|
|
3076
|
-
export function Seq(): Seq<
|
|
3147
|
+
export function Seq<V>(obj: { [key: string]: V }): Seq.Keyed<string, V>;
|
|
3148
|
+
export function Seq(): Seq<unknown, unknown>;
|
|
3077
3149
|
|
|
3078
3150
|
export interface Seq<K, V> extends Collection<K, V> {
|
|
3079
|
-
|
|
3080
3151
|
/**
|
|
3081
3152
|
* Some Seqs can describe their size lazily. When this is the case,
|
|
3082
3153
|
* size will be an integer. Otherwise it will be undefined.
|
|
@@ -3089,7 +3160,6 @@ declare module Immutable {
|
|
|
3089
3160
|
*/
|
|
3090
3161
|
readonly size: number | undefined;
|
|
3091
3162
|
|
|
3092
|
-
|
|
3093
3163
|
// Force evaluation
|
|
3094
3164
|
|
|
3095
3165
|
/**
|
|
@@ -3131,7 +3201,7 @@ declare module Immutable {
|
|
|
3131
3201
|
*/
|
|
3132
3202
|
map<M>(
|
|
3133
3203
|
mapper: (value: V, key: K, iter: this) => M,
|
|
3134
|
-
context?:
|
|
3204
|
+
context?: unknown
|
|
3135
3205
|
): Seq<K, M>;
|
|
3136
3206
|
|
|
3137
3207
|
/**
|
|
@@ -3150,7 +3220,7 @@ declare module Immutable {
|
|
|
3150
3220
|
*/
|
|
3151
3221
|
map<M>(
|
|
3152
3222
|
mapper: (value: V, key: K, iter: this) => M,
|
|
3153
|
-
context?:
|
|
3223
|
+
context?: unknown
|
|
3154
3224
|
): Seq<M, M>;
|
|
3155
3225
|
|
|
3156
3226
|
/**
|
|
@@ -3160,7 +3230,7 @@ declare module Immutable {
|
|
|
3160
3230
|
*/
|
|
3161
3231
|
flatMap<M>(
|
|
3162
3232
|
mapper: (value: V, key: K, iter: this) => Iterable<M>,
|
|
3163
|
-
context?:
|
|
3233
|
+
context?: unknown
|
|
3164
3234
|
): Seq<K, M>;
|
|
3165
3235
|
|
|
3166
3236
|
/**
|
|
@@ -3171,7 +3241,7 @@ declare module Immutable {
|
|
|
3171
3241
|
*/
|
|
3172
3242
|
flatMap<M>(
|
|
3173
3243
|
mapper: (value: V, key: K, iter: this) => Iterable<M>,
|
|
3174
|
-
context?:
|
|
3244
|
+
context?: unknown
|
|
3175
3245
|
): Seq<M, M>;
|
|
3176
3246
|
|
|
3177
3247
|
/**
|
|
@@ -3183,11 +3253,11 @@ declare module Immutable {
|
|
|
3183
3253
|
*/
|
|
3184
3254
|
filter<F extends V>(
|
|
3185
3255
|
predicate: (value: V, key: K, iter: this) => value is F,
|
|
3186
|
-
context?:
|
|
3256
|
+
context?: unknown
|
|
3187
3257
|
): Seq<K, F>;
|
|
3188
3258
|
filter(
|
|
3189
|
-
predicate: (value: V, key: K, iter: this) =>
|
|
3190
|
-
context?:
|
|
3259
|
+
predicate: (value: V, key: K, iter: this) => unknown,
|
|
3260
|
+
context?: unknown
|
|
3191
3261
|
): this;
|
|
3192
3262
|
}
|
|
3193
3263
|
|
|
@@ -3206,27 +3276,33 @@ declare module Immutable {
|
|
|
3206
3276
|
* `Collection.Indexed`, or `Collection.Set`.
|
|
3207
3277
|
*/
|
|
3208
3278
|
export module Collection {
|
|
3209
|
-
|
|
3210
3279
|
/**
|
|
3211
3280
|
* @deprecated use `const { isKeyed } = require('immutable')`
|
|
3212
3281
|
*/
|
|
3213
|
-
function isKeyed(
|
|
3282
|
+
function isKeyed(
|
|
3283
|
+
maybeKeyed: unknown
|
|
3284
|
+
): maybeKeyed is Collection.Keyed<unknown, unknown>;
|
|
3214
3285
|
|
|
3215
3286
|
/**
|
|
3216
3287
|
* @deprecated use `const { isIndexed } = require('immutable')`
|
|
3217
3288
|
*/
|
|
3218
|
-
function isIndexed(
|
|
3289
|
+
function isIndexed(
|
|
3290
|
+
maybeIndexed: unknown
|
|
3291
|
+
): maybeIndexed is Collection.Indexed<unknown>;
|
|
3219
3292
|
|
|
3220
3293
|
/**
|
|
3221
3294
|
* @deprecated use `const { isAssociative } = require('immutable')`
|
|
3222
3295
|
*/
|
|
3223
|
-
function isAssociative(
|
|
3296
|
+
function isAssociative(
|
|
3297
|
+
maybeAssociative: unknown
|
|
3298
|
+
): maybeAssociative is
|
|
3299
|
+
| Collection.Keyed<unknown, unknown>
|
|
3300
|
+
| Collection.Indexed<unknown>;
|
|
3224
3301
|
|
|
3225
3302
|
/**
|
|
3226
3303
|
* @deprecated use `const { isOrdered } = require('immutable')`
|
|
3227
3304
|
*/
|
|
3228
|
-
function isOrdered(maybeOrdered:
|
|
3229
|
-
|
|
3305
|
+
function isOrdered(maybeOrdered: unknown): boolean;
|
|
3230
3306
|
|
|
3231
3307
|
/**
|
|
3232
3308
|
* Keyed Collections have discrete keys tied to each value.
|
|
@@ -3246,8 +3322,12 @@ declare module Immutable {
|
|
|
3246
3322
|
* Note: `Collection.Keyed` is a conversion function and not a class, and
|
|
3247
3323
|
* does not use the `new` keyword during construction.
|
|
3248
3324
|
*/
|
|
3249
|
-
export function Keyed<K, V>(
|
|
3250
|
-
|
|
3325
|
+
export function Keyed<K, V>(
|
|
3326
|
+
collection: Iterable<[K, V]>
|
|
3327
|
+
): Collection.Keyed<K, V>;
|
|
3328
|
+
export function Keyed<V>(obj: {
|
|
3329
|
+
[key: string]: V;
|
|
3330
|
+
}): Collection.Keyed<string, V>;
|
|
3251
3331
|
|
|
3252
3332
|
export interface Keyed<K, V> extends Collection<K, V> {
|
|
3253
3333
|
/**
|
|
@@ -3255,7 +3335,7 @@ declare module Immutable {
|
|
|
3255
3335
|
*
|
|
3256
3336
|
* Converts keys to Strings.
|
|
3257
3337
|
*/
|
|
3258
|
-
toJS():
|
|
3338
|
+
toJS(): { [key: string]: unknown };
|
|
3259
3339
|
|
|
3260
3340
|
/**
|
|
3261
3341
|
* Shallowly converts this Keyed collection to equivalent native JavaScript Object.
|
|
@@ -3275,7 +3355,6 @@ declare module Immutable {
|
|
|
3275
3355
|
*/
|
|
3276
3356
|
toSeq(): Seq.Keyed<K, V>;
|
|
3277
3357
|
|
|
3278
|
-
|
|
3279
3358
|
// Sequence functions
|
|
3280
3359
|
|
|
3281
3360
|
/**
|
|
@@ -3294,8 +3373,12 @@ declare module Immutable {
|
|
|
3294
3373
|
/**
|
|
3295
3374
|
* Returns a new Collection with other collections concatenated to this one.
|
|
3296
3375
|
*/
|
|
3297
|
-
concat<KC, VC>(
|
|
3298
|
-
|
|
3376
|
+
concat<KC, VC>(
|
|
3377
|
+
...collections: Array<Iterable<[KC, VC]>>
|
|
3378
|
+
): Collection.Keyed<K | KC, V | VC>;
|
|
3379
|
+
concat<C>(
|
|
3380
|
+
...collections: Array<{ [key: string]: C }>
|
|
3381
|
+
): Collection.Keyed<K | string, V | C>;
|
|
3299
3382
|
|
|
3300
3383
|
/**
|
|
3301
3384
|
* Returns a new Collection.Keyed with values passed through a
|
|
@@ -3312,7 +3395,7 @@ declare module Immutable {
|
|
|
3312
3395
|
*/
|
|
3313
3396
|
map<M>(
|
|
3314
3397
|
mapper: (value: V, key: K, iter: this) => M,
|
|
3315
|
-
context?:
|
|
3398
|
+
context?: unknown
|
|
3316
3399
|
): Collection.Keyed<K, M>;
|
|
3317
3400
|
|
|
3318
3401
|
/**
|
|
@@ -3331,7 +3414,7 @@ declare module Immutable {
|
|
|
3331
3414
|
*/
|
|
3332
3415
|
mapKeys<M>(
|
|
3333
3416
|
mapper: (key: K, value: V, iter: this) => M,
|
|
3334
|
-
context?:
|
|
3417
|
+
context?: unknown
|
|
3335
3418
|
): Collection.Keyed<M, V>;
|
|
3336
3419
|
|
|
3337
3420
|
/**
|
|
@@ -3348,10 +3431,12 @@ declare module Immutable {
|
|
|
3348
3431
|
*
|
|
3349
3432
|
* Note: `mapEntries()` always returns a new instance, even if it produced
|
|
3350
3433
|
* the same entry at every step.
|
|
3434
|
+
*
|
|
3435
|
+
* If the mapper function returns `undefined`, then the entry will be filtered
|
|
3351
3436
|
*/
|
|
3352
3437
|
mapEntries<KM, VM>(
|
|
3353
|
-
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
|
|
3354
|
-
context?:
|
|
3438
|
+
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined,
|
|
3439
|
+
context?: unknown
|
|
3355
3440
|
): Collection.Keyed<KM, VM>;
|
|
3356
3441
|
|
|
3357
3442
|
/**
|
|
@@ -3361,7 +3446,7 @@ declare module Immutable {
|
|
|
3361
3446
|
*/
|
|
3362
3447
|
flatMap<KM, VM>(
|
|
3363
3448
|
mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
|
|
3364
|
-
context?:
|
|
3449
|
+
context?: unknown
|
|
3365
3450
|
): Collection.Keyed<KM, VM>;
|
|
3366
3451
|
|
|
3367
3452
|
/**
|
|
@@ -3373,17 +3458,16 @@ declare module Immutable {
|
|
|
3373
3458
|
*/
|
|
3374
3459
|
filter<F extends V>(
|
|
3375
3460
|
predicate: (value: V, key: K, iter: this) => value is F,
|
|
3376
|
-
context?:
|
|
3461
|
+
context?: unknown
|
|
3377
3462
|
): Collection.Keyed<K, F>;
|
|
3378
3463
|
filter(
|
|
3379
|
-
predicate: (value: V, key: K, iter: this) =>
|
|
3380
|
-
context?:
|
|
3464
|
+
predicate: (value: V, key: K, iter: this) => unknown,
|
|
3465
|
+
context?: unknown
|
|
3381
3466
|
): this;
|
|
3382
3467
|
|
|
3383
3468
|
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
3384
3469
|
}
|
|
3385
3470
|
|
|
3386
|
-
|
|
3387
3471
|
/**
|
|
3388
3472
|
* Indexed Collections have incrementing numeric keys. They exhibit
|
|
3389
3473
|
* slightly different behavior than `Collection.Keyed` for some methods in order
|
|
@@ -3413,7 +3497,7 @@ declare module Immutable {
|
|
|
3413
3497
|
/**
|
|
3414
3498
|
* Deeply converts this Indexed collection to equivalent native JavaScript Array.
|
|
3415
3499
|
*/
|
|
3416
|
-
toJS(): Array<
|
|
3500
|
+
toJS(): Array<unknown>;
|
|
3417
3501
|
|
|
3418
3502
|
/**
|
|
3419
3503
|
* Shallowly converts this Indexed collection to equivalent native JavaScript Array.
|
|
@@ -3437,7 +3521,6 @@ declare module Immutable {
|
|
|
3437
3521
|
get<NSV>(index: number, notSetValue: NSV): T | NSV;
|
|
3438
3522
|
get(index: number): T | undefined;
|
|
3439
3523
|
|
|
3440
|
-
|
|
3441
3524
|
// Conversion to Seq
|
|
3442
3525
|
|
|
3443
3526
|
/**
|
|
@@ -3450,8 +3533,7 @@ declare module Immutable {
|
|
|
3450
3533
|
* If this is a collection of [key, value] entry tuples, it will return a
|
|
3451
3534
|
* Seq.Keyed of those entries.
|
|
3452
3535
|
*/
|
|
3453
|
-
fromEntrySeq(): Seq.Keyed<
|
|
3454
|
-
|
|
3536
|
+
fromEntrySeq(): Seq.Keyed<unknown, unknown>;
|
|
3455
3537
|
|
|
3456
3538
|
// Combination
|
|
3457
3539
|
|
|
@@ -3474,7 +3556,7 @@ declare module Immutable {
|
|
|
3474
3556
|
* ```js
|
|
3475
3557
|
* const { List } = require('immutable')
|
|
3476
3558
|
* List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ]))
|
|
3477
|
-
* // List [ 1, "A", 2, "B", 3, "C"
|
|
3559
|
+
* // List [ 1, "A", 2, "B", 3, "C" ]
|
|
3478
3560
|
* ```
|
|
3479
3561
|
*
|
|
3480
3562
|
* The shortest Collection stops interleave.
|
|
@@ -3487,7 +3569,7 @@ declare module Immutable {
|
|
|
3487
3569
|
* List([ 'A', 'B' ]),
|
|
3488
3570
|
* List([ 'X', 'Y', 'Z' ])
|
|
3489
3571
|
* )
|
|
3490
|
-
* // List [ 1, "A", "X", 2, "B", "Y"
|
|
3572
|
+
* // List [ 1, "A", "X", 2, "B", "Y" ]
|
|
3491
3573
|
* ```
|
|
3492
3574
|
*
|
|
3493
3575
|
* Since `interleave()` re-indexes values, it produces a complete copy,
|
|
@@ -3495,7 +3577,7 @@ declare module Immutable {
|
|
|
3495
3577
|
*
|
|
3496
3578
|
* Note: `interleave` *cannot* be used in `withMutations`.
|
|
3497
3579
|
*/
|
|
3498
|
-
interleave(...collections: Array<Collection<
|
|
3580
|
+
interleave(...collections: Array<Collection<unknown, T>>): this;
|
|
3499
3581
|
|
|
3500
3582
|
/**
|
|
3501
3583
|
* Splice returns a new indexed Collection by replacing a region of this
|
|
@@ -3517,11 +3599,7 @@ declare module Immutable {
|
|
|
3517
3599
|
*
|
|
3518
3600
|
* Note: `splice` *cannot* be used in `withMutations`.
|
|
3519
3601
|
*/
|
|
3520
|
-
splice(
|
|
3521
|
-
index: number,
|
|
3522
|
-
removeNum: number,
|
|
3523
|
-
...values: Array<T>
|
|
3524
|
-
): this;
|
|
3602
|
+
splice(index: number, removeNum: number, ...values: Array<T>): this;
|
|
3525
3603
|
|
|
3526
3604
|
/**
|
|
3527
3605
|
* Returns a Collection of the same type "zipped" with the provided
|
|
@@ -3539,9 +3617,14 @@ declare module Immutable {
|
|
|
3539
3617
|
* const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
|
|
3540
3618
|
* ```
|
|
3541
3619
|
*/
|
|
3542
|
-
zip<U>(other: Collection<
|
|
3543
|
-
zip<U,V>(
|
|
3544
|
-
|
|
3620
|
+
zip<U>(other: Collection<unknown, U>): Collection.Indexed<[T, U]>;
|
|
3621
|
+
zip<U, V>(
|
|
3622
|
+
other: Collection<unknown, U>,
|
|
3623
|
+
other2: Collection<unknown, V>
|
|
3624
|
+
): Collection.Indexed<[T, U, V]>;
|
|
3625
|
+
zip(
|
|
3626
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
3627
|
+
): Collection.Indexed<unknown>;
|
|
3545
3628
|
|
|
3546
3629
|
/**
|
|
3547
3630
|
* Returns a Collection "zipped" with the provided collections.
|
|
@@ -3555,9 +3638,14 @@ declare module Immutable {
|
|
|
3555
3638
|
* const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
|
|
3556
3639
|
* ```
|
|
3557
3640
|
*/
|
|
3558
|
-
zipAll<U>(other: Collection<
|
|
3559
|
-
zipAll<U,V>(
|
|
3560
|
-
|
|
3641
|
+
zipAll<U>(other: Collection<unknown, U>): Collection.Indexed<[T, U]>;
|
|
3642
|
+
zipAll<U, V>(
|
|
3643
|
+
other: Collection<unknown, U>,
|
|
3644
|
+
other2: Collection<unknown, V>
|
|
3645
|
+
): Collection.Indexed<[T, U, V]>;
|
|
3646
|
+
zipAll(
|
|
3647
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
3648
|
+
): Collection.Indexed<unknown>;
|
|
3561
3649
|
|
|
3562
3650
|
/**
|
|
3563
3651
|
* Returns a Collection of the same type "zipped" with the provided
|
|
@@ -3575,19 +3663,18 @@ declare module Immutable {
|
|
|
3575
3663
|
*/
|
|
3576
3664
|
zipWith<U, Z>(
|
|
3577
3665
|
zipper: (value: T, otherValue: U) => Z,
|
|
3578
|
-
otherCollection: Collection<
|
|
3666
|
+
otherCollection: Collection<unknown, U>
|
|
3579
3667
|
): Collection.Indexed<Z>;
|
|
3580
3668
|
zipWith<U, V, Z>(
|
|
3581
3669
|
zipper: (value: T, otherValue: U, thirdValue: V) => Z,
|
|
3582
|
-
otherCollection: Collection<
|
|
3583
|
-
thirdCollection: Collection<
|
|
3670
|
+
otherCollection: Collection<unknown, U>,
|
|
3671
|
+
thirdCollection: Collection<unknown, V>
|
|
3584
3672
|
): Collection.Indexed<Z>;
|
|
3585
3673
|
zipWith<Z>(
|
|
3586
|
-
zipper: (...any: Array<
|
|
3587
|
-
...collections: Array<Collection<
|
|
3674
|
+
zipper: (...any: Array<unknown>) => Z,
|
|
3675
|
+
...collections: Array<Collection<unknown, unknown>>
|
|
3588
3676
|
): Collection.Indexed<Z>;
|
|
3589
3677
|
|
|
3590
|
-
|
|
3591
3678
|
// Search for value
|
|
3592
3679
|
|
|
3593
3680
|
/**
|
|
@@ -3608,7 +3695,7 @@ declare module Immutable {
|
|
|
3608
3695
|
*/
|
|
3609
3696
|
findIndex(
|
|
3610
3697
|
predicate: (value: T, index: number, iter: this) => boolean,
|
|
3611
|
-
context?:
|
|
3698
|
+
context?: unknown
|
|
3612
3699
|
): number;
|
|
3613
3700
|
|
|
3614
3701
|
/**
|
|
@@ -3617,7 +3704,7 @@ declare module Immutable {
|
|
|
3617
3704
|
*/
|
|
3618
3705
|
findLastIndex(
|
|
3619
3706
|
predicate: (value: T, index: number, iter: this) => boolean,
|
|
3620
|
-
context?:
|
|
3707
|
+
context?: unknown
|
|
3621
3708
|
): number;
|
|
3622
3709
|
|
|
3623
3710
|
// Sequence algorithms
|
|
@@ -3625,7 +3712,9 @@ declare module Immutable {
|
|
|
3625
3712
|
/**
|
|
3626
3713
|
* Returns a new Collection with other collections concatenated to this one.
|
|
3627
3714
|
*/
|
|
3628
|
-
concat<C>(
|
|
3715
|
+
concat<C>(
|
|
3716
|
+
...valuesOrCollections: Array<Iterable<C> | C>
|
|
3717
|
+
): Collection.Indexed<T | C>;
|
|
3629
3718
|
|
|
3630
3719
|
/**
|
|
3631
3720
|
* Returns a new Collection.Indexed with values passed through a
|
|
@@ -3642,7 +3731,7 @@ declare module Immutable {
|
|
|
3642
3731
|
*/
|
|
3643
3732
|
map<M>(
|
|
3644
3733
|
mapper: (value: T, key: number, iter: this) => M,
|
|
3645
|
-
context?:
|
|
3734
|
+
context?: unknown
|
|
3646
3735
|
): Collection.Indexed<M>;
|
|
3647
3736
|
|
|
3648
3737
|
/**
|
|
@@ -3652,7 +3741,7 @@ declare module Immutable {
|
|
|
3652
3741
|
*/
|
|
3653
3742
|
flatMap<M>(
|
|
3654
3743
|
mapper: (value: T, key: number, iter: this) => Iterable<M>,
|
|
3655
|
-
context?:
|
|
3744
|
+
context?: unknown
|
|
3656
3745
|
): Collection.Indexed<M>;
|
|
3657
3746
|
|
|
3658
3747
|
/**
|
|
@@ -3664,17 +3753,16 @@ declare module Immutable {
|
|
|
3664
3753
|
*/
|
|
3665
3754
|
filter<F extends T>(
|
|
3666
3755
|
predicate: (value: T, index: number, iter: this) => value is F,
|
|
3667
|
-
context?:
|
|
3756
|
+
context?: unknown
|
|
3668
3757
|
): Collection.Indexed<F>;
|
|
3669
3758
|
filter(
|
|
3670
|
-
predicate: (value: T, index: number, iter: this) =>
|
|
3671
|
-
context?:
|
|
3759
|
+
predicate: (value: T, index: number, iter: this) => unknown,
|
|
3760
|
+
context?: unknown
|
|
3672
3761
|
): this;
|
|
3673
3762
|
|
|
3674
3763
|
[Symbol.iterator](): IterableIterator<T>;
|
|
3675
3764
|
}
|
|
3676
3765
|
|
|
3677
|
-
|
|
3678
3766
|
/**
|
|
3679
3767
|
* Set Collections only represent values. They have no associated keys or
|
|
3680
3768
|
* indices. Duplicate values are possible in the lazy `Seq.Set`s, however
|
|
@@ -3706,7 +3794,7 @@ declare module Immutable {
|
|
|
3706
3794
|
/**
|
|
3707
3795
|
* Deeply converts this Set collection to equivalent native JavaScript Array.
|
|
3708
3796
|
*/
|
|
3709
|
-
toJS(): Array<
|
|
3797
|
+
toJS(): Array<unknown>;
|
|
3710
3798
|
|
|
3711
3799
|
/**
|
|
3712
3800
|
* Shallowly converts this Set collection to equivalent native JavaScript Array.
|
|
@@ -3745,7 +3833,7 @@ declare module Immutable {
|
|
|
3745
3833
|
*/
|
|
3746
3834
|
map<M>(
|
|
3747
3835
|
mapper: (value: T, key: T, iter: this) => M,
|
|
3748
|
-
context?:
|
|
3836
|
+
context?: unknown
|
|
3749
3837
|
): Collection.Set<M>;
|
|
3750
3838
|
|
|
3751
3839
|
/**
|
|
@@ -3755,7 +3843,7 @@ declare module Immutable {
|
|
|
3755
3843
|
*/
|
|
3756
3844
|
flatMap<M>(
|
|
3757
3845
|
mapper: (value: T, key: T, iter: this) => Iterable<M>,
|
|
3758
|
-
context?:
|
|
3846
|
+
context?: unknown
|
|
3759
3847
|
): Collection.Set<M>;
|
|
3760
3848
|
|
|
3761
3849
|
/**
|
|
@@ -3767,16 +3855,15 @@ declare module Immutable {
|
|
|
3767
3855
|
*/
|
|
3768
3856
|
filter<F extends T>(
|
|
3769
3857
|
predicate: (value: T, key: T, iter: this) => value is F,
|
|
3770
|
-
context?:
|
|
3858
|
+
context?: unknown
|
|
3771
3859
|
): Collection.Set<F>;
|
|
3772
3860
|
filter(
|
|
3773
|
-
predicate: (value: T, key: T, iter: this) =>
|
|
3774
|
-
context?:
|
|
3861
|
+
predicate: (value: T, key: T, iter: this) => unknown,
|
|
3862
|
+
context?: unknown
|
|
3775
3863
|
): this;
|
|
3776
3864
|
|
|
3777
3865
|
[Symbol.iterator](): IterableIterator<T>;
|
|
3778
3866
|
}
|
|
3779
|
-
|
|
3780
3867
|
}
|
|
3781
3868
|
|
|
3782
3869
|
/**
|
|
@@ -3801,12 +3888,15 @@ declare module Immutable {
|
|
|
3801
3888
|
* Note: `Collection` is a conversion function and not a class, and does not
|
|
3802
3889
|
* use the `new` keyword during construction.
|
|
3803
3890
|
*/
|
|
3804
|
-
export function Collection<I extends Collection<
|
|
3891
|
+
export function Collection<I extends Collection<unknown, unknown>>(
|
|
3892
|
+
collection: I
|
|
3893
|
+
): I;
|
|
3805
3894
|
export function Collection<T>(collection: Iterable<T>): Collection.Indexed<T>;
|
|
3806
|
-
export function Collection<V>(obj: {
|
|
3895
|
+
export function Collection<V>(obj: {
|
|
3896
|
+
[key: string]: V;
|
|
3897
|
+
}): Collection.Keyed<string, V>;
|
|
3807
3898
|
|
|
3808
3899
|
export interface Collection<K, V> extends ValueObject {
|
|
3809
|
-
|
|
3810
3900
|
// Value equality
|
|
3811
3901
|
|
|
3812
3902
|
/**
|
|
@@ -3816,7 +3906,7 @@ declare module Immutable {
|
|
|
3816
3906
|
* Note: This is equivalent to `Immutable.is(this, other)`, but provided to
|
|
3817
3907
|
* allow for chained expressions.
|
|
3818
3908
|
*/
|
|
3819
|
-
equals(other:
|
|
3909
|
+
equals(other: unknown): boolean;
|
|
3820
3910
|
|
|
3821
3911
|
/**
|
|
3822
3912
|
* Computes and returns the hashed identity for this Collection.
|
|
@@ -3840,11 +3930,10 @@ declare module Immutable {
|
|
|
3840
3930
|
* to be equal][Hash Collision]. If two values have different `hashCode`s,
|
|
3841
3931
|
* they must not be equal.
|
|
3842
3932
|
*
|
|
3843
|
-
* [Hash Collision]:
|
|
3933
|
+
* [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science)
|
|
3844
3934
|
*/
|
|
3845
3935
|
hashCode(): number;
|
|
3846
3936
|
|
|
3847
|
-
|
|
3848
3937
|
// Reading values
|
|
3849
3938
|
|
|
3850
3939
|
/**
|
|
@@ -3878,7 +3967,7 @@ declare module Immutable {
|
|
|
3878
3967
|
* In case the `Collection` is empty returns the optional default
|
|
3879
3968
|
* value if provided, if no default value is provided returns undefined.
|
|
3880
3969
|
*/
|
|
3881
|
-
first<NSV>(notSetValue?: NSV): V | NSV;
|
|
3970
|
+
first<NSV = undefined>(notSetValue?: NSV): V | NSV;
|
|
3882
3971
|
|
|
3883
3972
|
/**
|
|
3884
3973
|
* In case the `Collection` is not empty returns the last element of the
|
|
@@ -3886,7 +3975,7 @@ declare module Immutable {
|
|
|
3886
3975
|
* In case the `Collection` is empty returns the optional default
|
|
3887
3976
|
* value if provided, if no default value is provided returns undefined.
|
|
3888
3977
|
*/
|
|
3889
|
-
last<NSV>(notSetValue?: NSV): V | NSV;
|
|
3978
|
+
last<NSV = undefined>(notSetValue?: NSV): V | NSV;
|
|
3890
3979
|
|
|
3891
3980
|
// Reading deep values
|
|
3892
3981
|
|
|
@@ -3911,13 +4000,13 @@ declare module Immutable {
|
|
|
3911
4000
|
* deepData.getIn(['x', 0, 'y']) // 123
|
|
3912
4001
|
* ```
|
|
3913
4002
|
*/
|
|
3914
|
-
getIn(searchKeyPath: Iterable<
|
|
4003
|
+
getIn(searchKeyPath: Iterable<unknown>, notSetValue?: unknown): unknown;
|
|
3915
4004
|
|
|
3916
4005
|
/**
|
|
3917
4006
|
* True if the result of following a path of keys or indices through nested
|
|
3918
4007
|
* Collections results in a set value.
|
|
3919
4008
|
*/
|
|
3920
|
-
hasIn(searchKeyPath: Iterable<
|
|
4009
|
+
hasIn(searchKeyPath: Iterable<unknown>): boolean;
|
|
3921
4010
|
|
|
3922
4011
|
// Persistent changes
|
|
3923
4012
|
|
|
@@ -3944,7 +4033,6 @@ declare module Immutable {
|
|
|
3944
4033
|
*/
|
|
3945
4034
|
update<R>(updater: (value: this) => R): R;
|
|
3946
4035
|
|
|
3947
|
-
|
|
3948
4036
|
// Conversion to JavaScript types
|
|
3949
4037
|
|
|
3950
4038
|
/**
|
|
@@ -3953,7 +4041,7 @@ declare module Immutable {
|
|
|
3953
4041
|
* `Collection.Indexed`, and `Collection.Set` become `Array`, while
|
|
3954
4042
|
* `Collection.Keyed` become `Object`, converting keys to Strings.
|
|
3955
4043
|
*/
|
|
3956
|
-
toJS(): Array<
|
|
4044
|
+
toJS(): Array<unknown> | { [key: string]: unknown };
|
|
3957
4045
|
|
|
3958
4046
|
/**
|
|
3959
4047
|
* Shallowly converts this Collection to equivalent native JavaScript Array or Object.
|
|
@@ -3978,7 +4066,6 @@ declare module Immutable {
|
|
|
3978
4066
|
*/
|
|
3979
4067
|
toObject(): { [key: string]: V };
|
|
3980
4068
|
|
|
3981
|
-
|
|
3982
4069
|
// Conversion to Collections
|
|
3983
4070
|
|
|
3984
4071
|
/**
|
|
@@ -4042,7 +4129,6 @@ declare module Immutable {
|
|
|
4042
4129
|
*/
|
|
4043
4130
|
toStack(): Stack<V>;
|
|
4044
4131
|
|
|
4045
|
-
|
|
4046
4132
|
// Conversion to Seq
|
|
4047
4133
|
|
|
4048
4134
|
/**
|
|
@@ -4085,7 +4171,6 @@ declare module Immutable {
|
|
|
4085
4171
|
*/
|
|
4086
4172
|
toSetSeq(): Seq.Set<V>;
|
|
4087
4173
|
|
|
4088
|
-
|
|
4089
4174
|
// Iterators
|
|
4090
4175
|
|
|
4091
4176
|
/**
|
|
@@ -4115,7 +4200,6 @@ declare module Immutable {
|
|
|
4115
4200
|
*/
|
|
4116
4201
|
entries(): IterableIterator<[K, V]>;
|
|
4117
4202
|
|
|
4118
|
-
|
|
4119
4203
|
// Collections (Seq)
|
|
4120
4204
|
|
|
4121
4205
|
/**
|
|
@@ -4134,7 +4218,6 @@ declare module Immutable {
|
|
|
4134
4218
|
*/
|
|
4135
4219
|
entrySeq(): Seq.Indexed<[K, V]>;
|
|
4136
4220
|
|
|
4137
|
-
|
|
4138
4221
|
// Sequence algorithms
|
|
4139
4222
|
|
|
4140
4223
|
/**
|
|
@@ -4153,7 +4236,7 @@ declare module Immutable {
|
|
|
4153
4236
|
*/
|
|
4154
4237
|
map<M>(
|
|
4155
4238
|
mapper: (value: V, key: K, iter: this) => M,
|
|
4156
|
-
context?:
|
|
4239
|
+
context?: unknown
|
|
4157
4240
|
): Collection<K, M>;
|
|
4158
4241
|
|
|
4159
4242
|
/**
|
|
@@ -4162,7 +4245,7 @@ declare module Immutable {
|
|
|
4162
4245
|
*
|
|
4163
4246
|
* @ignore
|
|
4164
4247
|
*/
|
|
4165
|
-
map<M>(...args: never[]):
|
|
4248
|
+
map<M>(...args: never[]): unknown;
|
|
4166
4249
|
|
|
4167
4250
|
/**
|
|
4168
4251
|
* Returns a new Collection of the same type with only the entries for which
|
|
@@ -4180,11 +4263,11 @@ declare module Immutable {
|
|
|
4180
4263
|
*/
|
|
4181
4264
|
filter<F extends V>(
|
|
4182
4265
|
predicate: (value: V, key: K, iter: this) => value is F,
|
|
4183
|
-
context?:
|
|
4266
|
+
context?: unknown
|
|
4184
4267
|
): Collection<K, F>;
|
|
4185
4268
|
filter(
|
|
4186
|
-
predicate: (value: V, key: K, iter: this) =>
|
|
4187
|
-
context?:
|
|
4269
|
+
predicate: (value: V, key: K, iter: this) => unknown,
|
|
4270
|
+
context?: unknown
|
|
4188
4271
|
): this;
|
|
4189
4272
|
|
|
4190
4273
|
/**
|
|
@@ -4203,7 +4286,7 @@ declare module Immutable {
|
|
|
4203
4286
|
*/
|
|
4204
4287
|
filterNot(
|
|
4205
4288
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4206
|
-
context?:
|
|
4289
|
+
context?: unknown
|
|
4207
4290
|
): this;
|
|
4208
4291
|
|
|
4209
4292
|
/**
|
|
@@ -4250,7 +4333,17 @@ declare module Immutable {
|
|
|
4250
4333
|
* Like `sort`, but also accepts a `comparatorValueMapper` which allows for
|
|
4251
4334
|
* sorting by more sophisticated means:
|
|
4252
4335
|
*
|
|
4253
|
-
*
|
|
4336
|
+
* <!-- runkit:activate -->
|
|
4337
|
+
* ```js
|
|
4338
|
+
* const { Map } = require('immutable')
|
|
4339
|
+
* const beattles = Map({
|
|
4340
|
+
* John: { name: "Lennon" },
|
|
4341
|
+
* Paul: { name: "McCartney" },
|
|
4342
|
+
* George: { name: "Harrison" },
|
|
4343
|
+
* Ringo: { name: "Starr" },
|
|
4344
|
+
* });
|
|
4345
|
+
* beattles.sortBy(member => member.name);
|
|
4346
|
+
* ```
|
|
4254
4347
|
*
|
|
4255
4348
|
* Note: `sortBy()` Always returns a new instance, even if the original was
|
|
4256
4349
|
* already sorted.
|
|
@@ -4288,9 +4381,8 @@ declare module Immutable {
|
|
|
4288
4381
|
*/
|
|
4289
4382
|
groupBy<G>(
|
|
4290
4383
|
grouper: (value: V, key: K, iter: this) => G,
|
|
4291
|
-
context?:
|
|
4292
|
-
): /*Map*/Seq.Keyed<G, /*this*/Collection<K, V>>;
|
|
4293
|
-
|
|
4384
|
+
context?: unknown
|
|
4385
|
+
): /*Map*/ Seq.Keyed<G, /*this*/ Collection<K, V>>;
|
|
4294
4386
|
|
|
4295
4387
|
// Side effects
|
|
4296
4388
|
|
|
@@ -4302,11 +4394,10 @@ declare module Immutable {
|
|
|
4302
4394
|
* (including the last iteration which returned false).
|
|
4303
4395
|
*/
|
|
4304
4396
|
forEach(
|
|
4305
|
-
sideEffect: (value: V, key: K, iter: this) =>
|
|
4306
|
-
context?:
|
|
4397
|
+
sideEffect: (value: V, key: K, iter: this) => unknown,
|
|
4398
|
+
context?: unknown
|
|
4307
4399
|
): number;
|
|
4308
4400
|
|
|
4309
|
-
|
|
4310
4401
|
// Creating subsets
|
|
4311
4402
|
|
|
4312
4403
|
/**
|
|
@@ -4360,12 +4451,12 @@ declare module Immutable {
|
|
|
4360
4451
|
* const { List } = require('immutable')
|
|
4361
4452
|
* List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
|
|
4362
4453
|
* .skipWhile(x => x.match(/g/))
|
|
4363
|
-
* // List [ "cat", "hat", "god"
|
|
4454
|
+
* // List [ "cat", "hat", "god" ]
|
|
4364
4455
|
* ```
|
|
4365
4456
|
*/
|
|
4366
4457
|
skipWhile(
|
|
4367
4458
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4368
|
-
context?:
|
|
4459
|
+
context?: unknown
|
|
4369
4460
|
): this;
|
|
4370
4461
|
|
|
4371
4462
|
/**
|
|
@@ -4377,12 +4468,12 @@ declare module Immutable {
|
|
|
4377
4468
|
* const { List } = require('immutable')
|
|
4378
4469
|
* List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
|
|
4379
4470
|
* .skipUntil(x => x.match(/hat/))
|
|
4380
|
-
* // List [ "hat", "god"
|
|
4471
|
+
* // List [ "hat", "god" ]
|
|
4381
4472
|
* ```
|
|
4382
4473
|
*/
|
|
4383
4474
|
skipUntil(
|
|
4384
4475
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4385
|
-
context?:
|
|
4476
|
+
context?: unknown
|
|
4386
4477
|
): this;
|
|
4387
4478
|
|
|
4388
4479
|
/**
|
|
@@ -4411,7 +4502,7 @@ declare module Immutable {
|
|
|
4411
4502
|
*/
|
|
4412
4503
|
takeWhile(
|
|
4413
4504
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4414
|
-
context?:
|
|
4505
|
+
context?: unknown
|
|
4415
4506
|
): this;
|
|
4416
4507
|
|
|
4417
4508
|
/**
|
|
@@ -4428,10 +4519,9 @@ declare module Immutable {
|
|
|
4428
4519
|
*/
|
|
4429
4520
|
takeUntil(
|
|
4430
4521
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4431
|
-
context?:
|
|
4522
|
+
context?: unknown
|
|
4432
4523
|
): this;
|
|
4433
4524
|
|
|
4434
|
-
|
|
4435
4525
|
// Combination
|
|
4436
4526
|
|
|
4437
4527
|
/**
|
|
@@ -4441,7 +4531,9 @@ declare module Immutable {
|
|
|
4441
4531
|
* For Seqs, all entries will be present in the resulting Seq, even if they
|
|
4442
4532
|
* have the same key.
|
|
4443
4533
|
*/
|
|
4444
|
-
concat(
|
|
4534
|
+
concat(
|
|
4535
|
+
...valuesOrCollections: Array<unknown>
|
|
4536
|
+
): Collection<unknown, unknown>;
|
|
4445
4537
|
|
|
4446
4538
|
/**
|
|
4447
4539
|
* Flattens nested Collections.
|
|
@@ -4453,11 +4545,11 @@ declare module Immutable {
|
|
|
4453
4545
|
*
|
|
4454
4546
|
* Flattens only others Collection, not Arrays or Objects.
|
|
4455
4547
|
*
|
|
4456
|
-
* Note: `flatten(true)` operates on Collection<
|
|
4548
|
+
* Note: `flatten(true)` operates on Collection<unknown, Collection<K, V>> and
|
|
4457
4549
|
* returns Collection<K, V>
|
|
4458
4550
|
*/
|
|
4459
|
-
flatten(depth?: number): Collection<
|
|
4460
|
-
flatten(shallow?: boolean): Collection<
|
|
4551
|
+
flatten(depth?: number): Collection<unknown, unknown>;
|
|
4552
|
+
flatten(shallow?: boolean): Collection<unknown, unknown>;
|
|
4461
4553
|
|
|
4462
4554
|
/**
|
|
4463
4555
|
* Flat-maps the Collection, returning a Collection of the same type.
|
|
@@ -4466,7 +4558,7 @@ declare module Immutable {
|
|
|
4466
4558
|
*/
|
|
4467
4559
|
flatMap<M>(
|
|
4468
4560
|
mapper: (value: V, key: K, iter: this) => Iterable<M>,
|
|
4469
|
-
context?:
|
|
4561
|
+
context?: unknown
|
|
4470
4562
|
): Collection<K, M>;
|
|
4471
4563
|
|
|
4472
4564
|
/**
|
|
@@ -4477,7 +4569,7 @@ declare module Immutable {
|
|
|
4477
4569
|
*/
|
|
4478
4570
|
flatMap<KM, VM>(
|
|
4479
4571
|
mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
|
|
4480
|
-
context?:
|
|
4572
|
+
context?: unknown
|
|
4481
4573
|
): Collection<KM, VM>;
|
|
4482
4574
|
|
|
4483
4575
|
// Reducing a value
|
|
@@ -4494,7 +4586,7 @@ declare module Immutable {
|
|
|
4494
4586
|
reduce<R>(
|
|
4495
4587
|
reducer: (reduction: R, value: V, key: K, iter: this) => R,
|
|
4496
4588
|
initialReduction: R,
|
|
4497
|
-
context?:
|
|
4589
|
+
context?: unknown
|
|
4498
4590
|
): R;
|
|
4499
4591
|
reduce<R>(
|
|
4500
4592
|
reducer: (reduction: V | R, value: V, key: K, iter: this) => R
|
|
@@ -4509,7 +4601,7 @@ declare module Immutable {
|
|
|
4509
4601
|
reduceRight<R>(
|
|
4510
4602
|
reducer: (reduction: R, value: V, key: K, iter: this) => R,
|
|
4511
4603
|
initialReduction: R,
|
|
4512
|
-
context?:
|
|
4604
|
+
context?: unknown
|
|
4513
4605
|
): R;
|
|
4514
4606
|
reduceRight<R>(
|
|
4515
4607
|
reducer: (reduction: V | R, value: V, key: K, iter: this) => R
|
|
@@ -4520,7 +4612,7 @@ declare module Immutable {
|
|
|
4520
4612
|
*/
|
|
4521
4613
|
every(
|
|
4522
4614
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4523
|
-
context?:
|
|
4615
|
+
context?: unknown
|
|
4524
4616
|
): boolean;
|
|
4525
4617
|
|
|
4526
4618
|
/**
|
|
@@ -4528,7 +4620,7 @@ declare module Immutable {
|
|
|
4528
4620
|
*/
|
|
4529
4621
|
some(
|
|
4530
4622
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4531
|
-
context?:
|
|
4623
|
+
context?: unknown
|
|
4532
4624
|
): boolean;
|
|
4533
4625
|
|
|
4534
4626
|
/**
|
|
@@ -4558,7 +4650,7 @@ declare module Immutable {
|
|
|
4558
4650
|
count(): number;
|
|
4559
4651
|
count(
|
|
4560
4652
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4561
|
-
context?:
|
|
4653
|
+
context?: unknown
|
|
4562
4654
|
): number;
|
|
4563
4655
|
|
|
4564
4656
|
/**
|
|
@@ -4569,10 +4661,9 @@ declare module Immutable {
|
|
|
4569
4661
|
*/
|
|
4570
4662
|
countBy<G>(
|
|
4571
4663
|
grouper: (value: V, key: K, iter: this) => G,
|
|
4572
|
-
context?:
|
|
4664
|
+
context?: unknown
|
|
4573
4665
|
): Map<G, number>;
|
|
4574
4666
|
|
|
4575
|
-
|
|
4576
4667
|
// Search for value
|
|
4577
4668
|
|
|
4578
4669
|
/**
|
|
@@ -4580,7 +4671,7 @@ declare module Immutable {
|
|
|
4580
4671
|
*/
|
|
4581
4672
|
find(
|
|
4582
4673
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4583
|
-
context?:
|
|
4674
|
+
context?: unknown,
|
|
4584
4675
|
notSetValue?: V
|
|
4585
4676
|
): V | undefined;
|
|
4586
4677
|
|
|
@@ -4591,7 +4682,7 @@ declare module Immutable {
|
|
|
4591
4682
|
*/
|
|
4592
4683
|
findLast(
|
|
4593
4684
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4594
|
-
context?:
|
|
4685
|
+
context?: unknown,
|
|
4595
4686
|
notSetValue?: V
|
|
4596
4687
|
): V | undefined;
|
|
4597
4688
|
|
|
@@ -4600,7 +4691,7 @@ declare module Immutable {
|
|
|
4600
4691
|
*/
|
|
4601
4692
|
findEntry(
|
|
4602
4693
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4603
|
-
context?:
|
|
4694
|
+
context?: unknown,
|
|
4604
4695
|
notSetValue?: V
|
|
4605
4696
|
): [K, V] | undefined;
|
|
4606
4697
|
|
|
@@ -4612,7 +4703,7 @@ declare module Immutable {
|
|
|
4612
4703
|
*/
|
|
4613
4704
|
findLastEntry(
|
|
4614
4705
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4615
|
-
context?:
|
|
4706
|
+
context?: unknown,
|
|
4616
4707
|
notSetValue?: V
|
|
4617
4708
|
): [K, V] | undefined;
|
|
4618
4709
|
|
|
@@ -4621,7 +4712,7 @@ declare module Immutable {
|
|
|
4621
4712
|
*/
|
|
4622
4713
|
findKey(
|
|
4623
4714
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4624
|
-
context?:
|
|
4715
|
+
context?: unknown
|
|
4625
4716
|
): K | undefined;
|
|
4626
4717
|
|
|
4627
4718
|
/**
|
|
@@ -4631,7 +4722,7 @@ declare module Immutable {
|
|
|
4631
4722
|
*/
|
|
4632
4723
|
findLastKey(
|
|
4633
4724
|
predicate: (value: V, key: K, iter: this) => boolean,
|
|
4634
|
-
context?:
|
|
4725
|
+
context?: unknown
|
|
4635
4726
|
): K | undefined;
|
|
4636
4727
|
|
|
4637
4728
|
/**
|
|
@@ -4665,8 +4756,16 @@ declare module Immutable {
|
|
|
4665
4756
|
* Like `max`, but also accepts a `comparatorValueMapper` which allows for
|
|
4666
4757
|
* comparing by more sophisticated means:
|
|
4667
4758
|
*
|
|
4668
|
-
*
|
|
4669
|
-
*
|
|
4759
|
+
* <!-- runkit:activate -->
|
|
4760
|
+
* ```js
|
|
4761
|
+
* const { List, } = require('immutable');
|
|
4762
|
+
* const l = List([
|
|
4763
|
+
* { name: 'Bob', avgHit: 1 },
|
|
4764
|
+
* { name: 'Max', avgHit: 3 },
|
|
4765
|
+
* { name: 'Lili', avgHit: 2 } ,
|
|
4766
|
+
* ]);
|
|
4767
|
+
* l.maxBy(i => i.avgHit); // will output { name: 'Max', avgHit: 3 }
|
|
4768
|
+
* ```
|
|
4670
4769
|
*/
|
|
4671
4770
|
maxBy<C>(
|
|
4672
4771
|
comparatorValueMapper: (value: V, key: K, iter: this) => C,
|
|
@@ -4694,15 +4793,22 @@ declare module Immutable {
|
|
|
4694
4793
|
* Like `min`, but also accepts a `comparatorValueMapper` which allows for
|
|
4695
4794
|
* comparing by more sophisticated means:
|
|
4696
4795
|
*
|
|
4697
|
-
*
|
|
4698
|
-
*
|
|
4796
|
+
* <!-- runkit:activate -->
|
|
4797
|
+
* ```js
|
|
4798
|
+
* const { List, } = require('immutable');
|
|
4799
|
+
* const l = List([
|
|
4800
|
+
* { name: 'Bob', avgHit: 1 },
|
|
4801
|
+
* { name: 'Max', avgHit: 3 },
|
|
4802
|
+
* { name: 'Lili', avgHit: 2 } ,
|
|
4803
|
+
* ]);
|
|
4804
|
+
* l.minBy(i => i.avgHit); // will output { name: 'Bob', avgHit: 1 }
|
|
4805
|
+
* ```
|
|
4699
4806
|
*/
|
|
4700
4807
|
minBy<C>(
|
|
4701
4808
|
comparatorValueMapper: (value: V, key: K, iter: this) => C,
|
|
4702
4809
|
comparator?: (valueA: C, valueB: C) => number
|
|
4703
4810
|
): V | undefined;
|
|
4704
4811
|
|
|
4705
|
-
|
|
4706
4812
|
// Comparison
|
|
4707
4813
|
|
|
4708
4814
|
/**
|
|
@@ -4727,7 +4833,7 @@ declare module Immutable {
|
|
|
4727
4833
|
* Note: This is equivalent to `Immutable.is(this, other)`, but provided to
|
|
4728
4834
|
* allow for chained expressions.
|
|
4729
4835
|
*/
|
|
4730
|
-
equals(other:
|
|
4836
|
+
equals(other: unknown): boolean;
|
|
4731
4837
|
|
|
4732
4838
|
/**
|
|
4733
4839
|
* Computes and returns the hashed identity for this Collection.
|
|
@@ -4758,7 +4864,7 @@ declare module Immutable {
|
|
|
4758
4864
|
* organize their internal data structures, while all Immutable.js
|
|
4759
4865
|
* collections use equality during lookups.
|
|
4760
4866
|
*
|
|
4761
|
-
* [Hash Collision]:
|
|
4867
|
+
* [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science)
|
|
4762
4868
|
*/
|
|
4763
4869
|
hashCode(): number;
|
|
4764
4870
|
}
|
|
@@ -4830,13 +4936,13 @@ declare module Immutable {
|
|
|
4830
4936
|
* "Using the reviver parameter"
|
|
4831
4937
|
*/
|
|
4832
4938
|
export function fromJS(
|
|
4833
|
-
jsValue:
|
|
4939
|
+
jsValue: unknown,
|
|
4834
4940
|
reviver?: (
|
|
4835
4941
|
key: string | number,
|
|
4836
|
-
sequence: Collection.Keyed<string,
|
|
4942
|
+
sequence: Collection.Keyed<string, unknown> | Collection.Indexed<unknown>,
|
|
4837
4943
|
path?: Array<string | number>
|
|
4838
|
-
) =>
|
|
4839
|
-
):
|
|
4944
|
+
) => unknown
|
|
4945
|
+
): unknown;
|
|
4840
4946
|
|
|
4841
4947
|
/**
|
|
4842
4948
|
* Value equality check with semantics similar to `Object.is`, but treats
|
|
@@ -4863,7 +4969,7 @@ declare module Immutable {
|
|
|
4863
4969
|
* Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same
|
|
4864
4970
|
* value, matching the behavior of ES6 Map key equality.
|
|
4865
4971
|
*/
|
|
4866
|
-
export function is(first:
|
|
4972
|
+
export function is(first: unknown, second: unknown): boolean;
|
|
4867
4973
|
|
|
4868
4974
|
/**
|
|
4869
4975
|
* The `hash()` function is an important part of how Immutable determines if
|
|
@@ -4887,7 +4993,7 @@ declare module Immutable {
|
|
|
4887
4993
|
*
|
|
4888
4994
|
* *New in Version 4.0*
|
|
4889
4995
|
*/
|
|
4890
|
-
export function hash(value:
|
|
4996
|
+
export function hash(value: unknown): number;
|
|
4891
4997
|
|
|
4892
4998
|
/**
|
|
4893
4999
|
* True if `maybeImmutable` is an Immutable Collection or Record.
|
|
@@ -4905,7 +5011,9 @@ declare module Immutable {
|
|
|
4905
5011
|
* isImmutable(Map().asMutable()); // true
|
|
4906
5012
|
* ```
|
|
4907
5013
|
*/
|
|
4908
|
-
export function isImmutable(
|
|
5014
|
+
export function isImmutable(
|
|
5015
|
+
maybeImmutable: unknown
|
|
5016
|
+
): maybeImmutable is Collection<unknown, unknown>;
|
|
4909
5017
|
|
|
4910
5018
|
/**
|
|
4911
5019
|
* True if `maybeCollection` is a Collection, or any of its subclasses.
|
|
@@ -4920,7 +5028,9 @@ declare module Immutable {
|
|
|
4920
5028
|
* isCollection(Stack()); // true
|
|
4921
5029
|
* ```
|
|
4922
5030
|
*/
|
|
4923
|
-
export function isCollection(
|
|
5031
|
+
export function isCollection(
|
|
5032
|
+
maybeCollection: unknown
|
|
5033
|
+
): maybeCollection is Collection<unknown, unknown>;
|
|
4924
5034
|
|
|
4925
5035
|
/**
|
|
4926
5036
|
* True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses.
|
|
@@ -4935,7 +5045,9 @@ declare module Immutable {
|
|
|
4935
5045
|
* isKeyed(Stack()); // false
|
|
4936
5046
|
* ```
|
|
4937
5047
|
*/
|
|
4938
|
-
export function isKeyed(
|
|
5048
|
+
export function isKeyed(
|
|
5049
|
+
maybeKeyed: unknown
|
|
5050
|
+
): maybeKeyed is Collection.Keyed<unknown, unknown>;
|
|
4939
5051
|
|
|
4940
5052
|
/**
|
|
4941
5053
|
* True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses.
|
|
@@ -4951,7 +5063,9 @@ declare module Immutable {
|
|
|
4951
5063
|
* isIndexed(Set()); // false
|
|
4952
5064
|
* ```
|
|
4953
5065
|
*/
|
|
4954
|
-
export function isIndexed(
|
|
5066
|
+
export function isIndexed(
|
|
5067
|
+
maybeIndexed: unknown
|
|
5068
|
+
): maybeIndexed is Collection.Indexed<unknown>;
|
|
4955
5069
|
|
|
4956
5070
|
/**
|
|
4957
5071
|
* True if `maybeAssociative` is either a Keyed or Indexed Collection.
|
|
@@ -4967,7 +5081,11 @@ declare module Immutable {
|
|
|
4967
5081
|
* isAssociative(Set()); // false
|
|
4968
5082
|
* ```
|
|
4969
5083
|
*/
|
|
4970
|
-
export function isAssociative(
|
|
5084
|
+
export function isAssociative(
|
|
5085
|
+
maybeAssociative: unknown
|
|
5086
|
+
): maybeAssociative is
|
|
5087
|
+
| Collection.Keyed<unknown, unknown>
|
|
5088
|
+
| Collection.Indexed<unknown>;
|
|
4971
5089
|
|
|
4972
5090
|
/**
|
|
4973
5091
|
* True if `maybeOrdered` is a Collection where iteration order is well
|
|
@@ -4984,7 +5102,7 @@ declare module Immutable {
|
|
|
4984
5102
|
* isOrdered(Set()); // false
|
|
4985
5103
|
* ```
|
|
4986
5104
|
*/
|
|
4987
|
-
export function isOrdered(maybeOrdered:
|
|
5105
|
+
export function isOrdered(maybeOrdered: unknown): boolean;
|
|
4988
5106
|
|
|
4989
5107
|
/**
|
|
4990
5108
|
* True if `maybeValue` is a JavaScript Object which has *both* `equals()`
|
|
@@ -4993,54 +5111,60 @@ declare module Immutable {
|
|
|
4993
5111
|
* Any two instances of *value objects* can be compared for value equality with
|
|
4994
5112
|
* `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`.
|
|
4995
5113
|
*/
|
|
4996
|
-
export function isValueObject(maybeValue:
|
|
4997
|
-
|
|
5114
|
+
export function isValueObject(maybeValue: unknown): maybeValue is ValueObject;
|
|
4998
5115
|
|
|
4999
5116
|
/**
|
|
5000
5117
|
* True if `maybeSeq` is a Seq.
|
|
5001
5118
|
*/
|
|
5002
|
-
export function isSeq(
|
|
5119
|
+
export function isSeq(
|
|
5120
|
+
maybeSeq: unknown
|
|
5121
|
+
): maybeSeq is
|
|
5122
|
+
| Seq.Indexed<unknown>
|
|
5123
|
+
| Seq.Keyed<unknown, unknown>
|
|
5124
|
+
| Seq.Set<unknown>;
|
|
5003
5125
|
|
|
5004
5126
|
/**
|
|
5005
5127
|
* True if `maybeList` is a List.
|
|
5006
5128
|
*/
|
|
5007
|
-
export function isList(maybeList:
|
|
5129
|
+
export function isList(maybeList: unknown): maybeList is List<unknown>;
|
|
5008
5130
|
|
|
5009
5131
|
/**
|
|
5010
5132
|
* True if `maybeMap` is a Map.
|
|
5011
5133
|
*
|
|
5012
5134
|
* Also true for OrderedMaps.
|
|
5013
5135
|
*/
|
|
5014
|
-
export function isMap(maybeMap:
|
|
5136
|
+
export function isMap(maybeMap: unknown): maybeMap is Map<unknown, unknown>;
|
|
5015
5137
|
|
|
5016
5138
|
/**
|
|
5017
5139
|
* True if `maybeOrderedMap` is an OrderedMap.
|
|
5018
5140
|
*/
|
|
5019
|
-
export function isOrderedMap(
|
|
5141
|
+
export function isOrderedMap(
|
|
5142
|
+
maybeOrderedMap: unknown
|
|
5143
|
+
): maybeOrderedMap is OrderedMap<unknown, unknown>;
|
|
5020
5144
|
|
|
5021
5145
|
/**
|
|
5022
5146
|
* True if `maybeStack` is a Stack.
|
|
5023
5147
|
*/
|
|
5024
|
-
export function isStack(maybeStack:
|
|
5148
|
+
export function isStack(maybeStack: unknown): maybeStack is Stack<unknown>;
|
|
5025
5149
|
|
|
5026
5150
|
/**
|
|
5027
5151
|
* True if `maybeSet` is a Set.
|
|
5028
5152
|
*
|
|
5029
5153
|
* Also true for OrderedSets.
|
|
5030
5154
|
*/
|
|
5031
|
-
export function isSet(maybeSet:
|
|
5155
|
+
export function isSet(maybeSet: unknown): maybeSet is Set<unknown>;
|
|
5032
5156
|
|
|
5033
5157
|
/**
|
|
5034
5158
|
* True if `maybeOrderedSet` is an OrderedSet.
|
|
5035
5159
|
*/
|
|
5036
|
-
export function isOrderedSet(
|
|
5160
|
+
export function isOrderedSet(
|
|
5161
|
+
maybeOrderedSet: unknown
|
|
5162
|
+
): maybeOrderedSet is OrderedSet<unknown>;
|
|
5037
5163
|
|
|
5038
5164
|
/**
|
|
5039
5165
|
* True if `maybeRecord` is a Record.
|
|
5040
5166
|
*/
|
|
5041
|
-
export function isRecord(maybeRecord:
|
|
5042
|
-
|
|
5043
|
-
|
|
5167
|
+
export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>;
|
|
5044
5168
|
|
|
5045
5169
|
/**
|
|
5046
5170
|
* Returns the value within the provided collection associated with the
|
|
@@ -5057,14 +5181,40 @@ declare module Immutable {
|
|
|
5057
5181
|
* get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet'
|
|
5058
5182
|
* ```
|
|
5059
5183
|
*/
|
|
5060
|
-
export function get<K, V>(
|
|
5061
|
-
|
|
5062
|
-
|
|
5184
|
+
export function get<K, V>(
|
|
5185
|
+
collection: Collection<K, V>,
|
|
5186
|
+
key: K
|
|
5187
|
+
): V | undefined;
|
|
5188
|
+
export function get<K, V, NSV>(
|
|
5189
|
+
collection: Collection<K, V>,
|
|
5190
|
+
key: K,
|
|
5191
|
+
notSetValue: NSV
|
|
5192
|
+
): V | NSV;
|
|
5193
|
+
export function get<TProps, K extends keyof TProps>(
|
|
5194
|
+
record: Record<TProps>,
|
|
5195
|
+
key: K,
|
|
5196
|
+
notSetValue: unknown
|
|
5197
|
+
): TProps[K];
|
|
5063
5198
|
export function get<V>(collection: Array<V>, key: number): V | undefined;
|
|
5064
|
-
export function get<V, NSV>(
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5199
|
+
export function get<V, NSV>(
|
|
5200
|
+
collection: Array<V>,
|
|
5201
|
+
key: number,
|
|
5202
|
+
notSetValue: NSV
|
|
5203
|
+
): V | NSV;
|
|
5204
|
+
export function get<C extends Object, K extends keyof C>(
|
|
5205
|
+
object: C,
|
|
5206
|
+
key: K,
|
|
5207
|
+
notSetValue: unknown
|
|
5208
|
+
): C[K];
|
|
5209
|
+
export function get<V>(
|
|
5210
|
+
collection: { [key: string]: V },
|
|
5211
|
+
key: string
|
|
5212
|
+
): V | undefined;
|
|
5213
|
+
export function get<V, NSV>(
|
|
5214
|
+
collection: { [key: string]: V },
|
|
5215
|
+
key: string,
|
|
5216
|
+
notSetValue: NSV
|
|
5217
|
+
): V | NSV;
|
|
5068
5218
|
|
|
5069
5219
|
/**
|
|
5070
5220
|
* Returns true if the key is defined in the provided collection.
|
|
@@ -5082,7 +5232,7 @@ declare module Immutable {
|
|
|
5082
5232
|
* has({ x: 123, y: 456 }, 'z') // false
|
|
5083
5233
|
* ```
|
|
5084
5234
|
*/
|
|
5085
|
-
export function has(collection: Object, key:
|
|
5235
|
+
export function has(collection: Object, key: unknown): boolean;
|
|
5086
5236
|
|
|
5087
5237
|
/**
|
|
5088
5238
|
* Returns a copy of the collection with the value at key removed.
|
|
@@ -5102,11 +5252,24 @@ declare module Immutable {
|
|
|
5102
5252
|
* console.log(originalObject) // { x: 123, y: 456 }
|
|
5103
5253
|
* ```
|
|
5104
5254
|
*/
|
|
5105
|
-
export function remove<K, C extends Collection<K,
|
|
5106
|
-
|
|
5107
|
-
|
|
5255
|
+
export function remove<K, C extends Collection<K, unknown>>(
|
|
5256
|
+
collection: C,
|
|
5257
|
+
key: K
|
|
5258
|
+
): C;
|
|
5259
|
+
export function remove<
|
|
5260
|
+
TProps,
|
|
5261
|
+
C extends Record<TProps>,
|
|
5262
|
+
K extends keyof TProps
|
|
5263
|
+
>(collection: C, key: K): C;
|
|
5264
|
+
export function remove<C extends Array<unknown>>(
|
|
5265
|
+
collection: C,
|
|
5266
|
+
key: number
|
|
5267
|
+
): C;
|
|
5108
5268
|
export function remove<C, K extends keyof C>(collection: C, key: K): C;
|
|
5109
|
-
export function remove<
|
|
5269
|
+
export function remove<
|
|
5270
|
+
C extends { [key: string]: unknown },
|
|
5271
|
+
K extends keyof C
|
|
5272
|
+
>(collection: C, key: K): C;
|
|
5110
5273
|
|
|
5111
5274
|
/**
|
|
5112
5275
|
* Returns a copy of the collection with the value at key set to the provided
|
|
@@ -5127,11 +5290,27 @@ declare module Immutable {
|
|
|
5127
5290
|
* console.log(originalObject) // { x: 123, y: 456 }
|
|
5128
5291
|
* ```
|
|
5129
5292
|
*/
|
|
5130
|
-
export function set<K, V, C extends Collection<K, V>>(
|
|
5131
|
-
|
|
5132
|
-
|
|
5293
|
+
export function set<K, V, C extends Collection<K, V>>(
|
|
5294
|
+
collection: C,
|
|
5295
|
+
key: K,
|
|
5296
|
+
value: V
|
|
5297
|
+
): C;
|
|
5298
|
+
export function set<TProps, C extends Record<TProps>, K extends keyof TProps>(
|
|
5299
|
+
record: C,
|
|
5300
|
+
key: K,
|
|
5301
|
+
value: TProps[K]
|
|
5302
|
+
): C;
|
|
5303
|
+
export function set<V, C extends Array<V>>(
|
|
5304
|
+
collection: C,
|
|
5305
|
+
key: number,
|
|
5306
|
+
value: V
|
|
5307
|
+
): C;
|
|
5133
5308
|
export function set<C, K extends keyof C>(object: C, key: K, value: C[K]): C;
|
|
5134
|
-
export function set<V, C extends {[key: string]: V}>(
|
|
5309
|
+
export function set<V, C extends { [key: string]: V }>(
|
|
5310
|
+
collection: C,
|
|
5311
|
+
key: string,
|
|
5312
|
+
value: V
|
|
5313
|
+
): C;
|
|
5135
5314
|
|
|
5136
5315
|
/**
|
|
5137
5316
|
* Returns a copy of the collection with the value at key set to the result of
|
|
@@ -5152,16 +5331,71 @@ declare module Immutable {
|
|
|
5152
5331
|
* console.log(originalObject) // { x: 123, y: 456 }
|
|
5153
5332
|
* ```
|
|
5154
5333
|
*/
|
|
5155
|
-
export function update<K, V, C extends Collection<K, V>>(
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
export function update<
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5334
|
+
export function update<K, V, C extends Collection<K, V>>(
|
|
5335
|
+
collection: C,
|
|
5336
|
+
key: K,
|
|
5337
|
+
updater: (value: V | undefined) => V
|
|
5338
|
+
): C;
|
|
5339
|
+
export function update<K, V, C extends Collection<K, V>, NSV>(
|
|
5340
|
+
collection: C,
|
|
5341
|
+
key: K,
|
|
5342
|
+
notSetValue: NSV,
|
|
5343
|
+
updater: (value: V | NSV) => V
|
|
5344
|
+
): C;
|
|
5345
|
+
export function update<
|
|
5346
|
+
TProps,
|
|
5347
|
+
C extends Record<TProps>,
|
|
5348
|
+
K extends keyof TProps
|
|
5349
|
+
>(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C;
|
|
5350
|
+
export function update<
|
|
5351
|
+
TProps,
|
|
5352
|
+
C extends Record<TProps>,
|
|
5353
|
+
K extends keyof TProps,
|
|
5354
|
+
NSV
|
|
5355
|
+
>(
|
|
5356
|
+
record: C,
|
|
5357
|
+
key: K,
|
|
5358
|
+
notSetValue: NSV,
|
|
5359
|
+
updater: (value: TProps[K] | NSV) => TProps[K]
|
|
5360
|
+
): C;
|
|
5361
|
+
export function update<V>(
|
|
5362
|
+
collection: Array<V>,
|
|
5363
|
+
key: number,
|
|
5364
|
+
updater: (value: V) => V
|
|
5365
|
+
): Array<V>;
|
|
5366
|
+
export function update<V, NSV>(
|
|
5367
|
+
collection: Array<V>,
|
|
5368
|
+
key: number,
|
|
5369
|
+
notSetValue: NSV,
|
|
5370
|
+
updater: (value: V | NSV) => V
|
|
5371
|
+
): Array<V>;
|
|
5372
|
+
export function update<C, K extends keyof C>(
|
|
5373
|
+
object: C,
|
|
5374
|
+
key: K,
|
|
5375
|
+
updater: (value: C[K]) => C[K]
|
|
5376
|
+
): C;
|
|
5377
|
+
export function update<C, K extends keyof C, NSV>(
|
|
5378
|
+
object: C,
|
|
5379
|
+
key: K,
|
|
5380
|
+
notSetValue: NSV,
|
|
5381
|
+
updater: (value: C[K] | NSV) => C[K]
|
|
5382
|
+
): C;
|
|
5383
|
+
export function update<V, C extends { [key: string]: V }, K extends keyof C>(
|
|
5384
|
+
collection: C,
|
|
5385
|
+
key: K,
|
|
5386
|
+
updater: (value: V) => V
|
|
5387
|
+
): { [key: string]: V };
|
|
5388
|
+
export function update<
|
|
5389
|
+
V,
|
|
5390
|
+
C extends { [key: string]: V },
|
|
5391
|
+
K extends keyof C,
|
|
5392
|
+
NSV
|
|
5393
|
+
>(
|
|
5394
|
+
collection: C,
|
|
5395
|
+
key: K,
|
|
5396
|
+
notSetValue: NSV,
|
|
5397
|
+
updater: (value: V | NSV) => V
|
|
5398
|
+
): { [key: string]: V };
|
|
5165
5399
|
|
|
5166
5400
|
/**
|
|
5167
5401
|
* Returns the value at the provided key path starting at the provided
|
|
@@ -5177,7 +5411,11 @@ declare module Immutable {
|
|
|
5177
5411
|
* getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet'
|
|
5178
5412
|
* ```
|
|
5179
5413
|
*/
|
|
5180
|
-
export function getIn(
|
|
5414
|
+
export function getIn(
|
|
5415
|
+
collection: unknown,
|
|
5416
|
+
keyPath: Iterable<unknown>,
|
|
5417
|
+
notSetValue: unknown
|
|
5418
|
+
): unknown;
|
|
5181
5419
|
|
|
5182
5420
|
/**
|
|
5183
5421
|
* Returns true if the key path is defined in the provided collection.
|
|
@@ -5192,7 +5430,10 @@ declare module Immutable {
|
|
|
5192
5430
|
* hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false
|
|
5193
5431
|
* ```
|
|
5194
5432
|
*/
|
|
5195
|
-
export function hasIn(
|
|
5433
|
+
export function hasIn(
|
|
5434
|
+
collection: unknown,
|
|
5435
|
+
keyPath: Iterable<unknown>
|
|
5436
|
+
): boolean;
|
|
5196
5437
|
|
|
5197
5438
|
/**
|
|
5198
5439
|
* Returns a copy of the collection with the value at the key path removed.
|
|
@@ -5208,7 +5449,7 @@ declare module Immutable {
|
|
|
5208
5449
|
* console.log(original) // { x: { y: { z: 123 }}}
|
|
5209
5450
|
* ```
|
|
5210
5451
|
*/
|
|
5211
|
-
export function removeIn<C>(collection: C, keyPath: Iterable<
|
|
5452
|
+
export function removeIn<C>(collection: C, keyPath: Iterable<unknown>): C;
|
|
5212
5453
|
|
|
5213
5454
|
/**
|
|
5214
5455
|
* Returns a copy of the collection with the value at the key path set to the
|
|
@@ -5225,7 +5466,11 @@ declare module Immutable {
|
|
|
5225
5466
|
* console.log(original) // { x: { y: { z: 123 }}}
|
|
5226
5467
|
* ```
|
|
5227
5468
|
*/
|
|
5228
|
-
export function setIn<C>(
|
|
5469
|
+
export function setIn<C>(
|
|
5470
|
+
collection: C,
|
|
5471
|
+
keyPath: Iterable<unknown>,
|
|
5472
|
+
value: unknown
|
|
5473
|
+
): C;
|
|
5229
5474
|
|
|
5230
5475
|
/**
|
|
5231
5476
|
* Returns a copy of the collection with the value at key path set to the
|
|
@@ -5242,8 +5487,17 @@ declare module Immutable {
|
|
|
5242
5487
|
* console.log(original) // { x: { y: { z: 123 }}}
|
|
5243
5488
|
* ```
|
|
5244
5489
|
*/
|
|
5245
|
-
export function updateIn<C>(
|
|
5246
|
-
|
|
5490
|
+
export function updateIn<C>(
|
|
5491
|
+
collection: C,
|
|
5492
|
+
keyPath: Iterable<unknown>,
|
|
5493
|
+
updater: (value: unknown) => unknown
|
|
5494
|
+
): C;
|
|
5495
|
+
export function updateIn<C>(
|
|
5496
|
+
collection: C,
|
|
5497
|
+
keyPath: Iterable<unknown>,
|
|
5498
|
+
notSetValue: unknown,
|
|
5499
|
+
updater: (value: unknown) => unknown
|
|
5500
|
+
): C;
|
|
5247
5501
|
|
|
5248
5502
|
/**
|
|
5249
5503
|
* Returns a copy of the collection with the remaining collections merged in.
|
|
@@ -5261,7 +5515,11 @@ declare module Immutable {
|
|
|
5261
5515
|
*/
|
|
5262
5516
|
export function merge<C>(
|
|
5263
5517
|
collection: C,
|
|
5264
|
-
...collections: Array<
|
|
5518
|
+
...collections: Array<
|
|
5519
|
+
| Iterable<unknown>
|
|
5520
|
+
| Iterable<[unknown, unknown]>
|
|
5521
|
+
| { [key: string]: unknown }
|
|
5522
|
+
>
|
|
5265
5523
|
): C;
|
|
5266
5524
|
|
|
5267
5525
|
/**
|
|
@@ -5284,9 +5542,13 @@ declare module Immutable {
|
|
|
5284
5542
|
* ```
|
|
5285
5543
|
*/
|
|
5286
5544
|
export function mergeWith<C>(
|
|
5287
|
-
merger: (oldVal:
|
|
5545
|
+
merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
|
|
5288
5546
|
collection: C,
|
|
5289
|
-
...collections: Array<
|
|
5547
|
+
...collections: Array<
|
|
5548
|
+
| Iterable<unknown>
|
|
5549
|
+
| Iterable<[unknown, unknown]>
|
|
5550
|
+
| { [key: string]: unknown }
|
|
5551
|
+
>
|
|
5290
5552
|
): C;
|
|
5291
5553
|
|
|
5292
5554
|
/**
|
|
@@ -5306,7 +5568,11 @@ declare module Immutable {
|
|
|
5306
5568
|
*/
|
|
5307
5569
|
export function mergeDeep<C>(
|
|
5308
5570
|
collection: C,
|
|
5309
|
-
...collections: Array<
|
|
5571
|
+
...collections: Array<
|
|
5572
|
+
| Iterable<unknown>
|
|
5573
|
+
| Iterable<[unknown, unknown]>
|
|
5574
|
+
| { [key: string]: unknown }
|
|
5575
|
+
>
|
|
5310
5576
|
): C;
|
|
5311
5577
|
|
|
5312
5578
|
/**
|
|
@@ -5330,12 +5596,16 @@ declare module Immutable {
|
|
|
5330
5596
|
* ```
|
|
5331
5597
|
*/
|
|
5332
5598
|
export function mergeDeepWith<C>(
|
|
5333
|
-
merger: (oldVal:
|
|
5599
|
+
merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
|
|
5334
5600
|
collection: C,
|
|
5335
|
-
...collections: Array<
|
|
5601
|
+
...collections: Array<
|
|
5602
|
+
| Iterable<unknown>
|
|
5603
|
+
| Iterable<[unknown, unknown]>
|
|
5604
|
+
| { [key: string]: unknown }
|
|
5605
|
+
>
|
|
5336
5606
|
): C;
|
|
5337
5607
|
}
|
|
5338
5608
|
|
|
5339
|
-
declare module
|
|
5340
|
-
export = Immutable
|
|
5609
|
+
declare module 'immutable' {
|
|
5610
|
+
export = Immutable;
|
|
5341
5611
|
}
|