immutable 3.7.4 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -10
- package/contrib/cursor/__tests__/{Cursor.ts → Cursor.ts.skip} +108 -80
- package/contrib/cursor/index.d.ts +9 -4
- package/contrib/cursor/index.js +6 -2
- package/dist/immutable-nonambient.d.ts +2535 -0
- package/dist/immutable.d.ts +591 -528
- package/dist/immutable.js +1949 -1897
- package/dist/immutable.js.flow +663 -0
- package/dist/immutable.min.js +28 -44
- package/package.json +57 -22
package/dist/immutable.d.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* [ES6]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
declare module
|
|
31
|
+
declare module Immutable {
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Deeply converts plain JS objects and arrays to Immutable Maps and Lists.
|
|
@@ -38,7 +38,7 @@ declare module 'immutable' {
|
|
|
38
38
|
* and proceeding to the top-level collection itself), along with the key
|
|
39
39
|
* refering to each collection and the parent JS object provided as `this`.
|
|
40
40
|
* For the top level, object, the key will be `""`. This `reviver` is expected
|
|
41
|
-
* to return a new Immutable Iterable, allowing for custom
|
|
41
|
+
* to return a new Immutable Iterable, allowing for custom conversions from
|
|
42
42
|
* deep JS objects.
|
|
43
43
|
*
|
|
44
44
|
* This example converts JSON to List and OrderedMap:
|
|
@@ -57,10 +57,29 @@ declare module 'immutable' {
|
|
|
57
57
|
*
|
|
58
58
|
* `reviver` acts similarly to the [same parameter in `JSON.parse`][1].
|
|
59
59
|
*
|
|
60
|
-
* `Immutable.fromJS` is conservative in
|
|
60
|
+
* `Immutable.fromJS` is conservative in its conversion. It will only convert
|
|
61
61
|
* arrays which pass `Array.isArray` to Lists, and only raw objects (no custom
|
|
62
62
|
* prototype) to Map.
|
|
63
63
|
*
|
|
64
|
+
* Keep in mind, when using JS objects to construct Immutable Maps, that
|
|
65
|
+
* JavaScript Object properties are always strings, even if written in a
|
|
66
|
+
* quote-less shorthand, while Immutable Maps accept keys of any type.
|
|
67
|
+
*
|
|
68
|
+
* ```js
|
|
69
|
+
* var obj = { 1: "one" };
|
|
70
|
+
* Object.keys(obj); // [ "1" ]
|
|
71
|
+
* obj["1"]; // "one"
|
|
72
|
+
* obj[1]; // "one"
|
|
73
|
+
*
|
|
74
|
+
* var map = Map(obj);
|
|
75
|
+
* map.get("1"); // "one"
|
|
76
|
+
* map.get(1); // undefined
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* Property access for JavaScript Objects first converts the key to a string,
|
|
80
|
+
* but since Immutable Map keys can be of any type the argument to `get()` is
|
|
81
|
+
* not altered.
|
|
82
|
+
*
|
|
64
83
|
* [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter
|
|
65
84
|
* "Using the reviver parameter"
|
|
66
85
|
*/
|
|
@@ -102,7 +121,7 @@ declare module 'immutable' {
|
|
|
102
121
|
*
|
|
103
122
|
* Unlike a JavaScript Array, there is no distinction between an
|
|
104
123
|
* "unset" index and an index set to `undefined`. `List#forEach` visits all
|
|
105
|
-
* indices from 0 to size, regardless of
|
|
124
|
+
* indices from 0 to size, regardless of whether they were explicitly defined.
|
|
106
125
|
*/
|
|
107
126
|
export module List {
|
|
108
127
|
|
|
@@ -122,15 +141,15 @@ declare module 'immutable' {
|
|
|
122
141
|
* iterable-like.
|
|
123
142
|
*/
|
|
124
143
|
export function List<T>(): List<T>;
|
|
125
|
-
export function List<T>(iter:
|
|
126
|
-
export function List<T>(iter:
|
|
127
|
-
export function List<K, V>(iter:
|
|
144
|
+
export function List<T>(iter: Iterable.Indexed<T>): List<T>;
|
|
145
|
+
export function List<T>(iter: Iterable.Set<T>): List<T>;
|
|
146
|
+
export function List<K, V>(iter: Iterable.Keyed<K, V>): List</*[K,V]*/any>;
|
|
128
147
|
export function List<T>(array: Array<T>): List<T>;
|
|
129
148
|
export function List<T>(iterator: Iterator<T>): List<T>;
|
|
130
149
|
export function List<T>(iterable: /*Iterable<T>*/Object): List<T>;
|
|
131
150
|
|
|
132
151
|
|
|
133
|
-
export interface List<T> extends
|
|
152
|
+
export interface List<T> extends Collection.Indexed<T> {
|
|
134
153
|
|
|
135
154
|
// Persistent changes
|
|
136
155
|
|
|
@@ -148,7 +167,7 @@ declare module 'immutable' {
|
|
|
148
167
|
|
|
149
168
|
/**
|
|
150
169
|
* Returns a new List which excludes this `index` and with a size 1 less
|
|
151
|
-
* than this List. Values at
|
|
170
|
+
* than this List. Values at indices above `index` are shifted down by 1 to
|
|
152
171
|
* fill the position.
|
|
153
172
|
*
|
|
154
173
|
* This is synonymous with `list.splice(index, 1)`.
|
|
@@ -162,6 +181,14 @@ declare module 'immutable' {
|
|
|
162
181
|
delete(index: number): List<T>;
|
|
163
182
|
remove(index: number): List<T>;
|
|
164
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Returns a new List with `value` at `index` with a size 1 more than this
|
|
186
|
+
* List. Values at indices above `index` are shifted over by 1.
|
|
187
|
+
*
|
|
188
|
+
* This is synonymous with `list.splice(index, 0, value)
|
|
189
|
+
*/
|
|
190
|
+
insert(index: number, value: T): List<T>;
|
|
191
|
+
|
|
165
192
|
/**
|
|
166
193
|
* Returns a new List with 0 size and no values.
|
|
167
194
|
*/
|
|
@@ -217,7 +244,7 @@ declare module 'immutable' {
|
|
|
217
244
|
/**
|
|
218
245
|
* @see `Map#merge`
|
|
219
246
|
*/
|
|
220
|
-
merge(...iterables:
|
|
247
|
+
merge(...iterables: Iterable.Indexed<T>[]): List<T>;
|
|
221
248
|
merge(...iterables: Array<T>[]): List<T>;
|
|
222
249
|
|
|
223
250
|
/**
|
|
@@ -225,7 +252,7 @@ declare module 'immutable' {
|
|
|
225
252
|
*/
|
|
226
253
|
mergeWith(
|
|
227
254
|
merger: (previous?: T, next?: T, key?: number) => T,
|
|
228
|
-
...iterables:
|
|
255
|
+
...iterables: Iterable.Indexed<T>[]
|
|
229
256
|
): List<T>;
|
|
230
257
|
mergeWith(
|
|
231
258
|
merger: (previous?: T, next?: T, key?: number) => T,
|
|
@@ -235,7 +262,7 @@ declare module 'immutable' {
|
|
|
235
262
|
/**
|
|
236
263
|
* @see `Map#mergeDeep`
|
|
237
264
|
*/
|
|
238
|
-
mergeDeep(...iterables:
|
|
265
|
+
mergeDeep(...iterables: Iterable.Indexed<T>[]): List<T>;
|
|
239
266
|
mergeDeep(...iterables: Array<T>[]): List<T>;
|
|
240
267
|
|
|
241
268
|
/**
|
|
@@ -243,7 +270,7 @@ declare module 'immutable' {
|
|
|
243
270
|
*/
|
|
244
271
|
mergeDeepWith(
|
|
245
272
|
merger: (previous?: T, next?: T, key?: number) => T,
|
|
246
|
-
...iterables:
|
|
273
|
+
...iterables: Iterable.Indexed<T>[]
|
|
247
274
|
): List<T>;
|
|
248
275
|
mergeDeepWith(
|
|
249
276
|
merger: (previous?: T, next?: T, key?: number) => T,
|
|
@@ -313,11 +340,11 @@ declare module 'immutable' {
|
|
|
313
340
|
*/
|
|
314
341
|
mergeIn(
|
|
315
342
|
keyPath: Iterable<any, any>,
|
|
316
|
-
...iterables:
|
|
343
|
+
...iterables: Iterable.Indexed<T>[]
|
|
317
344
|
): List<T>;
|
|
318
345
|
mergeIn(
|
|
319
346
|
keyPath: Array<any>,
|
|
320
|
-
...iterables:
|
|
347
|
+
...iterables: Iterable.Indexed<T>[]
|
|
321
348
|
): List<T>;
|
|
322
349
|
mergeIn(
|
|
323
350
|
keyPath: Array<any>,
|
|
@@ -329,11 +356,11 @@ declare module 'immutable' {
|
|
|
329
356
|
*/
|
|
330
357
|
mergeDeepIn(
|
|
331
358
|
keyPath: Iterable<any, any>,
|
|
332
|
-
...iterables:
|
|
359
|
+
...iterables: Iterable.Indexed<T>[]
|
|
333
360
|
): List<T>;
|
|
334
361
|
mergeDeepIn(
|
|
335
362
|
keyPath: Array<any>,
|
|
336
|
-
...iterables:
|
|
363
|
+
...iterables: Iterable.Indexed<T>[]
|
|
337
364
|
): List<T>;
|
|
338
365
|
mergeDeepIn(
|
|
339
366
|
keyPath: Array<any>,
|
|
@@ -365,7 +392,7 @@ declare module 'immutable' {
|
|
|
365
392
|
|
|
366
393
|
|
|
367
394
|
/**
|
|
368
|
-
* Immutable Map is an unordered
|
|
395
|
+
* Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with
|
|
369
396
|
* `O(log32 N)` gets and `O(log32 N)` persistent sets.
|
|
370
397
|
*
|
|
371
398
|
* Iteration order of a Map is undefined, however is stable. Multiple
|
|
@@ -393,27 +420,50 @@ declare module 'immutable' {
|
|
|
393
420
|
* True if the provided value is a Map
|
|
394
421
|
*/
|
|
395
422
|
function isMap(maybeMap: any): boolean;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Creates a new Map from alternating keys and values
|
|
426
|
+
*/
|
|
427
|
+
function of(...keyValues: any[]): Map<any, any>;
|
|
396
428
|
}
|
|
397
429
|
|
|
398
430
|
/**
|
|
399
431
|
* Creates a new Immutable Map.
|
|
400
432
|
*
|
|
401
|
-
* Created with the same key value pairs as the provided
|
|
433
|
+
* Created with the same key value pairs as the provided Iterable.Keyed or
|
|
402
434
|
* JavaScript Object or expects an Iterable of [K, V] tuple entries.
|
|
403
435
|
*
|
|
404
436
|
* var newMap = Map({key: "value"});
|
|
405
437
|
* var newMap = Map([["key", "value"]]);
|
|
406
438
|
*
|
|
439
|
+
* Keep in mind, when using JS objects to construct Immutable Maps, that
|
|
440
|
+
* JavaScript Object properties are always strings, even if written in a
|
|
441
|
+
* quote-less shorthand, while Immutable Maps accept keys of any type.
|
|
442
|
+
*
|
|
443
|
+
* ```js
|
|
444
|
+
* var obj = { 1: "one" };
|
|
445
|
+
* Object.keys(obj); // [ "1" ]
|
|
446
|
+
* obj["1"]; // "one"
|
|
447
|
+
* obj[1]; // "one"
|
|
448
|
+
*
|
|
449
|
+
* var map = Map(obj);
|
|
450
|
+
* map.get("1"); // "one"
|
|
451
|
+
* map.get(1); // undefined
|
|
452
|
+
* ```
|
|
453
|
+
*
|
|
454
|
+
* Property access for JavaScript Objects first converts the key to a string,
|
|
455
|
+
* but since Immutable Map keys can be of any type the argument to `get()` is
|
|
456
|
+
* not altered.
|
|
407
457
|
*/
|
|
408
458
|
export function Map<K, V>(): Map<K, V>;
|
|
409
|
-
export function Map<K, V>(iter:
|
|
459
|
+
export function Map<K, V>(iter: Iterable.Keyed<K, V>): Map<K, V>;
|
|
410
460
|
export function Map<K, V>(iter: Iterable<any, /*[K,V]*/Array<any>>): Map<K, V>;
|
|
411
461
|
export function Map<K, V>(array: Array</*[K,V]*/Array<any>>): Map<K, V>;
|
|
412
462
|
export function Map<V>(obj: {[key: string]: V}): Map<string, V>;
|
|
413
463
|
export function Map<K, V>(iterator: Iterator</*[K,V]*/Array<any>>): Map<K, V>;
|
|
414
464
|
export function Map<K, V>(iterable: /*Iterable<[K,V]>*/Object): Map<K, V>;
|
|
415
465
|
|
|
416
|
-
export interface Map<K, V> extends
|
|
466
|
+
export interface Map<K, V> extends Collection.Keyed<K, V> {
|
|
417
467
|
|
|
418
468
|
// Persistent changes
|
|
419
469
|
|
|
@@ -456,8 +506,8 @@ declare module 'immutable' {
|
|
|
456
506
|
* each iterable and sets it on this Map.
|
|
457
507
|
*
|
|
458
508
|
* If any of the values provided to `merge` are not Iterable (would return
|
|
459
|
-
* false for `Immutable.isIterable`) then they are deeply converted
|
|
460
|
-
* `Immutable.fromJS` before being merged. However, if the value is an
|
|
509
|
+
* false for `Immutable.Iterable.isIterable`) then they are deeply converted
|
|
510
|
+
* via `Immutable.fromJS` before being merged. However, if the value is an
|
|
461
511
|
* Iterable but includes non-iterable JS objects or arrays, those nested
|
|
462
512
|
* values will be preserved.
|
|
463
513
|
*
|
|
@@ -702,7 +752,7 @@ declare module 'immutable' {
|
|
|
702
752
|
/**
|
|
703
753
|
* Creates a new Immutable OrderedMap.
|
|
704
754
|
*
|
|
705
|
-
* Created with the same key value pairs as the provided
|
|
755
|
+
* Created with the same key value pairs as the provided Iterable.Keyed or
|
|
706
756
|
* JavaScript Object or expects an Iterable of [K, V] tuple entries.
|
|
707
757
|
*
|
|
708
758
|
* The iteration order of key-value pairs provided to this constructor will
|
|
@@ -713,7 +763,7 @@ declare module 'immutable' {
|
|
|
713
763
|
*
|
|
714
764
|
*/
|
|
715
765
|
export function OrderedMap<K, V>(): OrderedMap<K, V>;
|
|
716
|
-
export function OrderedMap<K, V>(iter:
|
|
766
|
+
export function OrderedMap<K, V>(iter: Iterable.Keyed<K, V>): OrderedMap<K, V>;
|
|
717
767
|
export function OrderedMap<K, V>(iter: Iterable<any, /*[K,V]*/Array<any>>): OrderedMap<K, V>;
|
|
718
768
|
export function OrderedMap<K, V>(array: Array</*[K,V]*/Array<any>>): OrderedMap<K, V>;
|
|
719
769
|
export function OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V>;
|
|
@@ -759,14 +809,14 @@ declare module 'immutable' {
|
|
|
759
809
|
* iterable-like.
|
|
760
810
|
*/
|
|
761
811
|
export function Set<T>(): Set<T>;
|
|
762
|
-
export function Set<T>(iter:
|
|
763
|
-
export function Set<T>(iter:
|
|
764
|
-
export function Set<K, V>(iter:
|
|
812
|
+
export function Set<T>(iter: Iterable.Set<T>): Set<T>;
|
|
813
|
+
export function Set<T>(iter: Iterable.Indexed<T>): Set<T>;
|
|
814
|
+
export function Set<K, V>(iter: Iterable.Keyed<K, V>): Set</*[K,V]*/any>;
|
|
765
815
|
export function Set<T>(array: Array<T>): Set<T>;
|
|
766
816
|
export function Set<T>(iterator: Iterator<T>): Set<T>;
|
|
767
817
|
export function Set<T>(iterable: /*Iterable<T>*/Object): Set<T>;
|
|
768
818
|
|
|
769
|
-
export interface Set<T> extends
|
|
819
|
+
export interface Set<T> extends Collection.Set<T> {
|
|
770
820
|
|
|
771
821
|
// Persistent changes
|
|
772
822
|
|
|
@@ -871,9 +921,9 @@ declare module 'immutable' {
|
|
|
871
921
|
* iterable-like.
|
|
872
922
|
*/
|
|
873
923
|
export function OrderedSet<T>(): OrderedSet<T>;
|
|
874
|
-
export function OrderedSet<T>(iter:
|
|
875
|
-
export function OrderedSet<T>(iter:
|
|
876
|
-
export function OrderedSet<K, V>(iter:
|
|
924
|
+
export function OrderedSet<T>(iter: Iterable.Set<T>): OrderedSet<T>;
|
|
925
|
+
export function OrderedSet<T>(iter: Iterable.Indexed<T>): OrderedSet<T>;
|
|
926
|
+
export function OrderedSet<K, V>(iter: Iterable.Keyed<K, V>): OrderedSet</*[K,V]*/any>;
|
|
877
927
|
export function OrderedSet<T>(array: Array<T>): OrderedSet<T>;
|
|
878
928
|
export function OrderedSet<T>(iterator: Iterator<T>): OrderedSet<T>;
|
|
879
929
|
export function OrderedSet<T>(iterable: /*Iterable<T>*/Object): OrderedSet<T>;
|
|
@@ -915,14 +965,14 @@ declare module 'immutable' {
|
|
|
915
965
|
* resulting `Stack`.
|
|
916
966
|
*/
|
|
917
967
|
export function Stack<T>(): Stack<T>;
|
|
918
|
-
export function Stack<T>(iter:
|
|
919
|
-
export function Stack<T>(iter:
|
|
920
|
-
export function Stack<K, V>(iter:
|
|
968
|
+
export function Stack<T>(iter: Iterable.Indexed<T>): Stack<T>;
|
|
969
|
+
export function Stack<T>(iter: Iterable.Set<T>): Stack<T>;
|
|
970
|
+
export function Stack<K, V>(iter: Iterable.Keyed<K, V>): Stack</*[K,V]*/any>;
|
|
921
971
|
export function Stack<T>(array: Array<T>): Stack<T>;
|
|
922
972
|
export function Stack<T>(iterator: Iterator<T>): Stack<T>;
|
|
923
973
|
export function Stack<T>(iterable: /*Iterable<T>*/Object): Stack<T>;
|
|
924
974
|
|
|
925
|
-
export interface Stack<T> extends
|
|
975
|
+
export interface Stack<T> extends Collection.Indexed<T> {
|
|
926
976
|
|
|
927
977
|
// Reading values
|
|
928
978
|
|
|
@@ -1003,7 +1053,7 @@ declare module 'immutable' {
|
|
|
1003
1053
|
|
|
1004
1054
|
|
|
1005
1055
|
/**
|
|
1006
|
-
* Returns a
|
|
1056
|
+
* Returns a Seq.Indexed of numbers from `start` (inclusive) to `end`
|
|
1007
1057
|
* (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to
|
|
1008
1058
|
* infinity. When `start` is equal to `end`, returns empty range.
|
|
1009
1059
|
*
|
|
@@ -1015,18 +1065,18 @@ declare module 'immutable' {
|
|
|
1015
1065
|
* Range(30,30,5) // []
|
|
1016
1066
|
*
|
|
1017
1067
|
*/
|
|
1018
|
-
export function Range(start?: number, end?: number, step?: number):
|
|
1068
|
+
export function Range(start?: number, end?: number, step?: number): Seq.Indexed<number>;
|
|
1019
1069
|
|
|
1020
1070
|
|
|
1021
1071
|
/**
|
|
1022
|
-
* Returns a
|
|
1072
|
+
* Returns a Seq.Indexed of `value` repeated `times` times. When `times` is
|
|
1023
1073
|
* not defined, returns an infinite `Seq` of `value`.
|
|
1024
1074
|
*
|
|
1025
1075
|
* Repeat('foo') // ['foo','foo','foo',...]
|
|
1026
1076
|
* Repeat('bar',4) // ['bar','bar','bar','bar']
|
|
1027
1077
|
*
|
|
1028
1078
|
*/
|
|
1029
|
-
export function Repeat<T>(value: T, times?: number):
|
|
1079
|
+
export function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
|
|
1030
1080
|
|
|
1031
1081
|
|
|
1032
1082
|
/**
|
|
@@ -1048,7 +1098,9 @@ declare module 'immutable' {
|
|
|
1048
1098
|
* myRecordWithoutB.size // 2
|
|
1049
1099
|
*
|
|
1050
1100
|
* Values provided to the constructor not found in the Record type will
|
|
1051
|
-
* be ignored
|
|
1101
|
+
* be ignored. For example, in this case, ABRecord is provided a key "x" even
|
|
1102
|
+
* though only "a" and "b" have been defined. The value for "x" will be
|
|
1103
|
+
* ignored for this record.
|
|
1052
1104
|
*
|
|
1053
1105
|
* var myRecord = new ABRecord({b:3, x:10})
|
|
1054
1106
|
* myRecord.get('x') // undefined
|
|
@@ -1074,12 +1126,12 @@ declare module 'immutable' {
|
|
|
1074
1126
|
* }
|
|
1075
1127
|
* }
|
|
1076
1128
|
*
|
|
1077
|
-
* var myRecord = new ABRecord(b:3)
|
|
1129
|
+
* var myRecord = new ABRecord({b: 3})
|
|
1078
1130
|
* myRecord.getAB() // 4
|
|
1079
1131
|
*
|
|
1080
1132
|
*/
|
|
1081
1133
|
export module Record {
|
|
1082
|
-
interface Class {
|
|
1134
|
+
export interface Class {
|
|
1083
1135
|
new (): Map<string, any>;
|
|
1084
1136
|
new (values: {[key: string]: any}): Map<string, any>;
|
|
1085
1137
|
new (values: Iterable<string, any>): Map<string, any>; // deprecated
|
|
@@ -1116,9 +1168,9 @@ declare module 'immutable' {
|
|
|
1116
1168
|
*
|
|
1117
1169
|
* Once the Seq is used, it performs only the work necessary. In this
|
|
1118
1170
|
* example, no intermediate data structures are ever created, filter is only
|
|
1119
|
-
* called three times, and map is only called
|
|
1171
|
+
* called three times, and map is only called once:
|
|
1120
1172
|
*
|
|
1121
|
-
* console.log(
|
|
1173
|
+
* console.log(oddSquares.get(1)); // 9
|
|
1122
1174
|
*
|
|
1123
1175
|
* Seq allows for the efficient chaining of operations,
|
|
1124
1176
|
* allowing for the expression of logic that can otherwise be very tedious:
|
|
@@ -1151,9 +1203,102 @@ declare module 'immutable' {
|
|
|
1151
1203
|
function isSeq(maybeSeq: any): boolean;
|
|
1152
1204
|
|
|
1153
1205
|
/**
|
|
1154
|
-
* Returns a Seq of the values provided. Alias for `
|
|
1206
|
+
* Returns a Seq of the values provided. Alias for `Seq.Indexed.of()`.
|
|
1207
|
+
*/
|
|
1208
|
+
function of<T>(...values: T[]): Seq.Indexed<T>;
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* `Seq` which represents key-value pairs.
|
|
1213
|
+
*/
|
|
1214
|
+
export module Keyed {}
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* Always returns a Seq.Keyed, if input is not keyed, expects an
|
|
1218
|
+
* iterable of [K, V] tuples.
|
|
1219
|
+
*/
|
|
1220
|
+
export function Keyed<K, V>(): Seq.Keyed<K, V>;
|
|
1221
|
+
export function Keyed<K, V>(seq: Iterable.Keyed<K, V>): Seq.Keyed<K, V>;
|
|
1222
|
+
export function Keyed<K, V>(seq: Iterable<any, /*[K,V]*/any>): Seq.Keyed<K, V>;
|
|
1223
|
+
export function Keyed<K, V>(array: Array</*[K,V]*/any>): Seq.Keyed<K, V>;
|
|
1224
|
+
export function Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
|
|
1225
|
+
export function Keyed<K, V>(iterator: Iterator</*[K,V]*/any>): Seq.Keyed<K, V>;
|
|
1226
|
+
export function Keyed<K, V>(iterable: /*Iterable<[K,V]>*/Object): Seq.Keyed<K, V>;
|
|
1227
|
+
|
|
1228
|
+
export interface Keyed<K, V> extends Seq<K, V>, Iterable.Keyed<K, V> {
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* Returns itself
|
|
1232
|
+
*/
|
|
1233
|
+
toSeq(): /*this*/Seq.Keyed<K, V>
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* `Seq` which represents an ordered indexed list of values.
|
|
1239
|
+
*/
|
|
1240
|
+
module Indexed {
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* Provides an Seq.Indexed of the values provided.
|
|
1244
|
+
*/
|
|
1245
|
+
function of<T>(...values: T[]): Seq.Indexed<T>;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* Always returns Seq.Indexed, discarding associated keys and
|
|
1250
|
+
* supplying incrementing indices.
|
|
1155
1251
|
*/
|
|
1156
|
-
function
|
|
1252
|
+
export function Indexed<T>(): Seq.Indexed<T>;
|
|
1253
|
+
export function Indexed<T>(seq: Iterable.Indexed<T>): Seq.Indexed<T>;
|
|
1254
|
+
export function Indexed<T>(seq: Iterable.Set<T>): Seq.Indexed<T>;
|
|
1255
|
+
export function Indexed<K, V>(seq: Iterable.Keyed<K, V>): Seq.Indexed</*[K,V]*/any>;
|
|
1256
|
+
export function Indexed<T>(array: Array<T>): Seq.Indexed<T>;
|
|
1257
|
+
export function Indexed<T>(iterator: Iterator<T>): Seq.Indexed<T>;
|
|
1258
|
+
export function Indexed<T>(iterable: /*Iterable<T>*/Object): Seq.Indexed<T>;
|
|
1259
|
+
|
|
1260
|
+
export interface Indexed<T> extends Seq<number, T>, Iterable.Indexed<T> {
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* Returns itself
|
|
1264
|
+
*/
|
|
1265
|
+
toSeq(): /*this*/Seq.Indexed<T>
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* `Seq` which represents a set of values.
|
|
1271
|
+
*
|
|
1272
|
+
* Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee
|
|
1273
|
+
* of value uniqueness as the concrete `Set`.
|
|
1274
|
+
*/
|
|
1275
|
+
export module Set {
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Returns a Seq.Set of the provided values
|
|
1279
|
+
*/
|
|
1280
|
+
function of<T>(...values: T[]): Seq.Set<T>;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Always returns a Seq.Set, discarding associated indices or keys.
|
|
1285
|
+
*/
|
|
1286
|
+
export function Set<T>(): Seq.Set<T>;
|
|
1287
|
+
export function Set<T>(seq: Iterable.Set<T>): Seq.Set<T>;
|
|
1288
|
+
export function Set<T>(seq: Iterable.Indexed<T>): Seq.Set<T>;
|
|
1289
|
+
export function Set<K, V>(seq: Iterable.Keyed<K, V>): Seq.Set</*[K,V]*/any>;
|
|
1290
|
+
export function Set<T>(array: Array<T>): Seq.Set<T>;
|
|
1291
|
+
export function Set<T>(iterator: Iterator<T>): Seq.Set<T>;
|
|
1292
|
+
export function Set<T>(iterable: /*Iterable<T>*/Object): Seq.Set<T>;
|
|
1293
|
+
|
|
1294
|
+
export interface Set<T> extends Seq<T, T>, Iterable.Set<T> {
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* Returns itself
|
|
1298
|
+
*/
|
|
1299
|
+
toSeq(): /*this*/Seq.Set<T>
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1157
1302
|
}
|
|
1158
1303
|
|
|
1159
1304
|
/**
|
|
@@ -1163,19 +1308,19 @@ declare module 'immutable' {
|
|
|
1163
1308
|
*
|
|
1164
1309
|
* * If a `Seq`, that same `Seq`.
|
|
1165
1310
|
* * If an `Iterable`, a `Seq` of the same kind (Keyed, Indexed, or Set).
|
|
1166
|
-
* * If an Array-like, an `
|
|
1167
|
-
* * If an Object with an Iterator, an `
|
|
1168
|
-
* * If an Iterator, an `
|
|
1169
|
-
* * If an Object, a `
|
|
1311
|
+
* * If an Array-like, an `Seq.Indexed`.
|
|
1312
|
+
* * If an Object with an Iterator, an `Seq.Indexed`.
|
|
1313
|
+
* * If an Iterator, an `Seq.Indexed`.
|
|
1314
|
+
* * If an Object, a `Seq.Keyed`.
|
|
1170
1315
|
*
|
|
1171
1316
|
*/
|
|
1172
1317
|
export function Seq<K, V>(): Seq<K, V>;
|
|
1173
1318
|
export function Seq<K, V>(seq: Seq<K, V>): Seq<K, V>;
|
|
1174
1319
|
export function Seq<K, V>(iterable: Iterable<K, V>): Seq<K, V>;
|
|
1175
|
-
export function Seq<T>(array: Array<T>):
|
|
1176
|
-
export function Seq<V>(obj: {[key: string]: V}):
|
|
1177
|
-
export function Seq<T>(iterator: Iterator<T>):
|
|
1178
|
-
export function Seq<T>(iterable: /*ES6Iterable<T>*/Object):
|
|
1320
|
+
export function Seq<T>(array: Array<T>): Seq.Indexed<T>;
|
|
1321
|
+
export function Seq<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
|
|
1322
|
+
export function Seq<T>(iterator: Iterator<T>): Seq.Indexed<T>;
|
|
1323
|
+
export function Seq<T>(iterable: /*ES6Iterable<T>*/Object): Seq.Indexed<T>;
|
|
1179
1324
|
|
|
1180
1325
|
export interface Seq<K, V> extends Iterable<K, V> {
|
|
1181
1326
|
|
|
@@ -1217,98 +1362,6 @@ declare module 'immutable' {
|
|
|
1217
1362
|
cacheResult(): /*this*/Seq<K, V>;
|
|
1218
1363
|
}
|
|
1219
1364
|
|
|
1220
|
-
|
|
1221
|
-
/**
|
|
1222
|
-
* `Seq` which represents key-value pairs.
|
|
1223
|
-
*/
|
|
1224
|
-
export module KeyedSeq {}
|
|
1225
|
-
|
|
1226
|
-
/**
|
|
1227
|
-
* Always returns a KeyedSeq, if input is not keyed, expects an
|
|
1228
|
-
* iterable of [K, V] tuples.
|
|
1229
|
-
*/
|
|
1230
|
-
export function KeyedSeq<K, V>(): KeyedSeq<K, V>;
|
|
1231
|
-
export function KeyedSeq<K, V>(seq: KeyedIterable<K, V>): KeyedSeq<K, V>;
|
|
1232
|
-
export function KeyedSeq<K, V>(seq: Iterable<any, /*[K,V]*/any>): KeyedSeq<K, V>;
|
|
1233
|
-
export function KeyedSeq<K, V>(array: Array</*[K,V]*/any>): KeyedSeq<K, V>;
|
|
1234
|
-
export function KeyedSeq<V>(obj: {[key: string]: V}): KeyedSeq<string, V>;
|
|
1235
|
-
export function KeyedSeq<K, V>(iterator: Iterator</*[K,V]*/any>): KeyedSeq<K, V>;
|
|
1236
|
-
export function KeyedSeq<K, V>(iterable: /*Iterable<[K,V]>*/Object): KeyedSeq<K, V>;
|
|
1237
|
-
|
|
1238
|
-
export interface KeyedSeq<K, V> extends Seq<K, V>, KeyedIterable<K, V> {
|
|
1239
|
-
|
|
1240
|
-
/**
|
|
1241
|
-
* Returns itself
|
|
1242
|
-
*/
|
|
1243
|
-
toSeq(): /*this*/KeyedSeq<K, V>
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
/**
|
|
1248
|
-
* `Seq` which represents an ordered indexed list of values.
|
|
1249
|
-
*/
|
|
1250
|
-
export module IndexedSeq {
|
|
1251
|
-
|
|
1252
|
-
/**
|
|
1253
|
-
* Provides an IndexedSeq of the values provided.
|
|
1254
|
-
*/
|
|
1255
|
-
function of<T>(...values: T[]): IndexedSeq<T>;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
/**
|
|
1259
|
-
* Always returns IndexedSeq, discarding associated keys and
|
|
1260
|
-
* supplying incrementing indices.
|
|
1261
|
-
*/
|
|
1262
|
-
export function IndexedSeq<T>(): IndexedSeq<T>;
|
|
1263
|
-
export function IndexedSeq<T>(seq: IndexedIterable<T>): IndexedSeq<T>;
|
|
1264
|
-
export function IndexedSeq<T>(seq: SetIterable<T>): IndexedSeq<T>;
|
|
1265
|
-
export function IndexedSeq<K, V>(seq: KeyedIterable<K, V>): IndexedSeq</*[K,V]*/any>;
|
|
1266
|
-
export function IndexedSeq<T>(array: Array<T>): IndexedSeq<T>;
|
|
1267
|
-
export function IndexedSeq<T>(iterator: Iterator<T>): IndexedSeq<T>;
|
|
1268
|
-
export function IndexedSeq<T>(iterable: /*Iterable<T>*/Object): IndexedSeq<T>;
|
|
1269
|
-
|
|
1270
|
-
export interface IndexedSeq<T> extends Seq<number, T>, IndexedIterable<T> {
|
|
1271
|
-
|
|
1272
|
-
/**
|
|
1273
|
-
* Returns itself
|
|
1274
|
-
*/
|
|
1275
|
-
toSeq(): /*this*/IndexedSeq<T>
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
/**
|
|
1279
|
-
* `Seq` which represents a set of values.
|
|
1280
|
-
*
|
|
1281
|
-
* Because `Seq` are often lazy, `SetSeq` does not provide the same guarantee
|
|
1282
|
-
* of value uniqueness as the concrete `Set`.
|
|
1283
|
-
*/
|
|
1284
|
-
export module SetSeq {
|
|
1285
|
-
|
|
1286
|
-
/**
|
|
1287
|
-
* Returns a SetSeq of the provided values
|
|
1288
|
-
*/
|
|
1289
|
-
function of<T>(...values: T[]): SetSeq<T>;
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
/**
|
|
1293
|
-
* Always returns a SetSeq, discarding associated indices or keys.
|
|
1294
|
-
*/
|
|
1295
|
-
export function SetSeq<T>(): SetSeq<T>;
|
|
1296
|
-
export function SetSeq<T>(seq: SetIterable<T>): SetSeq<T>;
|
|
1297
|
-
export function SetSeq<T>(seq: IndexedIterable<T>): SetSeq<T>;
|
|
1298
|
-
export function SetSeq<K, V>(seq: KeyedIterable<K, V>): SetSeq</*[K,V]*/any>;
|
|
1299
|
-
export function SetSeq<T>(array: Array<T>): SetSeq<T>;
|
|
1300
|
-
export function SetSeq<T>(iterator: Iterator<T>): SetSeq<T>;
|
|
1301
|
-
export function SetSeq<T>(iterable: /*Iterable<T>*/Object): SetSeq<T>;
|
|
1302
|
-
|
|
1303
|
-
export interface SetSeq<T> extends Seq<T, T>, SetIterable<T> {
|
|
1304
|
-
|
|
1305
|
-
/**
|
|
1306
|
-
* Returns itself
|
|
1307
|
-
*/
|
|
1308
|
-
toSeq(): /*this*/SetSeq<T>
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
1365
|
/**
|
|
1313
1366
|
* The `Iterable` is a set of (key, value) entries which can be iterated, and
|
|
1314
1367
|
* is the base class for all collections in `immutable`, allowing them to
|
|
@@ -1324,12 +1377,12 @@ declare module 'immutable' {
|
|
|
1324
1377
|
function isIterable(maybeIterable: any): boolean;
|
|
1325
1378
|
|
|
1326
1379
|
/**
|
|
1327
|
-
* True if `maybeKeyed` is
|
|
1380
|
+
* True if `maybeKeyed` is an Iterable.Keyed, or any of its subclasses.
|
|
1328
1381
|
*/
|
|
1329
1382
|
function isKeyed(maybeKeyed: any): boolean;
|
|
1330
1383
|
|
|
1331
1384
|
/**
|
|
1332
|
-
* True if `maybeIndexed` is a
|
|
1385
|
+
* True if `maybeIndexed` is a Iterable.Indexed, or any of its subclasses.
|
|
1333
1386
|
*/
|
|
1334
1387
|
function isIndexed(maybeIndexed: any): boolean;
|
|
1335
1388
|
|
|
@@ -1340,9 +1393,293 @@ declare module 'immutable' {
|
|
|
1340
1393
|
|
|
1341
1394
|
/**
|
|
1342
1395
|
* True if `maybeOrdered` is an Iterable where iteration order is well
|
|
1343
|
-
* defined. True for
|
|
1396
|
+
* defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.
|
|
1344
1397
|
*/
|
|
1345
1398
|
function isOrdered(maybeOrdered: any): boolean;
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* Keyed Iterables have discrete keys tied to each value.
|
|
1403
|
+
*
|
|
1404
|
+
* When iterating `Iterable.Keyed`, each iteration will yield a `[K, V]`
|
|
1405
|
+
* tuple, in other words, `Iterable#entries` is the default iterator for
|
|
1406
|
+
* Keyed Iterables.
|
|
1407
|
+
*/
|
|
1408
|
+
export module Keyed {}
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* Creates an Iterable.Keyed
|
|
1412
|
+
*
|
|
1413
|
+
* Similar to `Iterable()`, however it expects iterable-likes of [K, V]
|
|
1414
|
+
* tuples if not constructed from a Iterable.Keyed or JS Object.
|
|
1415
|
+
*/
|
|
1416
|
+
export function Keyed<K, V>(iter: Iterable.Keyed<K, V>): Iterable.Keyed<K, V>;
|
|
1417
|
+
export function Keyed<K, V>(iter: Iterable<any, /*[K,V]*/any>): Iterable.Keyed<K, V>;
|
|
1418
|
+
export function Keyed<K, V>(array: Array</*[K,V]*/any>): Iterable.Keyed<K, V>;
|
|
1419
|
+
export function Keyed<V>(obj: {[key: string]: V}): Iterable.Keyed<string, V>;
|
|
1420
|
+
export function Keyed<K, V>(iterator: Iterator</*[K,V]*/any>): Iterable.Keyed<K, V>;
|
|
1421
|
+
export function Keyed<K, V>(iterable: /*Iterable<[K,V]>*/Object): Iterable.Keyed<K, V>;
|
|
1422
|
+
|
|
1423
|
+
export interface Keyed<K, V> extends Iterable<K, V> {
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* Returns Seq.Keyed.
|
|
1427
|
+
* @override
|
|
1428
|
+
*/
|
|
1429
|
+
toSeq(): Seq.Keyed<K, V>;
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
// Sequence functions
|
|
1433
|
+
|
|
1434
|
+
/**
|
|
1435
|
+
* Returns a new Iterable.Keyed of the same type where the keys and values
|
|
1436
|
+
* have been flipped.
|
|
1437
|
+
*
|
|
1438
|
+
* Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }
|
|
1439
|
+
*
|
|
1440
|
+
*/
|
|
1441
|
+
flip(): /*this*/Iterable.Keyed<V, K>;
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* Returns a new Iterable.Keyed of the same type with keys passed through
|
|
1445
|
+
* a `mapper` function.
|
|
1446
|
+
*
|
|
1447
|
+
* Seq({ a: 1, b: 2 })
|
|
1448
|
+
* .mapKeys(x => x.toUpperCase())
|
|
1449
|
+
* // Seq { A: 1, B: 2 }
|
|
1450
|
+
*
|
|
1451
|
+
*/
|
|
1452
|
+
mapKeys<M>(
|
|
1453
|
+
mapper: (key?: K, value?: V, iter?: /*this*/Iterable.Keyed<K, V>) => M,
|
|
1454
|
+
context?: any
|
|
1455
|
+
): /*this*/Iterable.Keyed<M, V>;
|
|
1456
|
+
|
|
1457
|
+
/**
|
|
1458
|
+
* Returns a new Iterable.Keyed of the same type with entries
|
|
1459
|
+
* ([key, value] tuples) passed through a `mapper` function.
|
|
1460
|
+
*
|
|
1461
|
+
* Seq({ a: 1, b: 2 })
|
|
1462
|
+
* .mapEntries(([k, v]) => [k.toUpperCase(), v * 2])
|
|
1463
|
+
* // Seq { A: 2, B: 4 }
|
|
1464
|
+
*
|
|
1465
|
+
*/
|
|
1466
|
+
mapEntries<KM, VM>(
|
|
1467
|
+
mapper: (
|
|
1468
|
+
entry?: /*(K, V)*/Array<any>,
|
|
1469
|
+
index?: number,
|
|
1470
|
+
iter?: /*this*/Iterable.Keyed<K, V>
|
|
1471
|
+
) => /*[KM, VM]*/Array<any>,
|
|
1472
|
+
context?: any
|
|
1473
|
+
): /*this*/Iterable.Keyed<KM, VM>;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
/**
|
|
1478
|
+
* Indexed Iterables have incrementing numeric keys. They exhibit
|
|
1479
|
+
* slightly different behavior than `Iterable.Keyed` for some methods in order
|
|
1480
|
+
* to better mirror the behavior of JavaScript's `Array`, and add methods
|
|
1481
|
+
* which do not make sense on non-indexed Iterables such as `indexOf`.
|
|
1482
|
+
*
|
|
1483
|
+
* Unlike JavaScript arrays, `Iterable.Indexed`s are always dense. "Unset"
|
|
1484
|
+
* indices and `undefined` indices are indistinguishable, and all indices from
|
|
1485
|
+
* 0 to `size` are visited when iterated.
|
|
1486
|
+
*
|
|
1487
|
+
* All Iterable.Indexed methods return re-indexed Iterables. In other words,
|
|
1488
|
+
* indices always start at 0 and increment until size. If you wish to
|
|
1489
|
+
* preserve indices, using them as keys, convert to a Iterable.Keyed by
|
|
1490
|
+
* calling `toKeyedSeq`.
|
|
1491
|
+
*/
|
|
1492
|
+
export module Indexed {}
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* Creates a new Iterable.Indexed.
|
|
1496
|
+
*/
|
|
1497
|
+
export function Indexed<T>(iter: Iterable.Indexed<T>): Iterable.Indexed<T>;
|
|
1498
|
+
export function Indexed<T>(iter: Iterable.Set<T>): Iterable.Indexed<T>;
|
|
1499
|
+
export function Indexed<K, V>(iter: Iterable.Keyed<K, V>): Iterable.Indexed</*[K,V]*/any>;
|
|
1500
|
+
export function Indexed<T>(array: Array<T>): Iterable.Indexed<T>;
|
|
1501
|
+
export function Indexed<T>(iterator: Iterator<T>): Iterable.Indexed<T>;
|
|
1502
|
+
export function Indexed<T>(iterable: /*Iterable<T>*/Object): Iterable.Indexed<T>;
|
|
1503
|
+
|
|
1504
|
+
export interface Indexed<T> extends Iterable<number, T> {
|
|
1505
|
+
|
|
1506
|
+
// Reading values
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* Returns the value associated with the provided index, or notSetValue if
|
|
1510
|
+
* the index is beyond the bounds of the Iterable.
|
|
1511
|
+
*
|
|
1512
|
+
* `index` may be a negative number, which indexes back from the end of the
|
|
1513
|
+
* Iterable. `s.get(-1)` gets the last item in the Iterable.
|
|
1514
|
+
*/
|
|
1515
|
+
get(index: number, notSetValue?: T): T;
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
// Conversion to Seq
|
|
1519
|
+
|
|
1520
|
+
/**
|
|
1521
|
+
* Returns Seq.Indexed.
|
|
1522
|
+
* @override
|
|
1523
|
+
*/
|
|
1524
|
+
toSeq(): Seq.Indexed<T>;
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* If this is an iterable of [key, value] entry tuples, it will return a
|
|
1528
|
+
* Seq.Keyed of those entries.
|
|
1529
|
+
*/
|
|
1530
|
+
fromEntrySeq(): Seq.Keyed<any, any>;
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
// Combination
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* Returns an Iterable of the same type with `separator` between each item
|
|
1537
|
+
* in this Iterable.
|
|
1538
|
+
*/
|
|
1539
|
+
interpose(separator: T): /*this*/Iterable.Indexed<T>;
|
|
1540
|
+
|
|
1541
|
+
/**
|
|
1542
|
+
* Returns an Iterable of the same type with the provided `iterables`
|
|
1543
|
+
* interleaved into this iterable.
|
|
1544
|
+
*
|
|
1545
|
+
* The resulting Iterable includes the first item from each, then the
|
|
1546
|
+
* second from each, etc.
|
|
1547
|
+
*
|
|
1548
|
+
* I.Seq.of(1,2,3).interleave(I.Seq.of('A','B','C'))
|
|
1549
|
+
* // Seq [ 1, 'A', 2, 'B', 3, 'C' ]
|
|
1550
|
+
*
|
|
1551
|
+
* The shortest Iterable stops interleave.
|
|
1552
|
+
*
|
|
1553
|
+
* I.Seq.of(1,2,3).interleave(
|
|
1554
|
+
* I.Seq.of('A','B'),
|
|
1555
|
+
* I.Seq.of('X','Y','Z')
|
|
1556
|
+
* )
|
|
1557
|
+
* // Seq [ 1, 'A', 'X', 2, 'B', 'Y' ]
|
|
1558
|
+
*/
|
|
1559
|
+
interleave(...iterables: Array<Iterable<any, T>>): /*this*/Iterable.Indexed<T>;
|
|
1560
|
+
|
|
1561
|
+
/**
|
|
1562
|
+
* Splice returns a new indexed Iterable by replacing a region of this
|
|
1563
|
+
* Iterable with new values. If values are not provided, it only skips the
|
|
1564
|
+
* region to be removed.
|
|
1565
|
+
*
|
|
1566
|
+
* `index` may be a negative number, which indexes back from the end of the
|
|
1567
|
+
* Iterable. `s.splice(-2)` splices after the second to last item.
|
|
1568
|
+
*
|
|
1569
|
+
* Seq(['a','b','c','d']).splice(1, 2, 'q', 'r', 's')
|
|
1570
|
+
* // Seq ['a', 'q', 'r', 's', 'd']
|
|
1571
|
+
*
|
|
1572
|
+
*/
|
|
1573
|
+
splice(
|
|
1574
|
+
index: number,
|
|
1575
|
+
removeNum: number,
|
|
1576
|
+
...values: /*Array<Iterable.Indexed<T> | T>*/any[]
|
|
1577
|
+
): /*this*/Iterable.Indexed<T>;
|
|
1578
|
+
|
|
1579
|
+
/**
|
|
1580
|
+
* Returns an Iterable of the same type "zipped" with the provided
|
|
1581
|
+
* iterables.
|
|
1582
|
+
*
|
|
1583
|
+
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
|
|
1584
|
+
*
|
|
1585
|
+
* var a = Seq.of(1, 2, 3);
|
|
1586
|
+
* var b = Seq.of(4, 5, 6);
|
|
1587
|
+
* var c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
|
|
1588
|
+
*
|
|
1589
|
+
*/
|
|
1590
|
+
zip(...iterables: Array<Iterable<any, any>>): /*this*/Iterable.Indexed<any>;
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* Returns an Iterable of the same type "zipped" with the provided
|
|
1594
|
+
* iterables by using a custom `zipper` function.
|
|
1595
|
+
*
|
|
1596
|
+
* var a = Seq.of(1, 2, 3);
|
|
1597
|
+
* var b = Seq.of(4, 5, 6);
|
|
1598
|
+
* var c = a.zipWith((a, b) => a + b, b); // Seq [ 5, 7, 9 ]
|
|
1599
|
+
*
|
|
1600
|
+
*/
|
|
1601
|
+
zipWith<U, Z>(
|
|
1602
|
+
zipper: (value: T, otherValue: U) => Z,
|
|
1603
|
+
otherIterable: Iterable<any, U>
|
|
1604
|
+
): Iterable.Indexed<Z>;
|
|
1605
|
+
zipWith<U, V, Z>(
|
|
1606
|
+
zipper: (value: T, otherValue: U, thirdValue: V) => Z,
|
|
1607
|
+
otherIterable: Iterable<any, U>,
|
|
1608
|
+
thirdIterable: Iterable<any, V>
|
|
1609
|
+
): Iterable.Indexed<Z>;
|
|
1610
|
+
zipWith<Z>(
|
|
1611
|
+
zipper: (...any: Array<any>) => Z,
|
|
1612
|
+
...iterables: Array<Iterable<any, any>>
|
|
1613
|
+
): Iterable.Indexed<Z>;
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
// Search for value
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* Returns the first index at which a given value can be found in the
|
|
1620
|
+
* Iterable, or -1 if it is not present.
|
|
1621
|
+
*/
|
|
1622
|
+
indexOf(searchValue: T): number;
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* Returns the last index at which a given value can be found in the
|
|
1626
|
+
* Iterable, or -1 if it is not present.
|
|
1627
|
+
*/
|
|
1628
|
+
lastIndexOf(searchValue: T): number;
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* Returns the first index in the Iterable where a value satisfies the
|
|
1632
|
+
* provided predicate function. Otherwise -1 is returned.
|
|
1633
|
+
*/
|
|
1634
|
+
findIndex(
|
|
1635
|
+
predicate: (value?: T, index?: number, iter?: /*this*/Iterable.Indexed<T>) => boolean,
|
|
1636
|
+
context?: any
|
|
1637
|
+
): number;
|
|
1638
|
+
|
|
1639
|
+
/**
|
|
1640
|
+
* Returns the last index in the Iterable where a value satisfies the
|
|
1641
|
+
* provided predicate function. Otherwise -1 is returned.
|
|
1642
|
+
*/
|
|
1643
|
+
findLastIndex(
|
|
1644
|
+
predicate: (value?: T, index?: number, iter?: /*this*/Iterable.Indexed<T>) => boolean,
|
|
1645
|
+
context?: any
|
|
1646
|
+
): number;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
|
|
1650
|
+
/**
|
|
1651
|
+
* Set Iterables only represent values. They have no associated keys or
|
|
1652
|
+
* indices. Duplicate values are possible in Seq.Sets, however the
|
|
1653
|
+
* concrete `Set` does not allow duplicate values.
|
|
1654
|
+
*
|
|
1655
|
+
* Iterable methods on Iterable.Set such as `map` and `forEach` will provide
|
|
1656
|
+
* the value as both the first and second arguments to the provided function.
|
|
1657
|
+
*
|
|
1658
|
+
* var seq = Seq.Set.of('A', 'B', 'C');
|
|
1659
|
+
* assert.equal(seq.every((v, k) => v === k), true);
|
|
1660
|
+
*
|
|
1661
|
+
*/
|
|
1662
|
+
export module Set {}
|
|
1663
|
+
|
|
1664
|
+
/**
|
|
1665
|
+
* Similar to `Iterable()`, but always returns a Iterable.Set.
|
|
1666
|
+
*/
|
|
1667
|
+
export function Set<T>(iter: Iterable.Set<T>): Iterable.Set<T>;
|
|
1668
|
+
export function Set<T>(iter: Iterable.Indexed<T>): Iterable.Set<T>;
|
|
1669
|
+
export function Set<K, V>(iter: Iterable.Keyed<K, V>): Iterable.Set</*[K,V]*/any>;
|
|
1670
|
+
export function Set<T>(array: Array<T>): Iterable.Set<T>;
|
|
1671
|
+
export function Set<T>(iterator: Iterator<T>): Iterable.Set<T>;
|
|
1672
|
+
export function Set<T>(iterable: /*Iterable<T>*/Object): Iterable.Set<T>;
|
|
1673
|
+
|
|
1674
|
+
export interface Set<T> extends Iterable<T, T> {
|
|
1675
|
+
|
|
1676
|
+
/**
|
|
1677
|
+
* Returns Seq.Set.
|
|
1678
|
+
* @override
|
|
1679
|
+
*/
|
|
1680
|
+
toSeq(): Seq.Set<T>;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1346
1683
|
}
|
|
1347
1684
|
|
|
1348
1685
|
/**
|
|
@@ -1351,21 +1688,21 @@ declare module 'immutable' {
|
|
|
1351
1688
|
* The type of Iterable created is based on the input.
|
|
1352
1689
|
*
|
|
1353
1690
|
* * If an `Iterable`, that same `Iterable`.
|
|
1354
|
-
* * If an Array-like, an `
|
|
1355
|
-
* * If an Object with an Iterator, an `
|
|
1356
|
-
* * If an Iterator, an `
|
|
1357
|
-
* * If an Object,
|
|
1691
|
+
* * If an Array-like, an `Iterable.Indexed`.
|
|
1692
|
+
* * If an Object with an Iterator, an `Iterable.Indexed`.
|
|
1693
|
+
* * If an Iterator, an `Iterable.Indexed`.
|
|
1694
|
+
* * If an Object, an `Iterable.Keyed`.
|
|
1358
1695
|
*
|
|
1359
1696
|
* This methods forces the conversion of Objects and Strings to Iterables.
|
|
1360
1697
|
* If you want to ensure that a Iterable of one item is returned, use
|
|
1361
1698
|
* `Seq.of`.
|
|
1362
1699
|
*/
|
|
1363
1700
|
export function Iterable<K, V>(iterable: Iterable<K, V>): Iterable<K, V>;
|
|
1364
|
-
export function Iterable<T>(array: Array<T>):
|
|
1365
|
-
export function Iterable<V>(obj: {[key: string]: V}):
|
|
1366
|
-
export function Iterable<T>(iterator: Iterator<T>):
|
|
1367
|
-
export function Iterable<T>(iterable: /*ES6Iterable<T>*/Object):
|
|
1368
|
-
export function Iterable<V>(value: V):
|
|
1701
|
+
export function Iterable<T>(array: Array<T>): Iterable.Indexed<T>;
|
|
1702
|
+
export function Iterable<V>(obj: {[key: string]: V}): Iterable.Keyed<string, V>;
|
|
1703
|
+
export function Iterable<T>(iterator: Iterator<T>): Iterable.Indexed<T>;
|
|
1704
|
+
export function Iterable<T>(iterable: /*ES6Iterable<T>*/Object): Iterable.Indexed<T>;
|
|
1705
|
+
export function Iterable<V>(value: V): Iterable.Indexed<V>;
|
|
1369
1706
|
|
|
1370
1707
|
export interface Iterable<K, V> {
|
|
1371
1708
|
|
|
@@ -1415,12 +1752,12 @@ declare module 'immutable' {
|
|
|
1415
1752
|
get(key: K, notSetValue?: V): V;
|
|
1416
1753
|
|
|
1417
1754
|
/**
|
|
1418
|
-
* True if a key exists within this `Iterable
|
|
1755
|
+
* True if a key exists within this `Iterable`, using `Immutable.is` to determine equality
|
|
1419
1756
|
*/
|
|
1420
1757
|
has(key: K): boolean;
|
|
1421
1758
|
|
|
1422
1759
|
/**
|
|
1423
|
-
* True if a value exists within this `Iterable
|
|
1760
|
+
* True if a value exists within this `Iterable`, using `Immutable.is` to determine equality
|
|
1424
1761
|
* @alias contains
|
|
1425
1762
|
*/
|
|
1426
1763
|
includes(value: V): boolean;
|
|
@@ -1459,8 +1796,8 @@ declare module 'immutable' {
|
|
|
1459
1796
|
/**
|
|
1460
1797
|
* Deeply converts this Iterable to equivalent JS.
|
|
1461
1798
|
*
|
|
1462
|
-
* `
|
|
1463
|
-
* `
|
|
1799
|
+
* `Iterable.Indexeds`, and `Iterable.Sets` become Arrays, while
|
|
1800
|
+
* `Iterable.Keyeds` become Objects.
|
|
1464
1801
|
*
|
|
1465
1802
|
* @alias toJSON
|
|
1466
1803
|
*/
|
|
@@ -1495,7 +1832,7 @@ declare module 'immutable' {
|
|
|
1495
1832
|
* Note: This is equivalent to `OrderedMap(this.toKeyedSeq())`, but
|
|
1496
1833
|
* provided for convenience and to allow for chained expressions.
|
|
1497
1834
|
*/
|
|
1498
|
-
toOrderedMap():
|
|
1835
|
+
toOrderedMap(): OrderedMap<K, V>;
|
|
1499
1836
|
|
|
1500
1837
|
/**
|
|
1501
1838
|
* Converts this Iterable to a Set, discarding keys. Throws if values
|
|
@@ -1513,7 +1850,7 @@ declare module 'immutable' {
|
|
|
1513
1850
|
* Note: This is equivalent to `OrderedSet(this.valueSeq())`, but provided
|
|
1514
1851
|
* for convenience and to allow for chained expressions.
|
|
1515
1852
|
*/
|
|
1516
|
-
toOrderedSet():
|
|
1853
|
+
toOrderedSet(): OrderedSet<V>;
|
|
1517
1854
|
|
|
1518
1855
|
/**
|
|
1519
1856
|
* Converts this Iterable to a List, discarding keys.
|
|
@@ -1542,10 +1879,10 @@ declare module 'immutable' {
|
|
|
1542
1879
|
toSeq(): Seq<K, V>;
|
|
1543
1880
|
|
|
1544
1881
|
/**
|
|
1545
|
-
* Returns a
|
|
1882
|
+
* Returns a Seq.Keyed from this Iterable where indices are treated as keys.
|
|
1546
1883
|
*
|
|
1547
1884
|
* This is useful if you want to operate on an
|
|
1548
|
-
*
|
|
1885
|
+
* Iterable.Indexed and preserve the [index, value] pairs.
|
|
1549
1886
|
*
|
|
1550
1887
|
* The returned Seq will have identical iteration order as
|
|
1551
1888
|
* this Iterable.
|
|
@@ -1558,33 +1895,39 @@ declare module 'immutable' {
|
|
|
1558
1895
|
* keyedSeq.filter(v => v === 'B').toString() // Seq { 1: 'B' }
|
|
1559
1896
|
*
|
|
1560
1897
|
*/
|
|
1561
|
-
toKeyedSeq():
|
|
1898
|
+
toKeyedSeq(): Seq.Keyed<K, V>;
|
|
1562
1899
|
|
|
1563
1900
|
/**
|
|
1564
|
-
* Returns an
|
|
1901
|
+
* Returns an Seq.Indexed of the values of this Iterable, discarding keys.
|
|
1565
1902
|
*/
|
|
1566
|
-
toIndexedSeq():
|
|
1903
|
+
toIndexedSeq(): Seq.Indexed<V>;
|
|
1567
1904
|
|
|
1568
1905
|
/**
|
|
1569
|
-
* Returns a
|
|
1906
|
+
* Returns a Seq.Set of the values of this Iterable, discarding keys.
|
|
1570
1907
|
*/
|
|
1571
|
-
toSetSeq():
|
|
1908
|
+
toSetSeq(): Seq.Set<V>;
|
|
1572
1909
|
|
|
1573
1910
|
|
|
1574
1911
|
// Iterators
|
|
1575
1912
|
|
|
1576
1913
|
/**
|
|
1577
1914
|
* An iterator of this `Iterable`'s keys.
|
|
1915
|
+
*
|
|
1916
|
+
* Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `keySeq` instead, if this is what you want.
|
|
1578
1917
|
*/
|
|
1579
1918
|
keys(): Iterator<K>;
|
|
1580
1919
|
|
|
1581
1920
|
/**
|
|
1582
1921
|
* An iterator of this `Iterable`'s values.
|
|
1922
|
+
*
|
|
1923
|
+
* Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `valueSeq` instead, if this is what you want.
|
|
1583
1924
|
*/
|
|
1584
1925
|
values(): Iterator<V>;
|
|
1585
1926
|
|
|
1586
1927
|
/**
|
|
1587
1928
|
* An iterator of this `Iterable`'s entries as `[key, value]` tuples.
|
|
1929
|
+
*
|
|
1930
|
+
* Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `entrySeq` instead, if this is what you want.
|
|
1588
1931
|
*/
|
|
1589
1932
|
entries(): Iterator</*[K, V]*/Array<any>>;
|
|
1590
1933
|
|
|
@@ -1592,20 +1935,20 @@ declare module 'immutable' {
|
|
|
1592
1935
|
// Iterables (Seq)
|
|
1593
1936
|
|
|
1594
1937
|
/**
|
|
1595
|
-
* Returns a new
|
|
1938
|
+
* Returns a new Seq.Indexed of the keys of this Iterable,
|
|
1596
1939
|
* discarding values.
|
|
1597
1940
|
*/
|
|
1598
|
-
keySeq():
|
|
1941
|
+
keySeq(): Seq.Indexed<K>;
|
|
1599
1942
|
|
|
1600
1943
|
/**
|
|
1601
|
-
* Returns an
|
|
1944
|
+
* Returns an Seq.Indexed of the values of this Iterable, discarding keys.
|
|
1602
1945
|
*/
|
|
1603
|
-
valueSeq():
|
|
1946
|
+
valueSeq(): Seq.Indexed<V>;
|
|
1604
1947
|
|
|
1605
1948
|
/**
|
|
1606
|
-
* Returns a new
|
|
1949
|
+
* Returns a new Seq.Indexed of [key, value] tuples.
|
|
1607
1950
|
*/
|
|
1608
|
-
entrySeq():
|
|
1951
|
+
entrySeq(): Seq.Indexed</*(K, V)*/Array<any>>;
|
|
1609
1952
|
|
|
1610
1953
|
|
|
1611
1954
|
// Sequence algorithms
|
|
@@ -1686,7 +2029,7 @@ declare module 'immutable' {
|
|
|
1686
2029
|
): /*this*/Iterable<K, V>;
|
|
1687
2030
|
|
|
1688
2031
|
/**
|
|
1689
|
-
* Returns a `
|
|
2032
|
+
* Returns a `Iterable.Keyed` of `Iterable.Keyeds`, grouped by the return
|
|
1690
2033
|
* value of the `grouper` function.
|
|
1691
2034
|
*
|
|
1692
2035
|
* Note: This is always an eager operation.
|
|
@@ -1694,7 +2037,7 @@ declare module 'immutable' {
|
|
|
1694
2037
|
groupBy<G>(
|
|
1695
2038
|
grouper: (value?: V, key?: K, iter?: /*this*/Iterable<K, V>) => G,
|
|
1696
2039
|
context?: any
|
|
1697
|
-
): /*Map*/
|
|
2040
|
+
): /*Map*/Seq.Keyed<G, /*this*/Iterable<K, V>>;
|
|
1698
2041
|
|
|
1699
2042
|
|
|
1700
2043
|
// Side effects
|
|
@@ -1942,7 +2285,7 @@ declare module 'immutable' {
|
|
|
1942
2285
|
): number;
|
|
1943
2286
|
|
|
1944
2287
|
/**
|
|
1945
|
-
* Returns a `
|
|
2288
|
+
* Returns a `Seq.Keyed` of counts, grouped by the return value of
|
|
1946
2289
|
* the `grouper` function.
|
|
1947
2290
|
*
|
|
1948
2291
|
* Note: This is not a lazy operation.
|
|
@@ -1956,7 +2299,7 @@ declare module 'immutable' {
|
|
|
1956
2299
|
// Search for value
|
|
1957
2300
|
|
|
1958
2301
|
/**
|
|
1959
|
-
* Returns the value for which the `predicate` returns true.
|
|
2302
|
+
* Returns the first value for which the `predicate` returns true.
|
|
1960
2303
|
*/
|
|
1961
2304
|
find(
|
|
1962
2305
|
predicate: (value?: V, key?: K, iter?: /*this*/Iterable<K, V>) => boolean,
|
|
@@ -1976,7 +2319,7 @@ declare module 'immutable' {
|
|
|
1976
2319
|
): V;
|
|
1977
2320
|
|
|
1978
2321
|
/**
|
|
1979
|
-
* Returns the [key, value] entry for which the `predicate` returns true.
|
|
2322
|
+
* Returns the first [key, value] entry for which the `predicate` returns true.
|
|
1980
2323
|
*/
|
|
1981
2324
|
findEntry(
|
|
1982
2325
|
predicate: (value?: V, key?: K, iter?: /*this*/Iterable<K, V>) => boolean,
|
|
@@ -1996,6 +2339,34 @@ declare module 'immutable' {
|
|
|
1996
2339
|
notSetValue?: V
|
|
1997
2340
|
): /*[K, V]*/Array<any>;
|
|
1998
2341
|
|
|
2342
|
+
/**
|
|
2343
|
+
* Returns the key for which the `predicate` returns true.
|
|
2344
|
+
*/
|
|
2345
|
+
findKey(
|
|
2346
|
+
predicate: (value?: V, key?: K, iter?: /*this*/Iterable.Keyed<K, V>) => boolean,
|
|
2347
|
+
context?: any
|
|
2348
|
+
): K;
|
|
2349
|
+
|
|
2350
|
+
/**
|
|
2351
|
+
* Returns the last key for which the `predicate` returns true.
|
|
2352
|
+
*
|
|
2353
|
+
* Note: `predicate` will be called for each entry in reverse.
|
|
2354
|
+
*/
|
|
2355
|
+
findLastKey(
|
|
2356
|
+
predicate: (value?: V, key?: K, iter?: /*this*/Iterable.Keyed<K, V>) => boolean,
|
|
2357
|
+
context?: any
|
|
2358
|
+
): K;
|
|
2359
|
+
|
|
2360
|
+
/**
|
|
2361
|
+
* Returns the key associated with the search value, or undefined.
|
|
2362
|
+
*/
|
|
2363
|
+
keyOf(searchValue: V): K;
|
|
2364
|
+
|
|
2365
|
+
/**
|
|
2366
|
+
* Returns the last key associated with the search value, or undefined.
|
|
2367
|
+
*/
|
|
2368
|
+
lastKeyOf(searchValue: V): K;
|
|
2369
|
+
|
|
1999
2370
|
/**
|
|
2000
2371
|
* Returns the maximum value in this collection. If any values are
|
|
2001
2372
|
* comparatively equivalent, the first one found will be returned.
|
|
@@ -2083,328 +2454,63 @@ declare module 'immutable' {
|
|
|
2083
2454
|
|
|
2084
2455
|
|
|
2085
2456
|
/**
|
|
2086
|
-
*
|
|
2087
|
-
*
|
|
2088
|
-
* When iterating `KeyedIterable`, each iteration will yield a `[K, V]` tuple,
|
|
2089
|
-
* in other words, `Iterable#entries` is the default iterator for Keyed
|
|
2090
|
-
* Iterables.
|
|
2091
|
-
*/
|
|
2092
|
-
export module KeyedIterable {}
|
|
2093
|
-
|
|
2094
|
-
/**
|
|
2095
|
-
* Creates a KeyedIterable
|
|
2457
|
+
* Collection is the abstract base class for concrete data structures. It
|
|
2458
|
+
* cannot be constructed directly.
|
|
2096
2459
|
*
|
|
2097
|
-
*
|
|
2098
|
-
*
|
|
2460
|
+
* Implementations should extend one of the subclasses, `Collection.Keyed`,
|
|
2461
|
+
* `Collection.Indexed`, or `Collection.Set`.
|
|
2099
2462
|
*/
|
|
2100
|
-
export
|
|
2101
|
-
export function KeyedIterable<K, V>(iter: Iterable<any, /*[K,V]*/any>): KeyedIterable<K, V>;
|
|
2102
|
-
export function KeyedIterable<K, V>(array: Array</*[K,V]*/any>): KeyedIterable<K, V>;
|
|
2103
|
-
export function KeyedIterable<V>(obj: {[key: string]: V}): KeyedIterable<string, V>;
|
|
2104
|
-
export function KeyedIterable<K, V>(iterator: Iterator</*[K,V]*/any>): KeyedIterable<K, V>;
|
|
2105
|
-
export function KeyedIterable<K, V>(iterable: /*Iterable<[K,V]>*/Object): KeyedIterable<K, V>;
|
|
2463
|
+
export module Collection {
|
|
2106
2464
|
|
|
2107
|
-
export interface KeyedIterable<K, V> extends Iterable<K, V> {
|
|
2108
2465
|
|
|
2109
2466
|
/**
|
|
2110
|
-
*
|
|
2111
|
-
* @override
|
|
2467
|
+
* `Collection` which represents key-value pairs.
|
|
2112
2468
|
*/
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
// Sequence functions
|
|
2469
|
+
export module Keyed {}
|
|
2117
2470
|
|
|
2118
|
-
|
|
2119
|
-
* Returns a new KeyedIterable of the same type where the keys and values
|
|
2120
|
-
* have been flipped.
|
|
2121
|
-
*
|
|
2122
|
-
* Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }
|
|
2123
|
-
*
|
|
2124
|
-
*/
|
|
2125
|
-
flip(): /*this*/KeyedIterable<V, K>;
|
|
2471
|
+
export interface Keyed<K, V> extends Collection<K, V>, Iterable.Keyed<K, V> {
|
|
2126
2472
|
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
* // Seq { A: 1, B: 2 }
|
|
2134
|
-
*
|
|
2135
|
-
*/
|
|
2136
|
-
mapKeys<M>(
|
|
2137
|
-
mapper: (key?: K, value?: V, iter?: /*this*/KeyedIterable<K, V>) => M,
|
|
2138
|
-
context?: any
|
|
2139
|
-
): /*this*/KeyedIterable<M, V>;
|
|
2140
|
-
|
|
2141
|
-
/**
|
|
2142
|
-
* Returns a new KeyedIterable of the same type with entries
|
|
2143
|
-
* ([key, value] tuples) passed through a `mapper` function.
|
|
2144
|
-
*
|
|
2145
|
-
* Seq({ a: 1, b: 2 })
|
|
2146
|
-
* .mapEntries(([k, v]) => [k.toUpperCase(), v * 2])
|
|
2147
|
-
* // Seq { A: 2, B: 4 }
|
|
2148
|
-
*
|
|
2149
|
-
*/
|
|
2150
|
-
mapEntries<KM, VM>(
|
|
2151
|
-
mapper: (
|
|
2152
|
-
entry?: /*(K, V)*/Array<any>,
|
|
2153
|
-
index?: number,
|
|
2154
|
-
iter?: /*this*/KeyedIterable<K, V>
|
|
2155
|
-
) => /*[KM, VM]*/Array<any>,
|
|
2156
|
-
context?: any
|
|
2157
|
-
): /*this*/KeyedIterable<KM, VM>;
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
// Search for value
|
|
2161
|
-
|
|
2162
|
-
/**
|
|
2163
|
-
* Returns the key associated with the search value, or undefined.
|
|
2164
|
-
*/
|
|
2165
|
-
keyOf(searchValue: V): K;
|
|
2166
|
-
|
|
2167
|
-
/**
|
|
2168
|
-
* Returns the last key associated with the search value, or undefined.
|
|
2169
|
-
*/
|
|
2170
|
-
lastKeyOf(searchValue: V): K;
|
|
2171
|
-
|
|
2172
|
-
/**
|
|
2173
|
-
* Returns the key for which the `predicate` returns true.
|
|
2174
|
-
*/
|
|
2175
|
-
findKey(
|
|
2176
|
-
predicate: (value?: V, key?: K, iter?: /*this*/KeyedIterable<K, V>) => boolean,
|
|
2177
|
-
context?: any
|
|
2178
|
-
): K;
|
|
2179
|
-
|
|
2180
|
-
/**
|
|
2181
|
-
* Returns the last key for which the `predicate` returns true.
|
|
2182
|
-
*
|
|
2183
|
-
* Note: `predicate` will be called for each entry in reverse.
|
|
2184
|
-
*/
|
|
2185
|
-
findLastKey(
|
|
2186
|
-
predicate: (value?: V, key?: K, iter?: /*this*/KeyedIterable<K, V>) => boolean,
|
|
2187
|
-
context?: any
|
|
2188
|
-
): K;
|
|
2189
|
-
}
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
/**
|
|
2193
|
-
* Indexed Iterables have incrementing numeric keys. They exhibit
|
|
2194
|
-
* slightly different behavior than `KeyedIterable` for some methods in order
|
|
2195
|
-
* to better mirror the behavior of JavaScript's `Array`, and add methods
|
|
2196
|
-
* which do not make sense on non-indexed Iterables such as `indexOf`.
|
|
2197
|
-
*
|
|
2198
|
-
* Unlike JavaScript arrays, `IndexedIterable`s are always dense. "Unset"
|
|
2199
|
-
* indices and `undefined` indices are indistinguishable, and all indices from
|
|
2200
|
-
* 0 to `size` are visited when iterated.
|
|
2201
|
-
*
|
|
2202
|
-
* All IndexedIterable methods return re-indexed Iterables. In other words,
|
|
2203
|
-
* indices always start at 0 and increment until size. If you wish to
|
|
2204
|
-
* preserve indices, using them as keys, convert to a KeyedIterable by calling
|
|
2205
|
-
* `toKeyedSeq`.
|
|
2206
|
-
*/
|
|
2207
|
-
export module IndexedIterable {}
|
|
2208
|
-
|
|
2209
|
-
/**
|
|
2210
|
-
* Creates a new IndexedIterable.
|
|
2211
|
-
*/
|
|
2212
|
-
export function IndexedIterable<T>(iter: IndexedIterable<T>): IndexedIterable<T>;
|
|
2213
|
-
export function IndexedIterable<T>(iter: SetIterable<T>): IndexedIterable<T>;
|
|
2214
|
-
export function IndexedIterable<K, V>(iter: KeyedIterable<K, V>): IndexedIterable</*[K,V]*/any>;
|
|
2215
|
-
export function IndexedIterable<T>(array: Array<T>): IndexedIterable<T>;
|
|
2216
|
-
export function IndexedIterable<T>(iterator: Iterator<T>): IndexedIterable<T>;
|
|
2217
|
-
export function IndexedIterable<T>(iterable: /*Iterable<T>*/Object): IndexedIterable<T>;
|
|
2218
|
-
|
|
2219
|
-
export interface IndexedIterable<T> extends Iterable<number, T> {
|
|
2220
|
-
|
|
2221
|
-
// Reading values
|
|
2222
|
-
|
|
2223
|
-
/**
|
|
2224
|
-
* Returns the value associated with the provided index, or notSetValue if
|
|
2225
|
-
* the index is beyond the bounds of the Iterable.
|
|
2226
|
-
*
|
|
2227
|
-
* `index` may be a negative number, which indexes back from the end of the
|
|
2228
|
-
* Iterable. `s.get(-1)` gets the last item in the Iterable.
|
|
2229
|
-
*/
|
|
2230
|
-
get(index: number, notSetValue?: T): T;
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
// Conversion to Seq
|
|
2473
|
+
/**
|
|
2474
|
+
* Returns Seq.Keyed.
|
|
2475
|
+
* @override
|
|
2476
|
+
*/
|
|
2477
|
+
toSeq(): Seq.Keyed<K, V>;
|
|
2478
|
+
}
|
|
2234
2479
|
|
|
2235
|
-
/**
|
|
2236
|
-
* Returns IndexedSeq.
|
|
2237
|
-
* @override
|
|
2238
|
-
*/
|
|
2239
|
-
toSeq(): IndexedSeq<T>;
|
|
2240
2480
|
|
|
2241
2481
|
/**
|
|
2242
|
-
*
|
|
2243
|
-
* KeyedSeq of those entries.
|
|
2482
|
+
* `Collection` which represents ordered indexed values.
|
|
2244
2483
|
*/
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
// Combination
|
|
2484
|
+
export module Indexed {}
|
|
2249
2485
|
|
|
2250
|
-
|
|
2251
|
-
* Returns an Iterable of the same type with `separator` between each item
|
|
2252
|
-
* in this Iterable.
|
|
2253
|
-
*/
|
|
2254
|
-
interpose(separator: T): /*this*/IndexedIterable<T>;
|
|
2486
|
+
export interface Indexed<T> extends Collection<number, T>, Iterable.Indexed<T> {
|
|
2255
2487
|
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
*
|
|
2263
|
-
* I.Seq.of(1,2,3).interleave(I.Seq.of('A','B','C'))
|
|
2264
|
-
* // Seq [ 1, 'A', 2, 'B', 3, 'C' ]
|
|
2265
|
-
*
|
|
2266
|
-
* The shortest Iterable stops interleave.
|
|
2267
|
-
*
|
|
2268
|
-
* I.Seq.of(1,2,3).interleave(
|
|
2269
|
-
* I.Seq.of('A','B'),
|
|
2270
|
-
* I.Seq.of('X','Y','Z')
|
|
2271
|
-
* )
|
|
2272
|
-
* // Seq [ 1, 'A', 'X', 2, 'B', 'Y' ]
|
|
2273
|
-
*/
|
|
2274
|
-
interleave(...iterables: Array<Iterable<any, T>>): /*this*/IndexedIterable<T>;
|
|
2275
|
-
|
|
2276
|
-
/**
|
|
2277
|
-
* Splice returns a new indexed Iterable by replacing a region of this
|
|
2278
|
-
* Iterable with new values. If values are not provided, it only skips the
|
|
2279
|
-
* region to be removed.
|
|
2280
|
-
*
|
|
2281
|
-
* `index` may be a negative number, which indexes back from the end of the
|
|
2282
|
-
* Iterable. `s.splice(-2)` splices after the second to last item.
|
|
2283
|
-
*
|
|
2284
|
-
* Seq(['a','b','c','d']).splice(1, 2, 'q', 'r', 's')
|
|
2285
|
-
* // Seq ['a', 'q', 'r', 's', 'd']
|
|
2286
|
-
*
|
|
2287
|
-
*/
|
|
2288
|
-
splice(
|
|
2289
|
-
index: number,
|
|
2290
|
-
removeNum: number,
|
|
2291
|
-
...values: /*Array<IndexedIterable<T> | T>*/any[]
|
|
2292
|
-
): /*this*/IndexedIterable<T>;
|
|
2488
|
+
/**
|
|
2489
|
+
* Returns Seq.Indexed.
|
|
2490
|
+
* @override
|
|
2491
|
+
*/
|
|
2492
|
+
toSeq(): Seq.Indexed<T>;
|
|
2493
|
+
}
|
|
2293
2494
|
|
|
2294
|
-
/**
|
|
2295
|
-
* Returns an Iterable of the same type "zipped" with the provided
|
|
2296
|
-
* iterables.
|
|
2297
|
-
*
|
|
2298
|
-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
|
|
2299
|
-
*
|
|
2300
|
-
* var a = Seq.of(1, 2, 3);
|
|
2301
|
-
* var b = Seq.of(4, 5, 6);
|
|
2302
|
-
* var c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
|
|
2303
|
-
*
|
|
2304
|
-
*/
|
|
2305
|
-
zip(...iterables: Array<Iterable<any, any>>): /*this*/IndexedIterable<any>;
|
|
2306
2495
|
|
|
2307
2496
|
/**
|
|
2308
|
-
*
|
|
2309
|
-
* iterables by using a custom `zipper` function.
|
|
2497
|
+
* `Collection` which represents values, unassociated with keys or indices.
|
|
2310
2498
|
*
|
|
2311
|
-
*
|
|
2312
|
-
* var b = Seq.of(4, 5, 6);
|
|
2313
|
-
* var c = a.zipWith((a, b) => a + b, b); // Seq [ 5, 7, 9 ]
|
|
2314
|
-
*
|
|
2315
|
-
*/
|
|
2316
|
-
zipWith<U, Z>(
|
|
2317
|
-
zipper: (value: T, otherValue: U) => Z,
|
|
2318
|
-
otherIterable: Iterable<any, U>
|
|
2319
|
-
): IndexedIterable<Z>;
|
|
2320
|
-
zipWith<U, V, Z>(
|
|
2321
|
-
zipper: (value: T, otherValue: U, thirdValue: V) => Z,
|
|
2322
|
-
otherIterable: Iterable<any, U>,
|
|
2323
|
-
thirdIterable: Iterable<any, V>
|
|
2324
|
-
): IndexedIterable<Z>;
|
|
2325
|
-
zipWith<Z>(
|
|
2326
|
-
zipper: (...any: Array<any>) => Z,
|
|
2327
|
-
...iterables: Array<Iterable<any, any>>
|
|
2328
|
-
): IndexedIterable<Z>;
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
// Search for value
|
|
2332
|
-
|
|
2333
|
-
/**
|
|
2334
|
-
* Returns the first index at which a given value can be found in the
|
|
2335
|
-
* Iterable, or -1 if it is not present.
|
|
2499
|
+
* `Collection.Set` implementations should guarantee value uniqueness.
|
|
2336
2500
|
*/
|
|
2337
|
-
|
|
2501
|
+
export module Set {}
|
|
2338
2502
|
|
|
2339
|
-
|
|
2340
|
-
* Returns the last index at which a given value can be found in the
|
|
2341
|
-
* Iterable, or -1 if it is not present.
|
|
2342
|
-
*/
|
|
2343
|
-
lastIndexOf(searchValue: T): number;
|
|
2503
|
+
export interface Set<T> extends Collection<T, T>, Iterable.Set<T> {
|
|
2344
2504
|
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
context?: any
|
|
2352
|
-
): number;
|
|
2353
|
-
|
|
2354
|
-
/**
|
|
2355
|
-
* Returns the last index in the Iterable where a value satisfies the
|
|
2356
|
-
* provided predicate function. Otherwise -1 is returned.
|
|
2357
|
-
*/
|
|
2358
|
-
findLastIndex(
|
|
2359
|
-
predicate: (value?: T, index?: number, iter?: /*this*/IndexedIterable<T>) => boolean,
|
|
2360
|
-
context?: any
|
|
2361
|
-
): number;
|
|
2362
|
-
}
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
/**
|
|
2366
|
-
* Set Iterables only represent values. They have no associated keys or
|
|
2367
|
-
* indices. Duplicate values are possible in SetSeqs, however the
|
|
2368
|
-
* concrete `Set` does not allow duplicate values.
|
|
2369
|
-
*
|
|
2370
|
-
* Iterable methods on SetIterable such as `map` and `forEach` will provide
|
|
2371
|
-
* the value as both the first and second arguments to the provided function.
|
|
2372
|
-
*
|
|
2373
|
-
* var seq = SetSeq.of('A', 'B', 'C');
|
|
2374
|
-
* assert.equal(seq.every((v, k) => v === k), true);
|
|
2375
|
-
*
|
|
2376
|
-
*/
|
|
2377
|
-
export module SetIterable {}
|
|
2378
|
-
|
|
2379
|
-
/**
|
|
2380
|
-
* Similar to `Iterable()`, but always returns a SetIterable.
|
|
2381
|
-
*/
|
|
2382
|
-
export function SetIterable<T>(iter: SetIterable<T>): SetIterable<T>;
|
|
2383
|
-
export function SetIterable<T>(iter: IndexedIterable<T>): SetIterable<T>;
|
|
2384
|
-
export function SetIterable<K, V>(iter: KeyedIterable<K, V>): SetIterable</*[K,V]*/any>;
|
|
2385
|
-
export function SetIterable<T>(array: Array<T>): SetIterable<T>;
|
|
2386
|
-
export function SetIterable<T>(iterator: Iterator<T>): SetIterable<T>;
|
|
2387
|
-
export function SetIterable<T>(iterable: /*Iterable<T>*/Object): SetIterable<T>;
|
|
2388
|
-
|
|
2389
|
-
export interface SetIterable<T> extends Iterable<T, T> {
|
|
2505
|
+
/**
|
|
2506
|
+
* Returns Seq.Set.
|
|
2507
|
+
* @override
|
|
2508
|
+
*/
|
|
2509
|
+
toSeq(): Seq.Set<T>;
|
|
2510
|
+
}
|
|
2390
2511
|
|
|
2391
|
-
/**
|
|
2392
|
-
* Returns SetSeq.
|
|
2393
|
-
* @override
|
|
2394
|
-
*/
|
|
2395
|
-
toSeq(): SetSeq<T>;
|
|
2396
2512
|
}
|
|
2397
2513
|
|
|
2398
|
-
|
|
2399
|
-
/**
|
|
2400
|
-
* Collection is the abstract base class for concrete data structures. It
|
|
2401
|
-
* cannot be constructed directly.
|
|
2402
|
-
*
|
|
2403
|
-
* Implementations should extend one of the subclasses, `KeyedCollection`,
|
|
2404
|
-
* `IndexedCollection`, or `SetCollection`.
|
|
2405
|
-
*/
|
|
2406
|
-
export module Collection {}
|
|
2407
|
-
|
|
2408
2514
|
export interface Collection<K, V> extends Iterable<K, V> {
|
|
2409
2515
|
|
|
2410
2516
|
/**
|
|
@@ -2414,53 +2520,6 @@ declare module 'immutable' {
|
|
|
2414
2520
|
}
|
|
2415
2521
|
|
|
2416
2522
|
|
|
2417
|
-
/**
|
|
2418
|
-
* `Collection` which represents key-value pairs.
|
|
2419
|
-
*/
|
|
2420
|
-
export module KeyedCollection {}
|
|
2421
|
-
|
|
2422
|
-
export interface KeyedCollection<K, V> extends Collection<K, V>, KeyedIterable<K, V> {
|
|
2423
|
-
|
|
2424
|
-
/**
|
|
2425
|
-
* Returns KeyedSeq.
|
|
2426
|
-
* @override
|
|
2427
|
-
*/
|
|
2428
|
-
toSeq(): KeyedSeq<K, V>;
|
|
2429
|
-
}
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
/**
|
|
2433
|
-
* `Collection` which represents ordered indexed values.
|
|
2434
|
-
*/
|
|
2435
|
-
export module IndexedCollection {}
|
|
2436
|
-
|
|
2437
|
-
export interface IndexedCollection<T> extends Collection<number, T>, IndexedIterable<T> {
|
|
2438
|
-
|
|
2439
|
-
/**
|
|
2440
|
-
* Returns IndexedSeq.
|
|
2441
|
-
* @override
|
|
2442
|
-
*/
|
|
2443
|
-
toSeq(): IndexedSeq<T>;
|
|
2444
|
-
}
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
/**
|
|
2448
|
-
* `Collection` which represents values, unassociated with keys or indices.
|
|
2449
|
-
*
|
|
2450
|
-
* `SetCollection` implementations should guarantee value uniqueness.
|
|
2451
|
-
*/
|
|
2452
|
-
export module SetCollection {}
|
|
2453
|
-
|
|
2454
|
-
export interface SetCollection<T> extends Collection<T, T>, SetIterable<T> {
|
|
2455
|
-
|
|
2456
|
-
/**
|
|
2457
|
-
* Returns SetSeq.
|
|
2458
|
-
* @override
|
|
2459
|
-
*/
|
|
2460
|
-
toSeq(): SetSeq<T>;
|
|
2461
|
-
}
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
2523
|
/**
|
|
2465
2524
|
* ES6 Iterator.
|
|
2466
2525
|
*
|
|
@@ -2474,3 +2533,7 @@ declare module 'immutable' {
|
|
|
2474
2533
|
}
|
|
2475
2534
|
|
|
2476
2535
|
}
|
|
2536
|
+
|
|
2537
|
+
declare module "immutable" {
|
|
2538
|
+
export = Immutable
|
|
2539
|
+
}
|