immutable 3.7.5 → 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.
@@ -121,7 +121,7 @@ declare module Immutable {
121
121
  *
122
122
  * Unlike a JavaScript Array, there is no distinction between an
123
123
  * "unset" index and an index set to `undefined`. `List#forEach` visits all
124
- * 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.
125
125
  */
126
126
  export module List {
127
127
 
@@ -141,15 +141,15 @@ declare module Immutable {
141
141
  * iterable-like.
142
142
  */
143
143
  export function List<T>(): List<T>;
144
- export function List<T>(iter: IndexedIterable<T>): List<T>;
145
- export function List<T>(iter: SetIterable<T>): List<T>;
146
- 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>;
147
147
  export function List<T>(array: Array<T>): List<T>;
148
148
  export function List<T>(iterator: Iterator<T>): List<T>;
149
149
  export function List<T>(iterable: /*Iterable<T>*/Object): List<T>;
150
150
 
151
151
 
152
- export interface List<T> extends IndexedCollection<T> {
152
+ export interface List<T> extends Collection.Indexed<T> {
153
153
 
154
154
  // Persistent changes
155
155
 
@@ -181,6 +181,14 @@ declare module Immutable {
181
181
  delete(index: number): List<T>;
182
182
  remove(index: number): List<T>;
183
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
+
184
192
  /**
185
193
  * Returns a new List with 0 size and no values.
186
194
  */
@@ -236,7 +244,7 @@ declare module Immutable {
236
244
  /**
237
245
  * @see `Map#merge`
238
246
  */
239
- merge(...iterables: IndexedIterable<T>[]): List<T>;
247
+ merge(...iterables: Iterable.Indexed<T>[]): List<T>;
240
248
  merge(...iterables: Array<T>[]): List<T>;
241
249
 
242
250
  /**
@@ -244,7 +252,7 @@ declare module Immutable {
244
252
  */
245
253
  mergeWith(
246
254
  merger: (previous?: T, next?: T, key?: number) => T,
247
- ...iterables: IndexedIterable<T>[]
255
+ ...iterables: Iterable.Indexed<T>[]
248
256
  ): List<T>;
249
257
  mergeWith(
250
258
  merger: (previous?: T, next?: T, key?: number) => T,
@@ -254,7 +262,7 @@ declare module Immutable {
254
262
  /**
255
263
  * @see `Map#mergeDeep`
256
264
  */
257
- mergeDeep(...iterables: IndexedIterable<T>[]): List<T>;
265
+ mergeDeep(...iterables: Iterable.Indexed<T>[]): List<T>;
258
266
  mergeDeep(...iterables: Array<T>[]): List<T>;
259
267
 
260
268
  /**
@@ -262,7 +270,7 @@ declare module Immutable {
262
270
  */
263
271
  mergeDeepWith(
264
272
  merger: (previous?: T, next?: T, key?: number) => T,
265
- ...iterables: IndexedIterable<T>[]
273
+ ...iterables: Iterable.Indexed<T>[]
266
274
  ): List<T>;
267
275
  mergeDeepWith(
268
276
  merger: (previous?: T, next?: T, key?: number) => T,
@@ -332,11 +340,11 @@ declare module Immutable {
332
340
  */
333
341
  mergeIn(
334
342
  keyPath: Iterable<any, any>,
335
- ...iterables: IndexedIterable<T>[]
343
+ ...iterables: Iterable.Indexed<T>[]
336
344
  ): List<T>;
337
345
  mergeIn(
338
346
  keyPath: Array<any>,
339
- ...iterables: IndexedIterable<T>[]
347
+ ...iterables: Iterable.Indexed<T>[]
340
348
  ): List<T>;
341
349
  mergeIn(
342
350
  keyPath: Array<any>,
@@ -348,11 +356,11 @@ declare module Immutable {
348
356
  */
349
357
  mergeDeepIn(
350
358
  keyPath: Iterable<any, any>,
351
- ...iterables: IndexedIterable<T>[]
359
+ ...iterables: Iterable.Indexed<T>[]
352
360
  ): List<T>;
353
361
  mergeDeepIn(
354
362
  keyPath: Array<any>,
355
- ...iterables: IndexedIterable<T>[]
363
+ ...iterables: Iterable.Indexed<T>[]
356
364
  ): List<T>;
357
365
  mergeDeepIn(
358
366
  keyPath: Array<any>,
@@ -384,7 +392,7 @@ declare module Immutable {
384
392
 
385
393
 
386
394
  /**
387
- * Immutable Map is an unordered KeyedIterable of (key, value) pairs with
395
+ * Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with
388
396
  * `O(log32 N)` gets and `O(log32 N)` persistent sets.
389
397
  *
390
398
  * Iteration order of a Map is undefined, however is stable. Multiple
@@ -417,7 +425,7 @@ declare module Immutable {
417
425
  /**
418
426
  * Creates a new Immutable Map.
419
427
  *
420
- * 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
421
429
  * JavaScript Object or expects an Iterable of [K, V] tuple entries.
422
430
  *
423
431
  * var newMap = Map({key: "value"});
@@ -443,14 +451,14 @@ declare module Immutable {
443
451
  * not altered.
444
452
  */
445
453
  export function Map<K, V>(): Map<K, V>;
446
- 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>;
447
455
  export function Map<K, V>(iter: Iterable<any, /*[K,V]*/Array<any>>): Map<K, V>;
448
456
  export function Map<K, V>(array: Array</*[K,V]*/Array<any>>): Map<K, V>;
449
457
  export function Map<V>(obj: {[key: string]: V}): Map<string, V>;
450
458
  export function Map<K, V>(iterator: Iterator</*[K,V]*/Array<any>>): Map<K, V>;
451
459
  export function Map<K, V>(iterable: /*Iterable<[K,V]>*/Object): Map<K, V>;
452
460
 
453
- export interface Map<K, V> extends KeyedCollection<K, V> {
461
+ export interface Map<K, V> extends Collection.Keyed<K, V> {
454
462
 
455
463
  // Persistent changes
456
464
 
@@ -739,7 +747,7 @@ declare module Immutable {
739
747
  /**
740
748
  * Creates a new Immutable OrderedMap.
741
749
  *
742
- * 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
743
751
  * JavaScript Object or expects an Iterable of [K, V] tuple entries.
744
752
  *
745
753
  * The iteration order of key-value pairs provided to this constructor will
@@ -750,7 +758,7 @@ declare module Immutable {
750
758
  *
751
759
  */
752
760
  export function OrderedMap<K, V>(): OrderedMap<K, V>;
753
- 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>;
754
762
  export function OrderedMap<K, V>(iter: Iterable<any, /*[K,V]*/Array<any>>): OrderedMap<K, V>;
755
763
  export function OrderedMap<K, V>(array: Array</*[K,V]*/Array<any>>): OrderedMap<K, V>;
756
764
  export function OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V>;
@@ -796,14 +804,14 @@ declare module Immutable {
796
804
  * iterable-like.
797
805
  */
798
806
  export function Set<T>(): Set<T>;
799
- export function Set<T>(iter: SetIterable<T>): Set<T>;
800
- export function Set<T>(iter: IndexedIterable<T>): Set<T>;
801
- 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>;
802
810
  export function Set<T>(array: Array<T>): Set<T>;
803
811
  export function Set<T>(iterator: Iterator<T>): Set<T>;
804
812
  export function Set<T>(iterable: /*Iterable<T>*/Object): Set<T>;
805
813
 
806
- export interface Set<T> extends SetCollection<T> {
814
+ export interface Set<T> extends Collection.Set<T> {
807
815
 
808
816
  // Persistent changes
809
817
 
@@ -908,9 +916,9 @@ declare module Immutable {
908
916
  * iterable-like.
909
917
  */
910
918
  export function OrderedSet<T>(): OrderedSet<T>;
911
- export function OrderedSet<T>(iter: SetIterable<T>): OrderedSet<T>;
912
- export function OrderedSet<T>(iter: IndexedIterable<T>): OrderedSet<T>;
913
- 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>;
914
922
  export function OrderedSet<T>(array: Array<T>): OrderedSet<T>;
915
923
  export function OrderedSet<T>(iterator: Iterator<T>): OrderedSet<T>;
916
924
  export function OrderedSet<T>(iterable: /*Iterable<T>*/Object): OrderedSet<T>;
@@ -952,14 +960,14 @@ declare module Immutable {
952
960
  * resulting `Stack`.
953
961
  */
954
962
  export function Stack<T>(): Stack<T>;
955
- export function Stack<T>(iter: IndexedIterable<T>): Stack<T>;
956
- export function Stack<T>(iter: SetIterable<T>): Stack<T>;
957
- 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>;
958
966
  export function Stack<T>(array: Array<T>): Stack<T>;
959
967
  export function Stack<T>(iterator: Iterator<T>): Stack<T>;
960
968
  export function Stack<T>(iterable: /*Iterable<T>*/Object): Stack<T>;
961
969
 
962
- export interface Stack<T> extends IndexedCollection<T> {
970
+ export interface Stack<T> extends Collection.Indexed<T> {
963
971
 
964
972
  // Reading values
965
973
 
@@ -1040,7 +1048,7 @@ declare module Immutable {
1040
1048
 
1041
1049
 
1042
1050
  /**
1043
- * Returns a IndexedSeq of numbers from `start` (inclusive) to `end`
1051
+ * Returns a Seq.Indexed of numbers from `start` (inclusive) to `end`
1044
1052
  * (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to
1045
1053
  * infinity. When `start` is equal to `end`, returns empty range.
1046
1054
  *
@@ -1052,18 +1060,18 @@ declare module Immutable {
1052
1060
  * Range(30,30,5) // []
1053
1061
  *
1054
1062
  */
1055
- export function Range(start?: number, end?: number, step?: number): IndexedSeq<number>;
1063
+ export function Range(start?: number, end?: number, step?: number): Seq.Indexed<number>;
1056
1064
 
1057
1065
 
1058
1066
  /**
1059
- * Returns a IndexedSeq of `value` repeated `times` times. When `times` is
1067
+ * Returns a Seq.Indexed of `value` repeated `times` times. When `times` is
1060
1068
  * not defined, returns an infinite `Seq` of `value`.
1061
1069
  *
1062
1070
  * Repeat('foo') // ['foo','foo','foo',...]
1063
1071
  * Repeat('bar',4) // ['bar','bar','bar','bar']
1064
1072
  *
1065
1073
  */
1066
- export function Repeat<T>(value: T, times?: number): IndexedSeq<T>;
1074
+ export function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
1067
1075
 
1068
1076
 
1069
1077
  /**
@@ -1085,7 +1093,9 @@ declare module Immutable {
1085
1093
  * myRecordWithoutB.size // 2
1086
1094
  *
1087
1095
  * Values provided to the constructor not found in the Record type will
1088
- * 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.
1089
1099
  *
1090
1100
  * var myRecord = new ABRecord({b:3, x:10})
1091
1101
  * myRecord.get('x') // undefined
@@ -1153,7 +1163,7 @@ declare module Immutable {
1153
1163
  *
1154
1164
  * Once the Seq is used, it performs only the work necessary. In this
1155
1165
  * example, no intermediate data structures are ever created, filter is only
1156
- * called three times, and map is only called twice:
1166
+ * called three times, and map is only called once:
1157
1167
  *
1158
1168
  * console.log(evenSquares.get(1)); // 9
1159
1169
  *
@@ -1188,9 +1198,102 @@ declare module Immutable {
1188
1198
  function isSeq(maybeSeq: any): boolean;
1189
1199
 
1190
1200
  /**
1191
- * 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.
1246
+ */
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.
1192
1280
  */
1193
- function of<T>(...values: T[]): IndexedSeq<T>;
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
+
1194
1297
  }
1195
1298
 
1196
1299
  /**
@@ -1200,19 +1303,19 @@ declare module Immutable {
1200
1303
  *
1201
1304
  * * If a `Seq`, that same `Seq`.
1202
1305
  * * If an `Iterable`, a `Seq` of the same kind (Keyed, Indexed, or Set).
1203
- * * If an Array-like, an `IndexedSeq`.
1204
- * * If an Object with an Iterator, an `IndexedSeq`.
1205
- * * If an Iterator, an `IndexedSeq`.
1206
- * * 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`.
1207
1310
  *
1208
1311
  */
1209
1312
  export function Seq<K, V>(): Seq<K, V>;
1210
1313
  export function Seq<K, V>(seq: Seq<K, V>): Seq<K, V>;
1211
1314
  export function Seq<K, V>(iterable: Iterable<K, V>): Seq<K, V>;
1212
- export function Seq<T>(array: Array<T>): IndexedSeq<T>;
1213
- export function Seq<V>(obj: {[key: string]: V}): KeyedSeq<string, V>;
1214
- export function Seq<T>(iterator: Iterator<T>): IndexedSeq<T>;
1215
- 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>;
1216
1319
 
1217
1320
  export interface Seq<K, V> extends Iterable<K, V> {
1218
1321
 
@@ -1254,98 +1357,6 @@ declare module Immutable {
1254
1357
  cacheResult(): /*this*/Seq<K, V>;
1255
1358
  }
1256
1359
 
1257
-
1258
- /**
1259
- * `Seq` which represents key-value pairs.
1260
- */
1261
- export module KeyedSeq {}
1262
-
1263
- /**
1264
- * Always returns a KeyedSeq, if input is not keyed, expects an
1265
- * iterable of [K, V] tuples.
1266
- */
1267
- export function KeyedSeq<K, V>(): KeyedSeq<K, V>;
1268
- export function KeyedSeq<K, V>(seq: KeyedIterable<K, V>): KeyedSeq<K, V>;
1269
- export function KeyedSeq<K, V>(seq: Iterable<any, /*[K,V]*/any>): KeyedSeq<K, V>;
1270
- export function KeyedSeq<K, V>(array: Array</*[K,V]*/any>): KeyedSeq<K, V>;
1271
- export function KeyedSeq<V>(obj: {[key: string]: V}): KeyedSeq<string, V>;
1272
- export function KeyedSeq<K, V>(iterator: Iterator</*[K,V]*/any>): KeyedSeq<K, V>;
1273
- export function KeyedSeq<K, V>(iterable: /*Iterable<[K,V]>*/Object): KeyedSeq<K, V>;
1274
-
1275
- export interface KeyedSeq<K, V> extends Seq<K, V>, KeyedIterable<K, V> {
1276
-
1277
- /**
1278
- * Returns itself
1279
- */
1280
- toSeq(): /*this*/KeyedSeq<K, V>
1281
- }
1282
-
1283
-
1284
- /**
1285
- * `Seq` which represents an ordered indexed list of values.
1286
- */
1287
- export module IndexedSeq {
1288
-
1289
- /**
1290
- * Provides an IndexedSeq of the values provided.
1291
- */
1292
- function of<T>(...values: T[]): IndexedSeq<T>;
1293
- }
1294
-
1295
- /**
1296
- * Always returns IndexedSeq, discarding associated keys and
1297
- * supplying incrementing indices.
1298
- */
1299
- export function IndexedSeq<T>(): IndexedSeq<T>;
1300
- export function IndexedSeq<T>(seq: IndexedIterable<T>): IndexedSeq<T>;
1301
- export function IndexedSeq<T>(seq: SetIterable<T>): IndexedSeq<T>;
1302
- export function IndexedSeq<K, V>(seq: KeyedIterable<K, V>): IndexedSeq</*[K,V]*/any>;
1303
- export function IndexedSeq<T>(array: Array<T>): IndexedSeq<T>;
1304
- export function IndexedSeq<T>(iterator: Iterator<T>): IndexedSeq<T>;
1305
- export function IndexedSeq<T>(iterable: /*Iterable<T>*/Object): IndexedSeq<T>;
1306
-
1307
- export interface IndexedSeq<T> extends Seq<number, T>, IndexedIterable<T> {
1308
-
1309
- /**
1310
- * Returns itself
1311
- */
1312
- toSeq(): /*this*/IndexedSeq<T>
1313
- }
1314
-
1315
- /**
1316
- * `Seq` which represents a set of values.
1317
- *
1318
- * Because `Seq` are often lazy, `SetSeq` does not provide the same guarantee
1319
- * of value uniqueness as the concrete `Set`.
1320
- */
1321
- export module SetSeq {
1322
-
1323
- /**
1324
- * Returns a SetSeq of the provided values
1325
- */
1326
- function of<T>(...values: T[]): SetSeq<T>;
1327
- }
1328
-
1329
- /**
1330
- * Always returns a SetSeq, discarding associated indices or keys.
1331
- */
1332
- export function SetSeq<T>(): SetSeq<T>;
1333
- export function SetSeq<T>(seq: SetIterable<T>): SetSeq<T>;
1334
- export function SetSeq<T>(seq: IndexedIterable<T>): SetSeq<T>;
1335
- export function SetSeq<K, V>(seq: KeyedIterable<K, V>): SetSeq</*[K,V]*/any>;
1336
- export function SetSeq<T>(array: Array<T>): SetSeq<T>;
1337
- export function SetSeq<T>(iterator: Iterator<T>): SetSeq<T>;
1338
- export function SetSeq<T>(iterable: /*Iterable<T>*/Object): SetSeq<T>;
1339
-
1340
- export interface SetSeq<T> extends Seq<T, T>, SetIterable<T> {
1341
-
1342
- /**
1343
- * Returns itself
1344
- */
1345
- toSeq(): /*this*/SetSeq<T>
1346
- }
1347
-
1348
-
1349
1360
  /**
1350
1361
  * The `Iterable` is a set of (key, value) entries which can be iterated, and
1351
1362
  * is the base class for all collections in `immutable`, allowing them to
@@ -1361,12 +1372,12 @@ declare module Immutable {
1361
1372
  function isIterable(maybeIterable: any): boolean;
1362
1373
 
1363
1374
  /**
1364
- * True if `maybeKeyed` is a KeyedIterable, or any of its subclasses.
1375
+ * True if `maybeKeyed` is an Iterable.Keyed, or any of its subclasses.
1365
1376
  */
1366
1377
  function isKeyed(maybeKeyed: any): boolean;
1367
1378
 
1368
1379
  /**
1369
- * True if `maybeIndexed` is a IndexedIterable, or any of its subclasses.
1380
+ * True if `maybeIndexed` is a Iterable.Indexed, or any of its subclasses.
1370
1381
  */
1371
1382
  function isIndexed(maybeIndexed: any): boolean;
1372
1383
 
@@ -1377,9 +1388,324 @@ declare module Immutable {
1377
1388
 
1378
1389
  /**
1379
1390
  * True if `maybeOrdered` is an Iterable where iteration order is well
1380
- * defined. True for IndexedIterable as well as OrderedMap and OrderedSet.
1391
+ * defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.
1381
1392
  */
1382
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
+
1383
1709
  }
1384
1710
 
1385
1711
  /**
@@ -1388,21 +1714,21 @@ declare module Immutable {
1388
1714
  * The type of Iterable created is based on the input.
1389
1715
  *
1390
1716
  * * If an `Iterable`, that same `Iterable`.
1391
- * * If an Array-like, an `IndexedIterable`.
1392
- * * If an Object with an Iterator, an `IndexedIterable`.
1393
- * * If an Iterator, an `IndexedIterable`.
1394
- * * 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`.
1395
1721
  *
1396
1722
  * This methods forces the conversion of Objects and Strings to Iterables.
1397
1723
  * If you want to ensure that a Iterable of one item is returned, use
1398
1724
  * `Seq.of`.
1399
1725
  */
1400
1726
  export function Iterable<K, V>(iterable: Iterable<K, V>): Iterable<K, V>;
1401
- export function Iterable<T>(array: Array<T>): IndexedIterable<T>;
1402
- export function Iterable<V>(obj: {[key: string]: V}): KeyedIterable<string, V>;
1403
- export function Iterable<T>(iterator: Iterator<T>): IndexedIterable<T>;
1404
- export function Iterable<T>(iterable: /*ES6Iterable<T>*/Object): IndexedIterable<T>;
1405
- 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>;
1406
1732
 
1407
1733
  export interface Iterable<K, V> {
1408
1734
 
@@ -1496,8 +1822,8 @@ declare module Immutable {
1496
1822
  /**
1497
1823
  * Deeply converts this Iterable to equivalent JS.
1498
1824
  *
1499
- * `IndexedIterables`, and `SetIterables` become Arrays, while
1500
- * `KeyedIterables` become Objects.
1825
+ * `Iterable.Indexeds`, and `Iterable.Sets` become Arrays, while
1826
+ * `Iterable.Keyeds` become Objects.
1501
1827
  *
1502
1828
  * @alias toJSON
1503
1829
  */
@@ -1579,10 +1905,10 @@ declare module Immutable {
1579
1905
  toSeq(): Seq<K, V>;
1580
1906
 
1581
1907
  /**
1582
- * 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.
1583
1909
  *
1584
1910
  * This is useful if you want to operate on an
1585
- * IndexedIterable and preserve the [index, value] pairs.
1911
+ * Iterable.Indexed and preserve the [index, value] pairs.
1586
1912
  *
1587
1913
  * The returned Seq will have identical iteration order as
1588
1914
  * this Iterable.
@@ -1595,17 +1921,17 @@ declare module Immutable {
1595
1921
  * keyedSeq.filter(v => v === 'B').toString() // Seq { 1: 'B' }
1596
1922
  *
1597
1923
  */
1598
- toKeyedSeq(): KeyedSeq<K, V>;
1924
+ toKeyedSeq(): Seq.Keyed<K, V>;
1599
1925
 
1600
1926
  /**
1601
- * Returns an IndexedSeq of the values of this Iterable, discarding keys.
1927
+ * Returns an Seq.Indexed of the values of this Iterable, discarding keys.
1602
1928
  */
1603
- toIndexedSeq(): IndexedSeq<V>;
1929
+ toIndexedSeq(): Seq.Indexed<V>;
1604
1930
 
1605
1931
  /**
1606
- * Returns a SetSeq of the values of this Iterable, discarding keys.
1932
+ * Returns a Seq.Set of the values of this Iterable, discarding keys.
1607
1933
  */
1608
- toSetSeq(): SetSeq<V>;
1934
+ toSetSeq(): Seq.Set<V>;
1609
1935
 
1610
1936
 
1611
1937
  // Iterators
@@ -1629,20 +1955,20 @@ declare module Immutable {
1629
1955
  // Iterables (Seq)
1630
1956
 
1631
1957
  /**
1632
- * Returns a new IndexedSeq of the keys of this Iterable,
1958
+ * Returns a new Seq.Indexed of the keys of this Iterable,
1633
1959
  * discarding values.
1634
1960
  */
1635
- keySeq(): IndexedSeq<K>;
1961
+ keySeq(): Seq.Indexed<K>;
1636
1962
 
1637
1963
  /**
1638
- * Returns an IndexedSeq of the values of this Iterable, discarding keys.
1964
+ * Returns an Seq.Indexed of the values of this Iterable, discarding keys.
1639
1965
  */
1640
- valueSeq(): IndexedSeq<V>;
1966
+ valueSeq(): Seq.Indexed<V>;
1641
1967
 
1642
1968
  /**
1643
- * Returns a new IndexedSeq of [key, value] tuples.
1969
+ * Returns a new Seq.Indexed of [key, value] tuples.
1644
1970
  */
1645
- entrySeq(): IndexedSeq</*(K, V)*/Array<any>>;
1971
+ entrySeq(): Seq.Indexed</*(K, V)*/Array<any>>;
1646
1972
 
1647
1973
 
1648
1974
  // Sequence algorithms
@@ -1723,7 +2049,7 @@ declare module Immutable {
1723
2049
  ): /*this*/Iterable<K, V>;
1724
2050
 
1725
2051
  /**
1726
- * Returns a `KeyedIterable` of `KeyedIterables`, grouped by the return
2052
+ * Returns a `Iterable.Keyed` of `Iterable.Keyeds`, grouped by the return
1727
2053
  * value of the `grouper` function.
1728
2054
  *
1729
2055
  * Note: This is always an eager operation.
@@ -1731,7 +2057,7 @@ declare module Immutable {
1731
2057
  groupBy<G>(
1732
2058
  grouper: (value?: V, key?: K, iter?: /*this*/Iterable<K, V>) => G,
1733
2059
  context?: any
1734
- ): /*Map*/KeyedSeq<G, /*this*/Iterable<K, V>>;
2060
+ ): /*Map*/Seq.Keyed<G, /*this*/Iterable<K, V>>;
1735
2061
 
1736
2062
 
1737
2063
  // Side effects
@@ -1979,7 +2305,7 @@ declare module Immutable {
1979
2305
  ): number;
1980
2306
 
1981
2307
  /**
1982
- * Returns a `KeyedSeq` of counts, grouped by the return value of
2308
+ * Returns a `Seq.Keyed` of counts, grouped by the return value of
1983
2309
  * the `grouper` function.
1984
2310
  *
1985
2311
  * Note: This is not a lazy operation.
@@ -2120,328 +2446,63 @@ declare module Immutable {
2120
2446
 
2121
2447
 
2122
2448
  /**
2123
- * Keyed Iterables have discrete keys tied to each value.
2124
- *
2125
- * When iterating `KeyedIterable`, each iteration will yield a `[K, V]` tuple,
2126
- * in other words, `Iterable#entries` is the default iterator for Keyed
2127
- * Iterables.
2128
- */
2129
- export module KeyedIterable {}
2130
-
2131
- /**
2132
- * Creates a KeyedIterable
2449
+ * Collection is the abstract base class for concrete data structures. It
2450
+ * cannot be constructed directly.
2133
2451
  *
2134
- * Similar to `Iterable()`, however it expects iterable-likes of [K, V]
2135
- * tuples if not constructed from a KeyedIterable or JS Object.
2136
- */
2137
- export function KeyedIterable<K, V>(iter: KeyedIterable<K, V>): KeyedIterable<K, V>;
2138
- export function KeyedIterable<K, V>(iter: Iterable<any, /*[K,V]*/any>): KeyedIterable<K, V>;
2139
- export function KeyedIterable<K, V>(array: Array</*[K,V]*/any>): KeyedIterable<K, V>;
2140
- export function KeyedIterable<V>(obj: {[key: string]: V}): KeyedIterable<string, V>;
2141
- export function KeyedIterable<K, V>(iterator: Iterator</*[K,V]*/any>): KeyedIterable<K, V>;
2142
- export function KeyedIterable<K, V>(iterable: /*Iterable<[K,V]>*/Object): KeyedIterable<K, V>;
2143
-
2144
- export interface KeyedIterable<K, V> extends Iterable<K, V> {
2145
-
2146
- /**
2147
- * Returns KeyedSeq.
2148
- * @override
2149
- */
2150
- toSeq(): KeyedSeq<K, V>;
2151
-
2152
-
2153
- // Sequence functions
2154
-
2155
- /**
2156
- * Returns a new KeyedIterable of the same type where the keys and values
2157
- * have been flipped.
2158
- *
2159
- * Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }
2160
- *
2161
- */
2162
- flip(): /*this*/KeyedIterable<V, K>;
2163
-
2164
- /**
2165
- * Returns a new KeyedIterable of the same type with keys passed through a
2166
- * `mapper` function.
2167
- *
2168
- * Seq({ a: 1, b: 2 })
2169
- * .mapKeys(x => x.toUpperCase())
2170
- * // Seq { A: 1, B: 2 }
2171
- *
2172
- */
2173
- mapKeys<M>(
2174
- mapper: (key?: K, value?: V, iter?: /*this*/KeyedIterable<K, V>) => M,
2175
- context?: any
2176
- ): /*this*/KeyedIterable<M, V>;
2177
-
2178
- /**
2179
- * Returns a new KeyedIterable of the same type with entries
2180
- * ([key, value] tuples) passed through a `mapper` function.
2181
- *
2182
- * Seq({ a: 1, b: 2 })
2183
- * .mapEntries(([k, v]) => [k.toUpperCase(), v * 2])
2184
- * // Seq { A: 2, B: 4 }
2185
- *
2186
- */
2187
- mapEntries<KM, VM>(
2188
- mapper: (
2189
- entry?: /*(K, V)*/Array<any>,
2190
- index?: number,
2191
- iter?: /*this*/KeyedIterable<K, V>
2192
- ) => /*[KM, VM]*/Array<any>,
2193
- context?: any
2194
- ): /*this*/KeyedIterable<KM, VM>;
2195
-
2196
-
2197
- // Search for value
2198
-
2199
- /**
2200
- * Returns the key associated with the search value, or undefined.
2201
- */
2202
- keyOf(searchValue: V): K;
2203
-
2204
- /**
2205
- * Returns the last key associated with the search value, or undefined.
2206
- */
2207
- lastKeyOf(searchValue: V): K;
2208
-
2209
- /**
2210
- * Returns the key for which the `predicate` returns true.
2211
- */
2212
- findKey(
2213
- predicate: (value?: V, key?: K, iter?: /*this*/KeyedIterable<K, V>) => boolean,
2214
- context?: any
2215
- ): K;
2216
-
2217
- /**
2218
- * Returns the last key for which the `predicate` returns true.
2219
- *
2220
- * Note: `predicate` will be called for each entry in reverse.
2221
- */
2222
- findLastKey(
2223
- predicate: (value?: V, key?: K, iter?: /*this*/KeyedIterable<K, V>) => boolean,
2224
- context?: any
2225
- ): K;
2226
- }
2227
-
2228
-
2229
- /**
2230
- * Indexed Iterables have incrementing numeric keys. They exhibit
2231
- * slightly different behavior than `KeyedIterable` for some methods in order
2232
- * to better mirror the behavior of JavaScript's `Array`, and add methods
2233
- * which do not make sense on non-indexed Iterables such as `indexOf`.
2234
- *
2235
- * Unlike JavaScript arrays, `IndexedIterable`s are always dense. "Unset"
2236
- * indices and `undefined` indices are indistinguishable, and all indices from
2237
- * 0 to `size` are visited when iterated.
2238
- *
2239
- * All IndexedIterable methods return re-indexed Iterables. In other words,
2240
- * indices always start at 0 and increment until size. If you wish to
2241
- * preserve indices, using them as keys, convert to a KeyedIterable by calling
2242
- * `toKeyedSeq`.
2452
+ * Implementations should extend one of the subclasses, `Collection.Keyed`,
2453
+ * `Collection.Indexed`, or `Collection.Set`.
2243
2454
  */
2244
- export module IndexedIterable {}
2245
-
2246
- /**
2247
- * Creates a new IndexedIterable.
2248
- */
2249
- export function IndexedIterable<T>(iter: IndexedIterable<T>): IndexedIterable<T>;
2250
- export function IndexedIterable<T>(iter: SetIterable<T>): IndexedIterable<T>;
2251
- export function IndexedIterable<K, V>(iter: KeyedIterable<K, V>): IndexedIterable</*[K,V]*/any>;
2252
- export function IndexedIterable<T>(array: Array<T>): IndexedIterable<T>;
2253
- export function IndexedIterable<T>(iterator: Iterator<T>): IndexedIterable<T>;
2254
- export function IndexedIterable<T>(iterable: /*Iterable<T>*/Object): IndexedIterable<T>;
2255
-
2256
- export interface IndexedIterable<T> extends Iterable<number, T> {
2455
+ export module Collection {
2257
2456
 
2258
- // Reading values
2259
2457
 
2260
2458
  /**
2261
- * Returns the value associated with the provided index, or notSetValue if
2262
- * the index is beyond the bounds of the Iterable.
2263
- *
2264
- * `index` may be a negative number, which indexes back from the end of the
2265
- * Iterable. `s.get(-1)` gets the last item in the Iterable.
2459
+ * `Collection` which represents key-value pairs.
2266
2460
  */
2267
- get(index: number, notSetValue?: T): T;
2461
+ export module Keyed {}
2268
2462
 
2463
+ export interface Keyed<K, V> extends Collection<K, V>, Iterable.Keyed<K, V> {
2269
2464
 
2270
- // Conversion to Seq
2465
+ /**
2466
+ * Returns Seq.Keyed.
2467
+ * @override
2468
+ */
2469
+ toSeq(): Seq.Keyed<K, V>;
2470
+ }
2271
2471
 
2272
- /**
2273
- * Returns IndexedSeq.
2274
- * @override
2275
- */
2276
- toSeq(): IndexedSeq<T>;
2277
2472
 
2278
2473
  /**
2279
- * If this is an iterable of [key, value] entry tuples, it will return a
2280
- * KeyedSeq of those entries.
2474
+ * `Collection` which represents ordered indexed values.
2281
2475
  */
2282
- fromEntrySeq(): KeyedSeq<any, any>;
2476
+ export module Indexed {}
2283
2477
 
2478
+ export interface Indexed<T> extends Collection<number, T>, Iterable.Indexed<T> {
2284
2479
 
2285
- // Combination
2286
-
2287
- /**
2288
- * Returns an Iterable of the same type with `separator` between each item
2289
- * in this Iterable.
2290
- */
2291
- interpose(separator: T): /*this*/IndexedIterable<T>;
2292
-
2293
- /**
2294
- * Returns an Iterable of the same type with the provided `iterables`
2295
- * interleaved into this iterable.
2296
- *
2297
- * The resulting Iterable includes the first item from each, then the
2298
- * second from each, etc.
2299
- *
2300
- * I.Seq.of(1,2,3).interleave(I.Seq.of('A','B','C'))
2301
- * // Seq [ 1, 'A', 2, 'B', 3, 'C' ]
2302
- *
2303
- * The shortest Iterable stops interleave.
2304
- *
2305
- * I.Seq.of(1,2,3).interleave(
2306
- * I.Seq.of('A','B'),
2307
- * I.Seq.of('X','Y','Z')
2308
- * )
2309
- * // Seq [ 1, 'A', 'X', 2, 'B', 'Y' ]
2310
- */
2311
- interleave(...iterables: Array<Iterable<any, T>>): /*this*/IndexedIterable<T>;
2312
-
2313
- /**
2314
- * Splice returns a new indexed Iterable by replacing a region of this
2315
- * Iterable with new values. If values are not provided, it only skips the
2316
- * region to be removed.
2317
- *
2318
- * `index` may be a negative number, which indexes back from the end of the
2319
- * Iterable. `s.splice(-2)` splices after the second to last item.
2320
- *
2321
- * Seq(['a','b','c','d']).splice(1, 2, 'q', 'r', 's')
2322
- * // Seq ['a', 'q', 'r', 's', 'd']
2323
- *
2324
- */
2325
- splice(
2326
- index: number,
2327
- removeNum: number,
2328
- ...values: /*Array<IndexedIterable<T> | T>*/any[]
2329
- ): /*this*/IndexedIterable<T>;
2480
+ /**
2481
+ * Returns Seq.Indexed.
2482
+ * @override
2483
+ */
2484
+ toSeq(): Seq.Indexed<T>;
2485
+ }
2330
2486
 
2331
- /**
2332
- * Returns an Iterable of the same type "zipped" with the provided
2333
- * iterables.
2334
- *
2335
- * Like `zipWith`, but using the default `zipper`: creating an `Array`.
2336
- *
2337
- * var a = Seq.of(1, 2, 3);
2338
- * var b = Seq.of(4, 5, 6);
2339
- * var c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2340
- *
2341
- */
2342
- zip(...iterables: Array<Iterable<any, any>>): /*this*/IndexedIterable<any>;
2343
2487
 
2344
2488
  /**
2345
- * Returns an Iterable of the same type "zipped" with the provided
2346
- * iterables by using a custom `zipper` function.
2489
+ * `Collection` which represents values, unassociated with keys or indices.
2347
2490
  *
2348
- * var a = Seq.of(1, 2, 3);
2349
- * var b = Seq.of(4, 5, 6);
2350
- * var c = a.zipWith((a, b) => a + b, b); // Seq [ 5, 7, 9 ]
2351
- *
2352
- */
2353
- zipWith<U, Z>(
2354
- zipper: (value: T, otherValue: U) => Z,
2355
- otherIterable: Iterable<any, U>
2356
- ): IndexedIterable<Z>;
2357
- zipWith<U, V, Z>(
2358
- zipper: (value: T, otherValue: U, thirdValue: V) => Z,
2359
- otherIterable: Iterable<any, U>,
2360
- thirdIterable: Iterable<any, V>
2361
- ): IndexedIterable<Z>;
2362
- zipWith<Z>(
2363
- zipper: (...any: Array<any>) => Z,
2364
- ...iterables: Array<Iterable<any, any>>
2365
- ): IndexedIterable<Z>;
2366
-
2367
-
2368
- // Search for value
2369
-
2370
- /**
2371
- * Returns the first index at which a given value can be found in the
2372
- * Iterable, or -1 if it is not present.
2491
+ * `Collection.Set` implementations should guarantee value uniqueness.
2373
2492
  */
2374
- indexOf(searchValue: T): number;
2493
+ export module Set {}
2375
2494
 
2376
- /**
2377
- * Returns the last index at which a given value can be found in the
2378
- * Iterable, or -1 if it is not present.
2379
- */
2380
- lastIndexOf(searchValue: T): number;
2495
+ export interface Set<T> extends Collection<T, T>, Iterable.Set<T> {
2381
2496
 
2382
- /**
2383
- * Returns the first index in the Iterable where a value satisfies the
2384
- * provided predicate function. Otherwise -1 is returned.
2385
- */
2386
- findIndex(
2387
- predicate: (value?: T, index?: number, iter?: /*this*/IndexedIterable<T>) => boolean,
2388
- context?: any
2389
- ): number;
2390
-
2391
- /**
2392
- * Returns the last index in the Iterable where a value satisfies the
2393
- * provided predicate function. Otherwise -1 is returned.
2394
- */
2395
- findLastIndex(
2396
- predicate: (value?: T, index?: number, iter?: /*this*/IndexedIterable<T>) => boolean,
2397
- context?: any
2398
- ): number;
2399
- }
2400
-
2401
-
2402
- /**
2403
- * Set Iterables only represent values. They have no associated keys or
2404
- * indices. Duplicate values are possible in SetSeqs, however the
2405
- * concrete `Set` does not allow duplicate values.
2406
- *
2407
- * Iterable methods on SetIterable such as `map` and `forEach` will provide
2408
- * the value as both the first and second arguments to the provided function.
2409
- *
2410
- * var seq = SetSeq.of('A', 'B', 'C');
2411
- * assert.equal(seq.every((v, k) => v === k), true);
2412
- *
2413
- */
2414
- export module SetIterable {}
2415
-
2416
- /**
2417
- * Similar to `Iterable()`, but always returns a SetIterable.
2418
- */
2419
- export function SetIterable<T>(iter: SetIterable<T>): SetIterable<T>;
2420
- export function SetIterable<T>(iter: IndexedIterable<T>): SetIterable<T>;
2421
- export function SetIterable<K, V>(iter: KeyedIterable<K, V>): SetIterable</*[K,V]*/any>;
2422
- export function SetIterable<T>(array: Array<T>): SetIterable<T>;
2423
- export function SetIterable<T>(iterator: Iterator<T>): SetIterable<T>;
2424
- export function SetIterable<T>(iterable: /*Iterable<T>*/Object): SetIterable<T>;
2425
-
2426
- export interface SetIterable<T> extends Iterable<T, T> {
2497
+ /**
2498
+ * Returns Seq.Set.
2499
+ * @override
2500
+ */
2501
+ toSeq(): Seq.Set<T>;
2502
+ }
2427
2503
 
2428
- /**
2429
- * Returns SetSeq.
2430
- * @override
2431
- */
2432
- toSeq(): SetSeq<T>;
2433
2504
  }
2434
2505
 
2435
-
2436
- /**
2437
- * Collection is the abstract base class for concrete data structures. It
2438
- * cannot be constructed directly.
2439
- *
2440
- * Implementations should extend one of the subclasses, `KeyedCollection`,
2441
- * `IndexedCollection`, or `SetCollection`.
2442
- */
2443
- export module Collection {}
2444
-
2445
2506
  export interface Collection<K, V> extends Iterable<K, V> {
2446
2507
 
2447
2508
  /**
@@ -2451,53 +2512,6 @@ declare module Immutable {
2451
2512
  }
2452
2513
 
2453
2514
 
2454
- /**
2455
- * `Collection` which represents key-value pairs.
2456
- */
2457
- export module KeyedCollection {}
2458
-
2459
- export interface KeyedCollection<K, V> extends Collection<K, V>, KeyedIterable<K, V> {
2460
-
2461
- /**
2462
- * Returns KeyedSeq.
2463
- * @override
2464
- */
2465
- toSeq(): KeyedSeq<K, V>;
2466
- }
2467
-
2468
-
2469
- /**
2470
- * `Collection` which represents ordered indexed values.
2471
- */
2472
- export module IndexedCollection {}
2473
-
2474
- export interface IndexedCollection<T> extends Collection<number, T>, IndexedIterable<T> {
2475
-
2476
- /**
2477
- * Returns IndexedSeq.
2478
- * @override
2479
- */
2480
- toSeq(): IndexedSeq<T>;
2481
- }
2482
-
2483
-
2484
- /**
2485
- * `Collection` which represents values, unassociated with keys or indices.
2486
- *
2487
- * `SetCollection` implementations should guarantee value uniqueness.
2488
- */
2489
- export module SetCollection {}
2490
-
2491
- export interface SetCollection<T> extends Collection<T, T>, SetIterable<T> {
2492
-
2493
- /**
2494
- * Returns SetSeq.
2495
- * @override
2496
- */
2497
- toSeq(): SetSeq<T>;
2498
- }
2499
-
2500
-
2501
2515
  /**
2502
2516
  * ES6 Iterator.
2503
2517
  *