immutable 3.7.2 → 3.7.6

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.
@@ -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 'immutable' {
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 convertions from
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:
@@ -61,6 +61,25 @@ declare module 'immutable' {
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 if they where explicitly defined.
124
+ * indices from 0 to size, regardless of if 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: IndexedIterable<T>): List<T>;
126
- export function List<T>(iter: SetIterable<T>): List<T>;
127
- export function List<K, V>(iter: KeyedIterable<K, V>): List</*[K,V]*/any>;
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 IndexedCollection<T> {
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 indicies above `index` are shifted down by 1 to
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: IndexedIterable<T>[]): List<T>;
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: IndexedIterable<T>[]
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: IndexedIterable<T>[]): List<T>;
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: IndexedIterable<T>[]
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: IndexedIterable<T>[]
343
+ ...iterables: Iterable.Indexed<T>[]
317
344
  ): List<T>;
318
345
  mergeIn(
319
346
  keyPath: Array<any>,
320
- ...iterables: IndexedIterable<T>[]
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: IndexedIterable<T>[]
359
+ ...iterables: Iterable.Indexed<T>[]
333
360
  ): List<T>;
334
361
  mergeDeepIn(
335
362
  keyPath: Array<any>,
336
- ...iterables: IndexedIterable<T>[]
363
+ ...iterables: Iterable.Indexed<T>[]
337
364
  ): List<T>;
338
365
  mergeDeepIn(
339
366
  keyPath: Array<any>,
@@ -344,6 +371,10 @@ declare module 'immutable' {
344
371
  // Transient changes
345
372
 
346
373
  /**
374
+ * Note: Not all methods can be used on a mutable collection or within
375
+ * `withMutations`! Only `set`, `push`, `pop`, `shift`, `unshift` and
376
+ * `merge` may be used mutatively.
377
+ *
347
378
  * @see `Map#withMutations`
348
379
  */
349
380
  withMutations(mutator: (mutable: List<T>) => any): List<T>;
@@ -361,7 +392,7 @@ declare module 'immutable' {
361
392
 
362
393
 
363
394
  /**
364
- * Immutable Map is an unordered KeyedIterable of (key, value) pairs with
395
+ * Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with
365
396
  * `O(log32 N)` gets and `O(log32 N)` persistent sets.
366
397
  *
367
398
  * Iteration order of a Map is undefined, however is stable. Multiple
@@ -394,22 +425,40 @@ declare module 'immutable' {
394
425
  /**
395
426
  * Creates a new Immutable Map.
396
427
  *
397
- * Created with the same key value pairs as the provided KeyedIterable or
428
+ * Created with the same key value pairs as the provided Iterable.Keyed or
398
429
  * JavaScript Object or expects an Iterable of [K, V] tuple entries.
399
430
  *
400
431
  * var newMap = Map({key: "value"});
401
432
  * var newMap = Map([["key", "value"]]);
402
433
  *
434
+ * Keep in mind, when using JS objects to construct Immutable Maps, that
435
+ * JavaScript Object properties are always strings, even if written in a
436
+ * quote-less shorthand, while Immutable Maps accept keys of any type.
437
+ *
438
+ * ```js
439
+ * var obj = { 1: "one" };
440
+ * Object.keys(obj); // [ "1" ]
441
+ * obj["1"]; // "one"
442
+ * obj[1]; // "one"
443
+ *
444
+ * var map = Map(obj);
445
+ * map.get("1"); // "one"
446
+ * map.get(1); // undefined
447
+ * ```
448
+ *
449
+ * Property access for JavaScript Objects first converts the key to a string,
450
+ * but since Immutable Map keys can be of any type the argument to `get()` is
451
+ * not altered.
403
452
  */
404
453
  export function Map<K, V>(): Map<K, V>;
405
- export function Map<K, V>(iter: KeyedIterable<K, V>): Map<K, V>;
454
+ export function Map<K, V>(iter: Iterable.Keyed<K, V>): Map<K, V>;
406
455
  export function Map<K, V>(iter: Iterable<any, /*[K,V]*/Array<any>>): Map<K, V>;
407
456
  export function Map<K, V>(array: Array</*[K,V]*/Array<any>>): Map<K, V>;
408
457
  export function Map<V>(obj: {[key: string]: V}): Map<string, V>;
409
458
  export function Map<K, V>(iterator: Iterator</*[K,V]*/Array<any>>): Map<K, V>;
410
459
  export function Map<K, V>(iterable: /*Iterable<[K,V]>*/Object): Map<K, V>;
411
460
 
412
- export interface Map<K, V> extends KeyedCollection<K, V> {
461
+ export interface Map<K, V> extends Collection.Keyed<K, V> {
413
462
 
414
463
  // Persistent changes
415
464
 
@@ -452,8 +501,8 @@ declare module 'immutable' {
452
501
  * each iterable and sets it on this Map.
453
502
  *
454
503
  * If any of the values provided to `merge` are not Iterable (would return
455
- * false for `Immutable.isIterable`) then they are deeply converted via
456
- * `Immutable.fromJS` before being merged. However, if the value is an
504
+ * false for `Immutable.Iterable.isIterable`) then they are deeply converted
505
+ * via `Immutable.fromJS` before being merged. However, if the value is an
457
506
  * Iterable but includes non-iterable JS objects or arrays, those nested
458
507
  * values will be preserved.
459
508
  *
@@ -645,6 +694,9 @@ declare module 'immutable' {
645
694
  * assert(map1.size === 0);
646
695
  * assert(map2.size === 3);
647
696
  *
697
+ * Note: Not all methods can be used on a mutable collection or within
698
+ * `withMutations`! Only `set` and `merge` may be used mutatively.
699
+ *
648
700
  */
649
701
  withMutations(mutator: (mutable: Map<K, V>) => any): Map<K, V>;
650
702
 
@@ -657,6 +709,9 @@ declare module 'immutable' {
657
709
  * use API.
658
710
  *
659
711
  * Note: if the collection is already mutable, `asMutable` returns itself.
712
+ *
713
+ * Note: Not all methods can be used on a mutable collection or within
714
+ * `withMutations`! Only `set` and `merge` may be used mutatively.
660
715
  */
661
716
  asMutable(): Map<K, V>;
662
717
 
@@ -692,7 +747,7 @@ declare module 'immutable' {
692
747
  /**
693
748
  * Creates a new Immutable OrderedMap.
694
749
  *
695
- * Created with the same key value pairs as the provided KeyedIterable or
750
+ * Created with the same key value pairs as the provided Iterable.Keyed or
696
751
  * JavaScript Object or expects an Iterable of [K, V] tuple entries.
697
752
  *
698
753
  * The iteration order of key-value pairs provided to this constructor will
@@ -703,7 +758,7 @@ declare module 'immutable' {
703
758
  *
704
759
  */
705
760
  export function OrderedMap<K, V>(): OrderedMap<K, V>;
706
- export function OrderedMap<K, V>(iter: KeyedIterable<K, V>): OrderedMap<K, V>;
761
+ export function OrderedMap<K, V>(iter: Iterable.Keyed<K, V>): OrderedMap<K, V>;
707
762
  export function OrderedMap<K, V>(iter: Iterable<any, /*[K,V]*/Array<any>>): OrderedMap<K, V>;
708
763
  export function OrderedMap<K, V>(array: Array</*[K,V]*/Array<any>>): OrderedMap<K, V>;
709
764
  export function OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V>;
@@ -749,14 +804,14 @@ declare module 'immutable' {
749
804
  * iterable-like.
750
805
  */
751
806
  export function Set<T>(): Set<T>;
752
- export function Set<T>(iter: SetIterable<T>): Set<T>;
753
- export function Set<T>(iter: IndexedIterable<T>): Set<T>;
754
- export function Set<K, V>(iter: KeyedIterable<K, V>): Set</*[K,V]*/any>;
807
+ export function Set<T>(iter: Iterable.Set<T>): Set<T>;
808
+ export function Set<T>(iter: Iterable.Indexed<T>): Set<T>;
809
+ export function Set<K, V>(iter: Iterable.Keyed<K, V>): Set</*[K,V]*/any>;
755
810
  export function Set<T>(array: Array<T>): Set<T>;
756
811
  export function Set<T>(iterator: Iterator<T>): Set<T>;
757
812
  export function Set<T>(iterable: /*Iterable<T>*/Object): Set<T>;
758
813
 
759
- export interface Set<T> extends SetCollection<T> {
814
+ export interface Set<T> extends Collection.Set<T> {
760
815
 
761
816
  // Persistent changes
762
817
 
@@ -807,6 +862,9 @@ declare module 'immutable' {
807
862
  // Transient changes
808
863
 
809
864
  /**
865
+ * Note: Not all methods can be used on a mutable collection or within
866
+ * `withMutations`! Only `add` may be used mutatively.
867
+ *
810
868
  * @see `Map#withMutations`
811
869
  */
812
870
  withMutations(mutator: (mutable: Set<T>) => any): Set<T>;
@@ -858,9 +916,9 @@ declare module 'immutable' {
858
916
  * iterable-like.
859
917
  */
860
918
  export function OrderedSet<T>(): OrderedSet<T>;
861
- export function OrderedSet<T>(iter: SetIterable<T>): OrderedSet<T>;
862
- export function OrderedSet<T>(iter: IndexedIterable<T>): OrderedSet<T>;
863
- export function OrderedSet<K, V>(iter: KeyedIterable<K, V>): OrderedSet</*[K,V]*/any>;
919
+ export function OrderedSet<T>(iter: Iterable.Set<T>): OrderedSet<T>;
920
+ export function OrderedSet<T>(iter: Iterable.Indexed<T>): OrderedSet<T>;
921
+ export function OrderedSet<K, V>(iter: Iterable.Keyed<K, V>): OrderedSet</*[K,V]*/any>;
864
922
  export function OrderedSet<T>(array: Array<T>): OrderedSet<T>;
865
923
  export function OrderedSet<T>(iterator: Iterator<T>): OrderedSet<T>;
866
924
  export function OrderedSet<T>(iterable: /*Iterable<T>*/Object): OrderedSet<T>;
@@ -902,14 +960,14 @@ declare module 'immutable' {
902
960
  * resulting `Stack`.
903
961
  */
904
962
  export function Stack<T>(): Stack<T>;
905
- export function Stack<T>(iter: IndexedIterable<T>): Stack<T>;
906
- export function Stack<T>(iter: SetIterable<T>): Stack<T>;
907
- export function Stack<K, V>(iter: KeyedIterable<K, V>): Stack</*[K,V]*/any>;
963
+ export function Stack<T>(iter: Iterable.Indexed<T>): Stack<T>;
964
+ export function Stack<T>(iter: Iterable.Set<T>): Stack<T>;
965
+ export function Stack<K, V>(iter: Iterable.Keyed<K, V>): Stack</*[K,V]*/any>;
908
966
  export function Stack<T>(array: Array<T>): Stack<T>;
909
967
  export function Stack<T>(iterator: Iterator<T>): Stack<T>;
910
968
  export function Stack<T>(iterable: /*Iterable<T>*/Object): Stack<T>;
911
969
 
912
- export interface Stack<T> extends IndexedCollection<T> {
970
+ export interface Stack<T> extends Collection.Indexed<T> {
913
971
 
914
972
  // Reading values
915
973
 
@@ -970,6 +1028,9 @@ declare module 'immutable' {
970
1028
  // Transient changes
971
1029
 
972
1030
  /**
1031
+ * Note: Not all methods can be used on a mutable collection or within
1032
+ * `withMutations`! Only `set`, `push`, and `pop` may be used mutatively.
1033
+ *
973
1034
  * @see `Map#withMutations`
974
1035
  */
975
1036
  withMutations(mutator: (mutable: Stack<T>) => any): Stack<T>;
@@ -987,7 +1048,7 @@ declare module 'immutable' {
987
1048
 
988
1049
 
989
1050
  /**
990
- * Returns a IndexedSeq of numbers from `start` (inclusive) to `end`
1051
+ * Returns a Seq.Indexed of numbers from `start` (inclusive) to `end`
991
1052
  * (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to
992
1053
  * infinity. When `start` is equal to `end`, returns empty range.
993
1054
  *
@@ -999,18 +1060,18 @@ declare module 'immutable' {
999
1060
  * Range(30,30,5) // []
1000
1061
  *
1001
1062
  */
1002
- export function Range(start?: number, end?: number, step?: number): IndexedSeq<number>;
1063
+ export function Range(start?: number, end?: number, step?: number): Seq.Indexed<number>;
1003
1064
 
1004
1065
 
1005
1066
  /**
1006
- * Returns a IndexedSeq of `value` repeated `times` times. When `times` is
1067
+ * Returns a Seq.Indexed of `value` repeated `times` times. When `times` is
1007
1068
  * not defined, returns an infinite `Seq` of `value`.
1008
1069
  *
1009
1070
  * Repeat('foo') // ['foo','foo','foo',...]
1010
1071
  * Repeat('bar',4) // ['bar','bar','bar','bar']
1011
1072
  *
1012
1073
  */
1013
- export function Repeat<T>(value: T, times?: number): IndexedSeq<T>;
1074
+ export function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
1014
1075
 
1015
1076
 
1016
1077
  /**
@@ -1032,7 +1093,9 @@ declare module 'immutable' {
1032
1093
  * myRecordWithoutB.size // 2
1033
1094
  *
1034
1095
  * Values provided to the constructor not found in the Record type will
1035
- * be ignored:
1096
+ * be ignored. For example, in this case, ABRecord is provided a key "x" even
1097
+ * though only "a" and "b" have been defined. The value for "x" will be
1098
+ * ignored for this record.
1036
1099
  *
1037
1100
  * var myRecord = new ABRecord({b:3, x:10})
1038
1101
  * myRecord.get('x') // undefined
@@ -1058,7 +1121,7 @@ declare module 'immutable' {
1058
1121
  * }
1059
1122
  * }
1060
1123
  *
1061
- * var myRecord = new ABRecord(b:3)
1124
+ * var myRecord = new ABRecord({b: 3})
1062
1125
  * myRecord.getAB() // 4
1063
1126
  *
1064
1127
  */
@@ -1100,7 +1163,7 @@ declare module 'immutable' {
1100
1163
  *
1101
1164
  * Once the Seq is used, it performs only the work necessary. In this
1102
1165
  * example, no intermediate data structures are ever created, filter is only
1103
- * called three times, and map is only called twice:
1166
+ * called three times, and map is only called once:
1104
1167
  *
1105
1168
  * console.log(evenSquares.get(1)); // 9
1106
1169
  *
@@ -1135,9 +1198,102 @@ declare module 'immutable' {
1135
1198
  function isSeq(maybeSeq: any): boolean;
1136
1199
 
1137
1200
  /**
1138
- * Returns a Seq of the values provided. Alias for `IndexedSeq.of()`.
1201
+ * Returns a Seq of the values provided. Alias for `Seq.Indexed.of()`.
1202
+ */
1203
+ function of<T>(...values: T[]): Seq.Indexed<T>;
1204
+
1205
+
1206
+ /**
1207
+ * `Seq` which represents key-value pairs.
1208
+ */
1209
+ export module Keyed {}
1210
+
1211
+ /**
1212
+ * Always returns a Seq.Keyed, if input is not keyed, expects an
1213
+ * iterable of [K, V] tuples.
1214
+ */
1215
+ export function Keyed<K, V>(): Seq.Keyed<K, V>;
1216
+ export function Keyed<K, V>(seq: Iterable.Keyed<K, V>): Seq.Keyed<K, V>;
1217
+ export function Keyed<K, V>(seq: Iterable<any, /*[K,V]*/any>): Seq.Keyed<K, V>;
1218
+ export function Keyed<K, V>(array: Array</*[K,V]*/any>): Seq.Keyed<K, V>;
1219
+ export function Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
1220
+ export function Keyed<K, V>(iterator: Iterator</*[K,V]*/any>): Seq.Keyed<K, V>;
1221
+ export function Keyed<K, V>(iterable: /*Iterable<[K,V]>*/Object): Seq.Keyed<K, V>;
1222
+
1223
+ export interface Keyed<K, V> extends Seq<K, V>, Iterable.Keyed<K, V> {
1224
+
1225
+ /**
1226
+ * Returns itself
1227
+ */
1228
+ toSeq(): /*this*/Seq.Keyed<K, V>
1229
+ }
1230
+
1231
+
1232
+ /**
1233
+ * `Seq` which represents an ordered indexed list of values.
1234
+ */
1235
+ module Indexed {
1236
+
1237
+ /**
1238
+ * Provides an Seq.Indexed of the values provided.
1239
+ */
1240
+ function of<T>(...values: T[]): Seq.Indexed<T>;
1241
+ }
1242
+
1243
+ /**
1244
+ * Always returns Seq.Indexed, discarding associated keys and
1245
+ * supplying incrementing indices.
1139
1246
  */
1140
- function of<T>(...values: T[]): IndexedSeq<T>;
1247
+ export function Indexed<T>(): Seq.Indexed<T>;
1248
+ export function Indexed<T>(seq: Iterable.Indexed<T>): Seq.Indexed<T>;
1249
+ export function Indexed<T>(seq: Iterable.Set<T>): Seq.Indexed<T>;
1250
+ export function Indexed<K, V>(seq: Iterable.Keyed<K, V>): Seq.Indexed</*[K,V]*/any>;
1251
+ export function Indexed<T>(array: Array<T>): Seq.Indexed<T>;
1252
+ export function Indexed<T>(iterator: Iterator<T>): Seq.Indexed<T>;
1253
+ export function Indexed<T>(iterable: /*Iterable<T>*/Object): Seq.Indexed<T>;
1254
+
1255
+ export interface Indexed<T> extends Seq<number, T>, Iterable.Indexed<T> {
1256
+
1257
+ /**
1258
+ * Returns itself
1259
+ */
1260
+ toSeq(): /*this*/Seq.Indexed<T>
1261
+ }
1262
+
1263
+
1264
+ /**
1265
+ * `Seq` which represents a set of values.
1266
+ *
1267
+ * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee
1268
+ * of value uniqueness as the concrete `Set`.
1269
+ */
1270
+ export module Set {
1271
+
1272
+ /**
1273
+ * Returns a Seq.Set of the provided values
1274
+ */
1275
+ function of<T>(...values: T[]): Seq.Set<T>;
1276
+ }
1277
+
1278
+ /**
1279
+ * Always returns a Seq.Set, discarding associated indices or keys.
1280
+ */
1281
+ export function Set<T>(): Seq.Set<T>;
1282
+ export function Set<T>(seq: Iterable.Set<T>): Seq.Set<T>;
1283
+ export function Set<T>(seq: Iterable.Indexed<T>): Seq.Set<T>;
1284
+ export function Set<K, V>(seq: Iterable.Keyed<K, V>): Seq.Set</*[K,V]*/any>;
1285
+ export function Set<T>(array: Array<T>): Seq.Set<T>;
1286
+ export function Set<T>(iterator: Iterator<T>): Seq.Set<T>;
1287
+ export function Set<T>(iterable: /*Iterable<T>*/Object): Seq.Set<T>;
1288
+
1289
+ export interface Set<T> extends Seq<T, T>, Iterable.Set<T> {
1290
+
1291
+ /**
1292
+ * Returns itself
1293
+ */
1294
+ toSeq(): /*this*/Seq.Set<T>
1295
+ }
1296
+
1141
1297
  }
1142
1298
 
1143
1299
  /**
@@ -1147,19 +1303,19 @@ declare module 'immutable' {
1147
1303
  *
1148
1304
  * * If a `Seq`, that same `Seq`.
1149
1305
  * * If an `Iterable`, a `Seq` of the same kind (Keyed, Indexed, or Set).
1150
- * * If an Array-like, an `IndexedSeq`.
1151
- * * If an Object with an Iterator, an `IndexedSeq`.
1152
- * * If an Iterator, an `IndexedSeq`.
1153
- * * If an Object, a `KeyedSeq`.
1306
+ * * If an Array-like, an `Seq.Indexed`.
1307
+ * * If an Object with an Iterator, an `Seq.Indexed`.
1308
+ * * If an Iterator, an `Seq.Indexed`.
1309
+ * * If an Object, a `Seq.Keyed`.
1154
1310
  *
1155
1311
  */
1156
1312
  export function Seq<K, V>(): Seq<K, V>;
1157
1313
  export function Seq<K, V>(seq: Seq<K, V>): Seq<K, V>;
1158
1314
  export function Seq<K, V>(iterable: Iterable<K, V>): Seq<K, V>;
1159
- export function Seq<T>(array: Array<T>): IndexedSeq<T>;
1160
- export function Seq<V>(obj: {[key: string]: V}): KeyedSeq<string, V>;
1161
- export function Seq<T>(iterator: Iterator<T>): IndexedSeq<T>;
1162
- export function Seq<T>(iterable: /*ES6Iterable<T>*/Object): IndexedSeq<T>;
1315
+ export function Seq<T>(array: Array<T>): Seq.Indexed<T>;
1316
+ export function Seq<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
1317
+ export function Seq<T>(iterator: Iterator<T>): Seq.Indexed<T>;
1318
+ export function Seq<T>(iterable: /*ES6Iterable<T>*/Object): Seq.Indexed<T>;
1163
1319
 
1164
1320
  export interface Seq<K, V> extends Iterable<K, V> {
1165
1321
 
@@ -1201,98 +1357,6 @@ declare module 'immutable' {
1201
1357
  cacheResult(): /*this*/Seq<K, V>;
1202
1358
  }
1203
1359
 
1204
-
1205
- /**
1206
- * `Seq` which represents key-value pairs.
1207
- */
1208
- export module KeyedSeq {}
1209
-
1210
- /**
1211
- * Always returns a KeyedSeq, if input is not keyed, expects an
1212
- * iterable of [K, V] tuples.
1213
- */
1214
- export function KeyedSeq<K, V>(): KeyedSeq<K, V>;
1215
- export function KeyedSeq<K, V>(seq: KeyedIterable<K, V>): KeyedSeq<K, V>;
1216
- export function KeyedSeq<K, V>(seq: Iterable<any, /*[K,V]*/any>): KeyedSeq<K, V>;
1217
- export function KeyedSeq<K, V>(array: Array</*[K,V]*/any>): KeyedSeq<K, V>;
1218
- export function KeyedSeq<V>(obj: {[key: string]: V}): KeyedSeq<string, V>;
1219
- export function KeyedSeq<K, V>(iterator: Iterator</*[K,V]*/any>): KeyedSeq<K, V>;
1220
- export function KeyedSeq<K, V>(iterable: /*Iterable<[K,V]>*/Object): KeyedSeq<K, V>;
1221
-
1222
- export interface KeyedSeq<K, V> extends Seq<K, V>, KeyedIterable<K, V> {
1223
-
1224
- /**
1225
- * Returns itself
1226
- */
1227
- toSeq(): /*this*/KeyedSeq<K, V>
1228
- }
1229
-
1230
-
1231
- /**
1232
- * `Seq` which represents an ordered indexed list of values.
1233
- */
1234
- export module IndexedSeq {
1235
-
1236
- /**
1237
- * Provides an IndexedSeq of the values provided.
1238
- */
1239
- function of<T>(...values: T[]): IndexedSeq<T>;
1240
- }
1241
-
1242
- /**
1243
- * Always returns IndexedSeq, discarding associated keys and
1244
- * supplying incrementing indices.
1245
- */
1246
- export function IndexedSeq<T>(): IndexedSeq<T>;
1247
- export function IndexedSeq<T>(seq: IndexedIterable<T>): IndexedSeq<T>;
1248
- export function IndexedSeq<T>(seq: SetIterable<T>): IndexedSeq<T>;
1249
- export function IndexedSeq<K, V>(seq: KeyedIterable<K, V>): IndexedSeq</*[K,V]*/any>;
1250
- export function IndexedSeq<T>(array: Array<T>): IndexedSeq<T>;
1251
- export function IndexedSeq<T>(iterator: Iterator<T>): IndexedSeq<T>;
1252
- export function IndexedSeq<T>(iterable: /*Iterable<T>*/Object): IndexedSeq<T>;
1253
-
1254
- export interface IndexedSeq<T> extends Seq<number, T>, IndexedIterable<T> {
1255
-
1256
- /**
1257
- * Returns itself
1258
- */
1259
- toSeq(): /*this*/IndexedSeq<T>
1260
- }
1261
-
1262
- /**
1263
- * `Seq` which represents a set of values.
1264
- *
1265
- * Because `Seq` are often lazy, `SetSeq` does not provide the same guarantee
1266
- * of value uniqueness as the concrete `Set`.
1267
- */
1268
- export module SetSeq {
1269
-
1270
- /**
1271
- * Returns a SetSeq of the provided values
1272
- */
1273
- function of<T>(...values: T[]): SetSeq<T>;
1274
- }
1275
-
1276
- /**
1277
- * Always returns a SetSeq, discarding associated indices or keys.
1278
- */
1279
- export function SetSeq<T>(): SetSeq<T>;
1280
- export function SetSeq<T>(seq: SetIterable<T>): SetSeq<T>;
1281
- export function SetSeq<T>(seq: IndexedIterable<T>): SetSeq<T>;
1282
- export function SetSeq<K, V>(seq: KeyedIterable<K, V>): SetSeq</*[K,V]*/any>;
1283
- export function SetSeq<T>(array: Array<T>): SetSeq<T>;
1284
- export function SetSeq<T>(iterator: Iterator<T>): SetSeq<T>;
1285
- export function SetSeq<T>(iterable: /*Iterable<T>*/Object): SetSeq<T>;
1286
-
1287
- export interface SetSeq<T> extends Seq<T, T>, SetIterable<T> {
1288
-
1289
- /**
1290
- * Returns itself
1291
- */
1292
- toSeq(): /*this*/SetSeq<T>
1293
- }
1294
-
1295
-
1296
1360
  /**
1297
1361
  * The `Iterable` is a set of (key, value) entries which can be iterated, and
1298
1362
  * is the base class for all collections in `immutable`, allowing them to
@@ -1308,12 +1372,12 @@ declare module 'immutable' {
1308
1372
  function isIterable(maybeIterable: any): boolean;
1309
1373
 
1310
1374
  /**
1311
- * True if `maybeKeyed` is a KeyedIterable, or any of its subclasses.
1375
+ * True if `maybeKeyed` is an Iterable.Keyed, or any of its subclasses.
1312
1376
  */
1313
1377
  function isKeyed(maybeKeyed: any): boolean;
1314
1378
 
1315
1379
  /**
1316
- * True if `maybeIndexed` is a IndexedIterable, or any of its subclasses.
1380
+ * True if `maybeIndexed` is a Iterable.Indexed, or any of its subclasses.
1317
1381
  */
1318
1382
  function isIndexed(maybeIndexed: any): boolean;
1319
1383
 
@@ -1324,9 +1388,324 @@ declare module 'immutable' {
1324
1388
 
1325
1389
  /**
1326
1390
  * True if `maybeOrdered` is an Iterable where iteration order is well
1327
- * defined. True for IndexedIterable as well as OrderedMap and OrderedSet.
1391
+ * defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.
1328
1392
  */
1329
1393
  function isOrdered(maybeOrdered: any): boolean;
1394
+
1395
+
1396
+ /**
1397
+ * Keyed Iterables have discrete keys tied to each value.
1398
+ *
1399
+ * When iterating `Iterable.Keyed`, each iteration will yield a `[K, V]`
1400
+ * tuple, in other words, `Iterable#entries` is the default iterator for
1401
+ * Keyed Iterables.
1402
+ */
1403
+ export module Keyed {}
1404
+
1405
+ /**
1406
+ * Creates an Iterable.Keyed
1407
+ *
1408
+ * Similar to `Iterable()`, however it expects iterable-likes of [K, V]
1409
+ * tuples if not constructed from a Iterable.Keyed or JS Object.
1410
+ */
1411
+ export function Keyed<K, V>(iter: Iterable.Keyed<K, V>): Iterable.Keyed<K, V>;
1412
+ export function Keyed<K, V>(iter: Iterable<any, /*[K,V]*/any>): Iterable.Keyed<K, V>;
1413
+ export function Keyed<K, V>(array: Array</*[K,V]*/any>): Iterable.Keyed<K, V>;
1414
+ export function Keyed<V>(obj: {[key: string]: V}): Iterable.Keyed<string, V>;
1415
+ export function Keyed<K, V>(iterator: Iterator</*[K,V]*/any>): Iterable.Keyed<K, V>;
1416
+ export function Keyed<K, V>(iterable: /*Iterable<[K,V]>*/Object): Iterable.Keyed<K, V>;
1417
+
1418
+ export interface Keyed<K, V> extends Iterable<K, V> {
1419
+
1420
+ /**
1421
+ * Returns Seq.Keyed.
1422
+ * @override
1423
+ */
1424
+ toSeq(): Seq.Keyed<K, V>;
1425
+
1426
+
1427
+ // Sequence functions
1428
+
1429
+ /**
1430
+ * Returns a new Iterable.Keyed of the same type where the keys and values
1431
+ * have been flipped.
1432
+ *
1433
+ * Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }
1434
+ *
1435
+ */
1436
+ flip(): /*this*/Iterable.Keyed<V, K>;
1437
+
1438
+ /**
1439
+ * Returns a new Iterable.Keyed of the same type with keys passed through
1440
+ * a `mapper` function.
1441
+ *
1442
+ * Seq({ a: 1, b: 2 })
1443
+ * .mapKeys(x => x.toUpperCase())
1444
+ * // Seq { A: 1, B: 2 }
1445
+ *
1446
+ */
1447
+ mapKeys<M>(
1448
+ mapper: (key?: K, value?: V, iter?: /*this*/Iterable.Keyed<K, V>) => M,
1449
+ context?: any
1450
+ ): /*this*/Iterable.Keyed<M, V>;
1451
+
1452
+ /**
1453
+ * Returns a new Iterable.Keyed of the same type with entries
1454
+ * ([key, value] tuples) passed through a `mapper` function.
1455
+ *
1456
+ * Seq({ a: 1, b: 2 })
1457
+ * .mapEntries(([k, v]) => [k.toUpperCase(), v * 2])
1458
+ * // Seq { A: 2, B: 4 }
1459
+ *
1460
+ */
1461
+ mapEntries<KM, VM>(
1462
+ mapper: (
1463
+ entry?: /*(K, V)*/Array<any>,
1464
+ index?: number,
1465
+ iter?: /*this*/Iterable.Keyed<K, V>
1466
+ ) => /*[KM, VM]*/Array<any>,
1467
+ context?: any
1468
+ ): /*this*/Iterable.Keyed<KM, VM>;
1469
+
1470
+
1471
+ // Search for value
1472
+
1473
+ /**
1474
+ * Returns the key associated with the search value, or undefined.
1475
+ */
1476
+ keyOf(searchValue: V): K;
1477
+
1478
+ /**
1479
+ * Returns the last key associated with the search value, or undefined.
1480
+ */
1481
+ lastKeyOf(searchValue: V): K;
1482
+
1483
+ /**
1484
+ * Returns the key for which the `predicate` returns true.
1485
+ */
1486
+ findKey(
1487
+ predicate: (value?: V, key?: K, iter?: /*this*/Iterable.Keyed<K, V>) => boolean,
1488
+ context?: any
1489
+ ): K;
1490
+
1491
+ /**
1492
+ * Returns the last key for which the `predicate` returns true.
1493
+ *
1494
+ * Note: `predicate` will be called for each entry in reverse.
1495
+ */
1496
+ findLastKey(
1497
+ predicate: (value?: V, key?: K, iter?: /*this*/Iterable.Keyed<K, V>) => boolean,
1498
+ context?: any
1499
+ ): K;
1500
+ }
1501
+
1502
+
1503
+ /**
1504
+ * Indexed Iterables have incrementing numeric keys. They exhibit
1505
+ * slightly different behavior than `Iterable.Keyed` for some methods in order
1506
+ * to better mirror the behavior of JavaScript's `Array`, and add methods
1507
+ * which do not make sense on non-indexed Iterables such as `indexOf`.
1508
+ *
1509
+ * Unlike JavaScript arrays, `Iterable.Indexed`s are always dense. "Unset"
1510
+ * indices and `undefined` indices are indistinguishable, and all indices from
1511
+ * 0 to `size` are visited when iterated.
1512
+ *
1513
+ * All Iterable.Indexed methods return re-indexed Iterables. In other words,
1514
+ * indices always start at 0 and increment until size. If you wish to
1515
+ * preserve indices, using them as keys, convert to a Iterable.Keyed by
1516
+ * calling `toKeyedSeq`.
1517
+ */
1518
+ export module Indexed {}
1519
+
1520
+ /**
1521
+ * Creates a new Iterable.Indexed.
1522
+ */
1523
+ export function Indexed<T>(iter: Iterable.Indexed<T>): Iterable.Indexed<T>;
1524
+ export function Indexed<T>(iter: Iterable.Set<T>): Iterable.Indexed<T>;
1525
+ export function Indexed<K, V>(iter: Iterable.Keyed<K, V>): Iterable.Indexed</*[K,V]*/any>;
1526
+ export function Indexed<T>(array: Array<T>): Iterable.Indexed<T>;
1527
+ export function Indexed<T>(iterator: Iterator<T>): Iterable.Indexed<T>;
1528
+ export function Indexed<T>(iterable: /*Iterable<T>*/Object): Iterable.Indexed<T>;
1529
+
1530
+ export interface Indexed<T> extends Iterable<number, T> {
1531
+
1532
+ // Reading values
1533
+
1534
+ /**
1535
+ * Returns the value associated with the provided index, or notSetValue if
1536
+ * the index is beyond the bounds of the Iterable.
1537
+ *
1538
+ * `index` may be a negative number, which indexes back from the end of the
1539
+ * Iterable. `s.get(-1)` gets the last item in the Iterable.
1540
+ */
1541
+ get(index: number, notSetValue?: T): T;
1542
+
1543
+
1544
+ // Conversion to Seq
1545
+
1546
+ /**
1547
+ * Returns Seq.Indexed.
1548
+ * @override
1549
+ */
1550
+ toSeq(): Seq.Indexed<T>;
1551
+
1552
+ /**
1553
+ * If this is an iterable of [key, value] entry tuples, it will return a
1554
+ * Seq.Keyed of those entries.
1555
+ */
1556
+ fromEntrySeq(): Seq.Keyed<any, any>;
1557
+
1558
+
1559
+ // Combination
1560
+
1561
+ /**
1562
+ * Returns an Iterable of the same type with `separator` between each item
1563
+ * in this Iterable.
1564
+ */
1565
+ interpose(separator: T): /*this*/Iterable.Indexed<T>;
1566
+
1567
+ /**
1568
+ * Returns an Iterable of the same type with the provided `iterables`
1569
+ * interleaved into this iterable.
1570
+ *
1571
+ * The resulting Iterable includes the first item from each, then the
1572
+ * second from each, etc.
1573
+ *
1574
+ * I.Seq.of(1,2,3).interleave(I.Seq.of('A','B','C'))
1575
+ * // Seq [ 1, 'A', 2, 'B', 3, 'C' ]
1576
+ *
1577
+ * The shortest Iterable stops interleave.
1578
+ *
1579
+ * I.Seq.of(1,2,3).interleave(
1580
+ * I.Seq.of('A','B'),
1581
+ * I.Seq.of('X','Y','Z')
1582
+ * )
1583
+ * // Seq [ 1, 'A', 'X', 2, 'B', 'Y' ]
1584
+ */
1585
+ interleave(...iterables: Array<Iterable<any, T>>): /*this*/Iterable.Indexed<T>;
1586
+
1587
+ /**
1588
+ * Splice returns a new indexed Iterable by replacing a region of this
1589
+ * Iterable with new values. If values are not provided, it only skips the
1590
+ * region to be removed.
1591
+ *
1592
+ * `index` may be a negative number, which indexes back from the end of the
1593
+ * Iterable. `s.splice(-2)` splices after the second to last item.
1594
+ *
1595
+ * Seq(['a','b','c','d']).splice(1, 2, 'q', 'r', 's')
1596
+ * // Seq ['a', 'q', 'r', 's', 'd']
1597
+ *
1598
+ */
1599
+ splice(
1600
+ index: number,
1601
+ removeNum: number,
1602
+ ...values: /*Array<Iterable.Indexed<T> | T>*/any[]
1603
+ ): /*this*/Iterable.Indexed<T>;
1604
+
1605
+ /**
1606
+ * Returns an Iterable of the same type "zipped" with the provided
1607
+ * iterables.
1608
+ *
1609
+ * Like `zipWith`, but using the default `zipper`: creating an `Array`.
1610
+ *
1611
+ * var a = Seq.of(1, 2, 3);
1612
+ * var b = Seq.of(4, 5, 6);
1613
+ * var c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
1614
+ *
1615
+ */
1616
+ zip(...iterables: Array<Iterable<any, any>>): /*this*/Iterable.Indexed<any>;
1617
+
1618
+ /**
1619
+ * Returns an Iterable of the same type "zipped" with the provided
1620
+ * iterables by using a custom `zipper` function.
1621
+ *
1622
+ * var a = Seq.of(1, 2, 3);
1623
+ * var b = Seq.of(4, 5, 6);
1624
+ * var c = a.zipWith((a, b) => a + b, b); // Seq [ 5, 7, 9 ]
1625
+ *
1626
+ */
1627
+ zipWith<U, Z>(
1628
+ zipper: (value: T, otherValue: U) => Z,
1629
+ otherIterable: Iterable<any, U>
1630
+ ): Iterable.Indexed<Z>;
1631
+ zipWith<U, V, Z>(
1632
+ zipper: (value: T, otherValue: U, thirdValue: V) => Z,
1633
+ otherIterable: Iterable<any, U>,
1634
+ thirdIterable: Iterable<any, V>
1635
+ ): Iterable.Indexed<Z>;
1636
+ zipWith<Z>(
1637
+ zipper: (...any: Array<any>) => Z,
1638
+ ...iterables: Array<Iterable<any, any>>
1639
+ ): Iterable.Indexed<Z>;
1640
+
1641
+
1642
+ // Search for value
1643
+
1644
+ /**
1645
+ * Returns the first index at which a given value can be found in the
1646
+ * Iterable, or -1 if it is not present.
1647
+ */
1648
+ indexOf(searchValue: T): number;
1649
+
1650
+ /**
1651
+ * Returns the last index at which a given value can be found in the
1652
+ * Iterable, or -1 if it is not present.
1653
+ */
1654
+ lastIndexOf(searchValue: T): number;
1655
+
1656
+ /**
1657
+ * Returns the first index in the Iterable where a value satisfies the
1658
+ * provided predicate function. Otherwise -1 is returned.
1659
+ */
1660
+ findIndex(
1661
+ predicate: (value?: T, index?: number, iter?: /*this*/Iterable.Indexed<T>) => boolean,
1662
+ context?: any
1663
+ ): number;
1664
+
1665
+ /**
1666
+ * Returns the last index in the Iterable where a value satisfies the
1667
+ * provided predicate function. Otherwise -1 is returned.
1668
+ */
1669
+ findLastIndex(
1670
+ predicate: (value?: T, index?: number, iter?: /*this*/Iterable.Indexed<T>) => boolean,
1671
+ context?: any
1672
+ ): number;
1673
+ }
1674
+
1675
+
1676
+ /**
1677
+ * Set Iterables only represent values. They have no associated keys or
1678
+ * indices. Duplicate values are possible in Seq.Sets, however the
1679
+ * concrete `Set` does not allow duplicate values.
1680
+ *
1681
+ * Iterable methods on Iterable.Set such as `map` and `forEach` will provide
1682
+ * the value as both the first and second arguments to the provided function.
1683
+ *
1684
+ * var seq = Seq.Set.of('A', 'B', 'C');
1685
+ * assert.equal(seq.every((v, k) => v === k), true);
1686
+ *
1687
+ */
1688
+ export module Set {}
1689
+
1690
+ /**
1691
+ * Similar to `Iterable()`, but always returns a Iterable.Set.
1692
+ */
1693
+ export function Set<T>(iter: Iterable.Set<T>): Iterable.Set<T>;
1694
+ export function Set<T>(iter: Iterable.Indexed<T>): Iterable.Set<T>;
1695
+ export function Set<K, V>(iter: Iterable.Keyed<K, V>): Iterable.Set</*[K,V]*/any>;
1696
+ export function Set<T>(array: Array<T>): Iterable.Set<T>;
1697
+ export function Set<T>(iterator: Iterator<T>): Iterable.Set<T>;
1698
+ export function Set<T>(iterable: /*Iterable<T>*/Object): Iterable.Set<T>;
1699
+
1700
+ export interface Set<T> extends Iterable<T, T> {
1701
+
1702
+ /**
1703
+ * Returns Seq.Set.
1704
+ * @override
1705
+ */
1706
+ toSeq(): Seq.Set<T>;
1707
+ }
1708
+
1330
1709
  }
1331
1710
 
1332
1711
  /**
@@ -1335,21 +1714,21 @@ declare module 'immutable' {
1335
1714
  * The type of Iterable created is based on the input.
1336
1715
  *
1337
1716
  * * If an `Iterable`, that same `Iterable`.
1338
- * * If an Array-like, an `IndexedIterable`.
1339
- * * If an Object with an Iterator, an `IndexedIterable`.
1340
- * * If an Iterator, an `IndexedIterable`.
1341
- * * If an Object, a `KeyedIterable`.
1717
+ * * If an Array-like, an `Iterable.Indexed`.
1718
+ * * If an Object with an Iterator, an `Iterable.Indexed`.
1719
+ * * If an Iterator, an `Iterable.Indexed`.
1720
+ * * If an Object, an `Iterable.Keyed`.
1342
1721
  *
1343
1722
  * This methods forces the conversion of Objects and Strings to Iterables.
1344
1723
  * If you want to ensure that a Iterable of one item is returned, use
1345
1724
  * `Seq.of`.
1346
1725
  */
1347
1726
  export function Iterable<K, V>(iterable: Iterable<K, V>): Iterable<K, V>;
1348
- export function Iterable<T>(array: Array<T>): IndexedIterable<T>;
1349
- export function Iterable<V>(obj: {[key: string]: V}): KeyedIterable<string, V>;
1350
- export function Iterable<T>(iterator: Iterator<T>): IndexedIterable<T>;
1351
- export function Iterable<T>(iterable: /*ES6Iterable<T>*/Object): IndexedIterable<T>;
1352
- export function Iterable<V>(value: V): IndexedIterable<V>;
1727
+ export function Iterable<T>(array: Array<T>): Iterable.Indexed<T>;
1728
+ export function Iterable<V>(obj: {[key: string]: V}): Iterable.Keyed<string, V>;
1729
+ export function Iterable<T>(iterator: Iterator<T>): Iterable.Indexed<T>;
1730
+ export function Iterable<T>(iterable: /*ES6Iterable<T>*/Object): Iterable.Indexed<T>;
1731
+ export function Iterable<V>(value: V): Iterable.Indexed<V>;
1353
1732
 
1354
1733
  export interface Iterable<K, V> {
1355
1734
 
@@ -1434,8 +1813,8 @@ declare module 'immutable' {
1434
1813
  * True if the result of following a path of keys or indices through nested
1435
1814
  * Iterables results in a set value.
1436
1815
  */
1437
- hasIn(searchKeyPath: Array<any>, notSetValue?: any): boolean;
1438
- hasIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): boolean;
1816
+ hasIn(searchKeyPath: Array<any>): boolean;
1817
+ hasIn(searchKeyPath: Iterable<any, any>): boolean;
1439
1818
 
1440
1819
 
1441
1820
  // Conversion to JavaScript types
@@ -1443,8 +1822,8 @@ declare module 'immutable' {
1443
1822
  /**
1444
1823
  * Deeply converts this Iterable to equivalent JS.
1445
1824
  *
1446
- * `IndexedIterables`, and `SetIterables` become Arrays, while
1447
- * `KeyedIterables` become Objects.
1825
+ * `Iterable.Indexeds`, and `Iterable.Sets` become Arrays, while
1826
+ * `Iterable.Keyeds` become Objects.
1448
1827
  *
1449
1828
  * @alias toJSON
1450
1829
  */
@@ -1526,10 +1905,10 @@ declare module 'immutable' {
1526
1905
  toSeq(): Seq<K, V>;
1527
1906
 
1528
1907
  /**
1529
- * Returns a KeyedSeq from this Iterable where indices are treated as keys.
1908
+ * Returns a Seq.Keyed from this Iterable where indices are treated as keys.
1530
1909
  *
1531
1910
  * This is useful if you want to operate on an
1532
- * IndexedIterable and preserve the [index, value] pairs.
1911
+ * Iterable.Indexed and preserve the [index, value] pairs.
1533
1912
  *
1534
1913
  * The returned Seq will have identical iteration order as
1535
1914
  * this Iterable.
@@ -1542,17 +1921,17 @@ declare module 'immutable' {
1542
1921
  * keyedSeq.filter(v => v === 'B').toString() // Seq { 1: 'B' }
1543
1922
  *
1544
1923
  */
1545
- toKeyedSeq(): KeyedSeq<K, V>;
1924
+ toKeyedSeq(): Seq.Keyed<K, V>;
1546
1925
 
1547
1926
  /**
1548
- * Returns an IndexedSeq of the values of this Iterable, discarding keys.
1927
+ * Returns an Seq.Indexed of the values of this Iterable, discarding keys.
1549
1928
  */
1550
- toIndexedSeq(): IndexedSeq<V>;
1929
+ toIndexedSeq(): Seq.Indexed<V>;
1551
1930
 
1552
1931
  /**
1553
- * Returns a SetSeq of the values of this Iterable, discarding keys.
1932
+ * Returns a Seq.Set of the values of this Iterable, discarding keys.
1554
1933
  */
1555
- toSetSeq(): SetSeq<V>;
1934
+ toSetSeq(): Seq.Set<V>;
1556
1935
 
1557
1936
 
1558
1937
  // Iterators
@@ -1576,20 +1955,20 @@ declare module 'immutable' {
1576
1955
  // Iterables (Seq)
1577
1956
 
1578
1957
  /**
1579
- * Returns a new IndexedSeq of the keys of this Iterable,
1958
+ * Returns a new Seq.Indexed of the keys of this Iterable,
1580
1959
  * discarding values.
1581
1960
  */
1582
- keySeq(): IndexedSeq<K>;
1961
+ keySeq(): Seq.Indexed<K>;
1583
1962
 
1584
1963
  /**
1585
- * Returns an IndexedSeq of the values of this Iterable, discarding keys.
1964
+ * Returns an Seq.Indexed of the values of this Iterable, discarding keys.
1586
1965
  */
1587
- valueSeq(): IndexedSeq<V>;
1966
+ valueSeq(): Seq.Indexed<V>;
1588
1967
 
1589
1968
  /**
1590
- * Returns a new IndexedSeq of [key, value] tuples.
1969
+ * Returns a new Seq.Indexed of [key, value] tuples.
1591
1970
  */
1592
- entrySeq(): IndexedSeq</*(K, V)*/Array<any>>;
1971
+ entrySeq(): Seq.Indexed</*(K, V)*/Array<any>>;
1593
1972
 
1594
1973
 
1595
1974
  // Sequence algorithms
@@ -1670,7 +2049,7 @@ declare module 'immutable' {
1670
2049
  ): /*this*/Iterable<K, V>;
1671
2050
 
1672
2051
  /**
1673
- * Returns a `KeyedIterable` of `KeyedIterables`, grouped by the return
2052
+ * Returns a `Iterable.Keyed` of `Iterable.Keyeds`, grouped by the return
1674
2053
  * value of the `grouper` function.
1675
2054
  *
1676
2055
  * Note: This is always an eager operation.
@@ -1678,7 +2057,7 @@ declare module 'immutable' {
1678
2057
  groupBy<G>(
1679
2058
  grouper: (value?: V, key?: K, iter?: /*this*/Iterable<K, V>) => G,
1680
2059
  context?: any
1681
- ): /*Map*/KeyedSeq<G, /*this*/Iterable<K, V>>;
2060
+ ): /*Map*/Seq.Keyed<G, /*this*/Iterable<K, V>>;
1682
2061
 
1683
2062
 
1684
2063
  // Side effects
@@ -1926,7 +2305,7 @@ declare module 'immutable' {
1926
2305
  ): number;
1927
2306
 
1928
2307
  /**
1929
- * Returns a `KeyedSeq` of counts, grouped by the return value of
2308
+ * Returns a `Seq.Keyed` of counts, grouped by the return value of
1930
2309
  * the `grouper` function.
1931
2310
  *
1932
2311
  * Note: This is not a lazy operation.
@@ -2067,328 +2446,63 @@ declare module 'immutable' {
2067
2446
 
2068
2447
 
2069
2448
  /**
2070
- * Keyed Iterables have discrete keys tied to each value.
2071
- *
2072
- * When iterating `KeyedIterable`, each iteration will yield a `[K, V]` tuple,
2073
- * in other words, `Iterable#entries` is the default iterator for Keyed
2074
- * Iterables.
2075
- */
2076
- export module KeyedIterable {}
2077
-
2078
- /**
2079
- * Creates a KeyedIterable
2449
+ * Collection is the abstract base class for concrete data structures. It
2450
+ * cannot be constructed directly.
2080
2451
  *
2081
- * Similar to `Iterable()`, however it expects iterable-likes of [K, V]
2082
- * tuples if not constructed from a KeyedIterable or JS Object.
2083
- */
2084
- export function KeyedIterable<K, V>(iter: KeyedIterable<K, V>): KeyedIterable<K, V>;
2085
- export function KeyedIterable<K, V>(iter: Iterable<any, /*[K,V]*/any>): KeyedIterable<K, V>;
2086
- export function KeyedIterable<K, V>(array: Array</*[K,V]*/any>): KeyedIterable<K, V>;
2087
- export function KeyedIterable<V>(obj: {[key: string]: V}): KeyedIterable<string, V>;
2088
- export function KeyedIterable<K, V>(iterator: Iterator</*[K,V]*/any>): KeyedIterable<K, V>;
2089
- export function KeyedIterable<K, V>(iterable: /*Iterable<[K,V]>*/Object): KeyedIterable<K, V>;
2090
-
2091
- export interface KeyedIterable<K, V> extends Iterable<K, V> {
2092
-
2093
- /**
2094
- * Returns KeyedSeq.
2095
- * @override
2096
- */
2097
- toSeq(): KeyedSeq<K, V>;
2098
-
2099
-
2100
- // Sequence functions
2101
-
2102
- /**
2103
- * Returns a new KeyedIterable of the same type where the keys and values
2104
- * have been flipped.
2105
- *
2106
- * Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }
2107
- *
2108
- */
2109
- flip(): /*this*/KeyedIterable<V, K>;
2110
-
2111
- /**
2112
- * Returns a new KeyedIterable of the same type with keys passed through a
2113
- * `mapper` function.
2114
- *
2115
- * Seq({ a: 1, b: 2 })
2116
- * .mapKeys(x => x.toUpperCase())
2117
- * // Seq { A: 1, B: 2 }
2118
- *
2119
- */
2120
- mapKeys<M>(
2121
- mapper: (key?: K, value?: V, iter?: /*this*/KeyedIterable<K, V>) => M,
2122
- context?: any
2123
- ): /*this*/KeyedIterable<M, V>;
2124
-
2125
- /**
2126
- * Returns a new KeyedIterable of the same type with entries
2127
- * ([key, value] tuples) passed through a `mapper` function.
2128
- *
2129
- * Seq({ a: 1, b: 2 })
2130
- * .mapEntries(([k, v]) => [k.toUpperCase(), v * 2])
2131
- * // Seq { A: 2, B: 4 }
2132
- *
2133
- */
2134
- mapEntries<KM, VM>(
2135
- mapper: (
2136
- entry?: /*(K, V)*/Array<any>,
2137
- index?: number,
2138
- iter?: /*this*/KeyedIterable<K, V>
2139
- ) => /*[KM, VM]*/Array<any>,
2140
- context?: any
2141
- ): /*this*/KeyedIterable<KM, VM>;
2142
-
2143
-
2144
- // Search for value
2145
-
2146
- /**
2147
- * Returns the key associated with the search value, or undefined.
2148
- */
2149
- keyOf(searchValue: V): K;
2150
-
2151
- /**
2152
- * Returns the last key associated with the search value, or undefined.
2153
- */
2154
- lastKeyOf(searchValue: V): K;
2155
-
2156
- /**
2157
- * Returns the key for which the `predicate` returns true.
2158
- */
2159
- findKey(
2160
- predicate: (value?: V, key?: K, iter?: /*this*/KeyedIterable<K, V>) => boolean,
2161
- context?: any
2162
- ): K;
2163
-
2164
- /**
2165
- * Returns the last key for which the `predicate` returns true.
2166
- *
2167
- * Note: `predicate` will be called for each entry in reverse.
2168
- */
2169
- findLastKey(
2170
- predicate: (value?: V, key?: K, iter?: /*this*/KeyedIterable<K, V>) => boolean,
2171
- context?: any
2172
- ): K;
2173
- }
2174
-
2175
-
2176
- /**
2177
- * Indexed Iterables have incrementing numeric keys. They exhibit
2178
- * slightly different behavior than `KeyedIterable` for some methods in order
2179
- * to better mirror the behavior of JavaScript's `Array`, and add methods
2180
- * which do not make sense on non-indexed Iterables such as `indexOf`.
2181
- *
2182
- * Unlike JavaScript arrays, `IndexedIterable`s are always dense. "Unset"
2183
- * indices and `undefined` indices are indistinguishable, and all indices from
2184
- * 0 to `size` are visited when iterated.
2185
- *
2186
- * All IndexedIterable methods return re-indexed Iterables. In other words,
2187
- * indices always start at 0 and increment until size. If you wish to
2188
- * preserve indices, using them as keys, convert to a KeyedIterable by calling
2189
- * `toKeyedSeq`.
2190
- */
2191
- export module IndexedIterable {}
2192
-
2193
- /**
2194
- * Creates a new IndexedIterable.
2452
+ * Implementations should extend one of the subclasses, `Collection.Keyed`,
2453
+ * `Collection.Indexed`, or `Collection.Set`.
2195
2454
  */
2196
- export function IndexedIterable<T>(iter: IndexedIterable<T>): IndexedIterable<T>;
2197
- export function IndexedIterable<T>(iter: SetIterable<T>): IndexedIterable<T>;
2198
- export function IndexedIterable<K, V>(iter: KeyedIterable<K, V>): IndexedIterable</*[K,V]*/any>;
2199
- export function IndexedIterable<T>(array: Array<T>): IndexedIterable<T>;
2200
- export function IndexedIterable<T>(iterator: Iterator<T>): IndexedIterable<T>;
2201
- export function IndexedIterable<T>(iterable: /*Iterable<T>*/Object): IndexedIterable<T>;
2455
+ export module Collection {
2202
2456
 
2203
- export interface IndexedIterable<T> extends Iterable<number, T> {
2204
-
2205
- // Reading values
2206
2457
 
2207
2458
  /**
2208
- * Returns the value associated with the provided index, or notSetValue if
2209
- * the index is beyond the bounds of the Iterable.
2210
- *
2211
- * `index` may be a negative number, which indexes back from the end of the
2212
- * Iterable. `s.get(-1)` gets the last item in the Iterable.
2459
+ * `Collection` which represents key-value pairs.
2213
2460
  */
2214
- get(index: number, notSetValue?: T): T;
2461
+ export module Keyed {}
2215
2462
 
2463
+ export interface Keyed<K, V> extends Collection<K, V>, Iterable.Keyed<K, V> {
2216
2464
 
2217
- // Conversion to Seq
2465
+ /**
2466
+ * Returns Seq.Keyed.
2467
+ * @override
2468
+ */
2469
+ toSeq(): Seq.Keyed<K, V>;
2470
+ }
2218
2471
 
2219
- /**
2220
- * Returns IndexedSeq.
2221
- * @override
2222
- */
2223
- toSeq(): IndexedSeq<T>;
2224
2472
 
2225
2473
  /**
2226
- * If this is an iterable of [key, value] entry tuples, it will return a
2227
- * KeyedSeq of those entries.
2474
+ * `Collection` which represents ordered indexed values.
2228
2475
  */
2229
- fromEntrySeq(): KeyedSeq<any, any>;
2230
-
2476
+ export module Indexed {}
2231
2477
 
2232
- // Combination
2478
+ export interface Indexed<T> extends Collection<number, T>, Iterable.Indexed<T> {
2233
2479
 
2234
- /**
2235
- * Returns an Iterable of the same type with `separator` between each item
2236
- * in this Iterable.
2237
- */
2238
- interpose(separator: T): /*this*/IndexedIterable<T>;
2239
-
2240
- /**
2241
- * Returns an Iterable of the same type with the provided `iterables`
2242
- * interleaved into this iterable.
2243
- *
2244
- * The resulting Iterable includes the first item from each, then the
2245
- * second from each, etc.
2246
- *
2247
- * I.Seq.of(1,2,3).interleave(I.Seq.of('A','B','C'))
2248
- * // Seq [ 1, 'A', 2, 'B', 3, 'C' ]
2249
- *
2250
- * The shortest Iterable stops interleave.
2251
- *
2252
- * I.Seq.of(1,2,3).interleave(
2253
- * I.Seq.of('A','B'),
2254
- * I.Seq.of('X','Y','Z')
2255
- * )
2256
- * // Seq [ 1, 'A', 'X', 2, 'B', 'Y' ]
2257
- */
2258
- interleave(...iterables: Array<Iterable<any, T>>): /*this*/IndexedIterable<T>;
2259
-
2260
- /**
2261
- * Splice returns a new indexed Iterable by replacing a region of this
2262
- * Iterable with new values. If values are not provided, it only skips the
2263
- * region to be removed.
2264
- *
2265
- * `index` may be a negative number, which indexes back from the end of the
2266
- * Iterable. `s.splice(-2)` splices after the second to last item.
2267
- *
2268
- * Seq(['a','b','c','d']).splice(1, 2, 'q', 'r', 's')
2269
- * // Seq ['a', 'q', 'r', 's', 'd']
2270
- *
2271
- */
2272
- splice(
2273
- index: number,
2274
- removeNum: number,
2275
- ...values: /*Array<IndexedIterable<T> | T>*/any[]
2276
- ): /*this*/IndexedIterable<T>;
2480
+ /**
2481
+ * Returns Seq.Indexed.
2482
+ * @override
2483
+ */
2484
+ toSeq(): Seq.Indexed<T>;
2485
+ }
2277
2486
 
2278
- /**
2279
- * Returns an Iterable of the same type "zipped" with the provided
2280
- * iterables.
2281
- *
2282
- * Like `zipWith`, but using the default `zipper`: creating an `Array`.
2283
- *
2284
- * var a = Seq.of(1, 2, 3);
2285
- * var b = Seq.of(4, 5, 6);
2286
- * var c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2287
- *
2288
- */
2289
- zip(...iterables: Array<Iterable<any, any>>): /*this*/IndexedIterable<any>;
2290
2487
 
2291
2488
  /**
2292
- * Returns an Iterable of the same type "zipped" with the provided
2293
- * iterables by using a custom `zipper` function.
2294
- *
2295
- * var a = Seq.of(1, 2, 3);
2296
- * var b = Seq.of(4, 5, 6);
2297
- * var c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2489
+ * `Collection` which represents values, unassociated with keys or indices.
2298
2490
  *
2491
+ * `Collection.Set` implementations should guarantee value uniqueness.
2299
2492
  */
2300
- zipWith<U, Z>(
2301
- zipper: (value: T, otherValue: U) => Z,
2302
- otherIterable: Iterable<any, U>
2303
- ): IndexedIterable<Z>;
2304
- zipWith<U, V, Z>(
2305
- zipper: (value: T, otherValue: U, thirdValue: V) => Z,
2306
- otherIterable: Iterable<any, U>,
2307
- thirdIterable: Iterable<any, V>
2308
- ): IndexedIterable<Z>;
2309
- zipWith<Z>(
2310
- zipper: (...any: Array<any>) => Z,
2311
- ...iterables: Array<Iterable<any, any>>
2312
- ): IndexedIterable<Z>;
2493
+ export module Set {}
2313
2494
 
2495
+ export interface Set<T> extends Collection<T, T>, Iterable.Set<T> {
2314
2496
 
2315
- // Search for value
2316
-
2317
- /**
2318
- * Returns the first index at which a given value can be found in the
2319
- * Iterable, or -1 if it is not present.
2320
- */
2321
- indexOf(searchValue: T): number;
2322
-
2323
- /**
2324
- * Returns the last index at which a given value can be found in the
2325
- * Iterable, or -1 if it is not present.
2326
- */
2327
- lastIndexOf(searchValue: T): number;
2328
-
2329
- /**
2330
- * Returns the first index in the Iterable where a value satisfies the
2331
- * provided predicate function. Otherwise -1 is returned.
2332
- */
2333
- findIndex(
2334
- predicate: (value?: T, index?: number, iter?: /*this*/IndexedIterable<T>) => boolean,
2335
- context?: any
2336
- ): number;
2337
-
2338
- /**
2339
- * Returns the last index in the Iterable where a value satisfies the
2340
- * provided predicate function. Otherwise -1 is returned.
2341
- */
2342
- findLastIndex(
2343
- predicate: (value?: T, index?: number, iter?: /*this*/IndexedIterable<T>) => boolean,
2344
- context?: any
2345
- ): number;
2346
- }
2347
-
2348
-
2349
- /**
2350
- * Set Iterables only represent values. They have no associated keys or
2351
- * indices. Duplicate values are possible in SetSeqs, however the
2352
- * concrete `Set` does not allow duplicate values.
2353
- *
2354
- * Iterable methods on SetIterable such as `map` and `forEach` will provide
2355
- * the value as both the first and second arguments to the provided function.
2356
- *
2357
- * var seq = SetSeq.of('A', 'B', 'C');
2358
- * assert.equal(seq.every((v, k) => v === k), true);
2359
- *
2360
- */
2361
- export module SetIterable {}
2362
-
2363
- /**
2364
- * Similar to `Iterable()`, but always returns a SetIterable.
2365
- */
2366
- export function SetIterable<T>(iter: SetIterable<T>): SetIterable<T>;
2367
- export function SetIterable<T>(iter: IndexedIterable<T>): SetIterable<T>;
2368
- export function SetIterable<K, V>(iter: KeyedIterable<K, V>): SetIterable</*[K,V]*/any>;
2369
- export function SetIterable<T>(array: Array<T>): SetIterable<T>;
2370
- export function SetIterable<T>(iterator: Iterator<T>): SetIterable<T>;
2371
- export function SetIterable<T>(iterable: /*Iterable<T>*/Object): SetIterable<T>;
2372
-
2373
- export interface SetIterable<T> extends Iterable<T, T> {
2497
+ /**
2498
+ * Returns Seq.Set.
2499
+ * @override
2500
+ */
2501
+ toSeq(): Seq.Set<T>;
2502
+ }
2374
2503
 
2375
- /**
2376
- * Returns SetSeq.
2377
- * @override
2378
- */
2379
- toSeq(): SetSeq<T>;
2380
2504
  }
2381
2505
 
2382
-
2383
- /**
2384
- * Collection is the abstract base class for concrete data structures. It
2385
- * cannot be constructed directly.
2386
- *
2387
- * Implementations should extend one of the subclasses, `KeyedCollection`,
2388
- * `IndexedCollection`, or `SetCollection`.
2389
- */
2390
- export module Collection {}
2391
-
2392
2506
  export interface Collection<K, V> extends Iterable<K, V> {
2393
2507
 
2394
2508
  /**
@@ -2398,53 +2512,6 @@ declare module 'immutable' {
2398
2512
  }
2399
2513
 
2400
2514
 
2401
- /**
2402
- * `Collection` which represents key-value pairs.
2403
- */
2404
- export module KeyedCollection {}
2405
-
2406
- export interface KeyedCollection<K, V> extends Collection<K, V>, KeyedIterable<K, V> {
2407
-
2408
- /**
2409
- * Returns KeyedSeq.
2410
- * @override
2411
- */
2412
- toSeq(): KeyedSeq<K, V>;
2413
- }
2414
-
2415
-
2416
- /**
2417
- * `Collection` which represents ordered indexed values.
2418
- */
2419
- export module IndexedCollection {}
2420
-
2421
- export interface IndexedCollection<T> extends Collection<number, T>, IndexedIterable<T> {
2422
-
2423
- /**
2424
- * Returns IndexedSeq.
2425
- * @override
2426
- */
2427
- toSeq(): IndexedSeq<T>;
2428
- }
2429
-
2430
-
2431
- /**
2432
- * `Collection` which represents values, unassociated with keys or indices.
2433
- *
2434
- * `SetCollection` implementations should guarantee value uniqueness.
2435
- */
2436
- export module SetCollection {}
2437
-
2438
- export interface SetCollection<T> extends Collection<T, T>, SetIterable<T> {
2439
-
2440
- /**
2441
- * Returns SetSeq.
2442
- * @override
2443
- */
2444
- toSeq(): SetSeq<T>;
2445
- }
2446
-
2447
-
2448
2515
  /**
2449
2516
  * ES6 Iterator.
2450
2517
  *
@@ -2458,3 +2525,7 @@ declare module 'immutable' {
2458
2525
  }
2459
2526
 
2460
2527
  }
2528
+
2529
+ declare module "immutable" {
2530
+ export = Immutable
2531
+ }