immutable 3.7.4 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,663 @@
1
+ /**
2
+ * This file provides type definitions for use with the Flow type checker.
3
+ *
4
+ * An important caveat when using these definitions is that the types for
5
+ * `Iterable.Keyed`, `Iterable.Indexed`, `Seq.Keyed`, and so on are stubs.
6
+ * When referring to those types, you can get the proper definitions by
7
+ * importing the types `KeyedIterable`, `IndexedIterable`, `KeyedSeq`, etc.
8
+ * For example,
9
+ *
10
+ * import { Seq } from 'immutable'
11
+ * import type { IndexedIterable, IndexedSeq } from 'immutable'
12
+ *
13
+ * const someSeq: IndexedSeq<number> = Seq.Indexed.of(1, 2, 3)
14
+ *
15
+ * function takesASeq<T, TS: IndexedIterable<T>>(iter: TS): TS {
16
+ * return iter.butLast()
17
+ * }
18
+ *
19
+ * takesASeq(someSeq)
20
+ *
21
+ * @flow
22
+ */
23
+
24
+ /*
25
+ * Alias for ECMAScript `Iterable` type, declared in
26
+ * https://github.com/facebook/flow/blob/master/lib/core.js
27
+ *
28
+ * Note that Immutable values implement the `ESIterable` interface.
29
+ */
30
+ type ESIterable<T> = $Iterable<T,void,void>;
31
+
32
+ declare class Iterable<K, V> extends _Iterable<K, V, typeof KeyedIterable, typeof IndexedIterable, typeof SetIterable> {}
33
+
34
+ declare class _Iterable<K, V, KI, II, SI> {
35
+ static Keyed: KI;
36
+ static Indexed: II;
37
+ static Set: SI;
38
+
39
+ static isIterable(maybeIterable: any): boolean;
40
+ static isKeyed(maybeKeyed: any): boolean;
41
+ static isIndexed(maybeIndexed: any): boolean;
42
+ static isAssociative(maybeAssociative: any): boolean;
43
+ static isOrdered(maybeOrdered: any): boolean;
44
+
45
+ equals(other: Iterable<K,V>): boolean;
46
+ hashCode(): number;
47
+ get(key: K): V;
48
+ get<V_>(key: K, notSetValue: V_): V|V_;
49
+ has(key: K): boolean;
50
+ includes(value: V): boolean;
51
+ contains(value: V): boolean;
52
+ first(): V;
53
+ last(): V;
54
+
55
+ getIn<T>(searchKeyPath: ESIterable<any>, notSetValue: T): T;
56
+ getIn<T>(searchKeyPath: ESIterable<any>): T;
57
+ hasIn(searchKeyPath: ESIterable<any>): boolean;
58
+
59
+ toJS(): any;
60
+ toArray(): V[];
61
+ toObject(): { [key: string]: V };
62
+ toMap(): Map<K,V>;
63
+ toOrderedMap(): Map<K,V>;
64
+ toSet(): Set<V>;
65
+ toOrderedSet(): Set<V>;
66
+ toList(): List<V>;
67
+ toStack(): Stack<V>;
68
+ toSeq(): Seq<K,V>;
69
+ toKeyedSeq(): KeyedSeq<K,V>;
70
+ toIndexedSeq(): IndexedSeq<V>;
71
+ toSetSeq(): SetSeq<V>;
72
+
73
+ keys(): Iterator<K>;
74
+ values(): Iterator<V>;
75
+ entries(): Iterator<[K,V]>;
76
+
77
+ keySeq(): IndexedSeq<K>;
78
+ valueSeq(): IndexedSeq<V>;
79
+ entrySeq(): IndexedSeq<[K,V]>;
80
+
81
+ reverse(): this;
82
+ sort(comparator?: (valueA: V, valueB: V) => number): this;
83
+
84
+ sortBy<C>(
85
+ comparatorValueMapper: (value: V, key: K, iter: this) => C,
86
+ comparator?: (valueA: C, valueB: C) => number
87
+ ): this;
88
+
89
+ groupBy<G>(
90
+ grouper: (value: V, key: K, iter: this) => G,
91
+ context?: any
92
+ ): KeyedSeq<G, this>;
93
+
94
+ forEach(
95
+ sideEffect: (value: V, key: K, iter: this) => any,
96
+ context?: any
97
+ ): number;
98
+
99
+ slice(begin?: number, end?: number): this;
100
+ rest(): this;
101
+ butLast(): this;
102
+ skip(amount: number): this;
103
+ skipLast(amount: number): this;
104
+ skipWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: any): this;
105
+ skipUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: any): this;
106
+ take(amount: number): this;
107
+ takeLast(amount: number): this;
108
+ takeWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: any): this;
109
+ takeUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: any): this;
110
+ flatten(depth?: number): /*this*/Iterable<any,any>;
111
+ flatten(shallow?: boolean): /*this*/Iterable<any,any>;
112
+
113
+ filter(
114
+ predicate: (value: V, key: K, iter: this) => mixed,
115
+ context?: any
116
+ ): this;
117
+
118
+ filterNot(
119
+ predicate: (value: V, key: K, iter: this) => mixed,
120
+ context?: any
121
+ ): this;
122
+
123
+ reduce<R>(
124
+ reducer: (reduction: R, value: V, key: K, iter: this) => R,
125
+ initialReduction?: R,
126
+ context?: any,
127
+ ): R;
128
+
129
+ reduceRight<R>(
130
+ reducer: (reduction: R, value: V, key: K, iter: this) => R,
131
+ initialReduction?: R,
132
+ context?: any,
133
+ ): R;
134
+
135
+ every(predicate: (value: V, key: K, iter: this) => mixed, context?: any): boolean;
136
+ some(predicate: (value: V, key: K, iter: this) => mixed, context?: any): boolean;
137
+ join(separator?: string): string;
138
+ isEmpty(): boolean;
139
+ count(predicate?: (value: V, key: K, iter: this) => mixed, context?: any): number;
140
+ countBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: any): Map<G,number>;
141
+
142
+ find(
143
+ predicate: (value: V, key: K, iter: this) => mixed,
144
+ context?: any,
145
+ ): ?V;
146
+ find<V_>(
147
+ predicate: (value: V, key: K, iter: this) => mixed,
148
+ context: any,
149
+ notSetValue: V_
150
+ ): V|V_;
151
+
152
+ findLast(
153
+ predicate: (value: V, key: K, iter: this) => mixed,
154
+ context?: any,
155
+ ): ?V;
156
+ findLast<V_>(
157
+ predicate: (value: V, key: K, iter: this) => mixed,
158
+ context: any,
159
+ notSetValue: V_
160
+ ): V|V_;
161
+
162
+
163
+ findEntry(predicate: (value: V, key: K, iter: this) => mixed): ?[K,V];
164
+ findLastEntry(predicate: (value: V, key: K, iter: this) => mixed): ?[K,V];
165
+
166
+ findKey(predicate: (value: V, key: K, iter: this) => mixed, context?: any): ?K;
167
+ findLastKey(predicate: (value: V, key: K, iter: this) => mixed, context?: any): ?K;
168
+
169
+ keyOf(searchValue: V): ?K;
170
+ lastKeyOf(searchValue: V): ?K;
171
+
172
+ max(comparator?: (valueA: V, valueB: V) => number): V;
173
+ maxBy<C>(
174
+ comparatorValueMapper: (value: V, key: K, iter: this) => C,
175
+ comparator?: (valueA: C, valueB: C) => number
176
+ ): V;
177
+ min(comparator?: (valueA: V, valueB: V) => number): V;
178
+ minBy<C>(
179
+ comparatorValueMapper: (value: V, key: K, iter: this) => C,
180
+ comparator?: (valueA: C, valueB: C) => number
181
+ ): V;
182
+
183
+ isSubset(iter: Iterable<any, V>): boolean;
184
+ isSubset(iter: ESIterable<V>): boolean;
185
+ isSuperset(iter: Iterable<any, V>): boolean;
186
+ isSuperset(iter: ESIterable<V>): boolean;
187
+ }
188
+
189
+ declare class KeyedIterable<K,V> extends Iterable<K,V> {
190
+ static <K,V>(iter?: ESIterable<[K,V]>): KeyedIterable<K,V>;
191
+ static <K,V>(obj?: { [key: K]: V }): KeyedIterable<K,V>;
192
+
193
+ @@iterator(): Iterator<[K,V]>;
194
+ toSeq(): KeyedSeq<K,V>;
195
+ flip(): /*this*/KeyedIterable<V,K>;
196
+
197
+ mapKeys<K_>(
198
+ mapper: (key: K, value: V, iter: this) => K_,
199
+ context?: any
200
+ ): /*this*/KeyedIterable<K_,V>;
201
+
202
+ mapEntries<K_,V_>(
203
+ mapper: (entry: [K,V], index: number, iter: this) => [K_,V_],
204
+ context?: any
205
+ ): /*this*/KeyedIterable<K_,V_>;
206
+
207
+ concat(...iters: ESIterable<[K,V]>[]): this;
208
+
209
+ map<V_>(
210
+ mapper: (value: V, key: K, iter: this) => V_,
211
+ context?: any
212
+ ): /*this*/KeyedIterable<K,V_>;
213
+
214
+ flatMap<K_, V_>(
215
+ mapper: (value: V, key: K, iter: this) => ESIterable<[K_,V_]>,
216
+ context?: any
217
+ ): /*this*/KeyedIterable<K_,V_>;
218
+
219
+ flatten(depth?: number): /*this*/KeyedIterable<any,any>;
220
+ flatten(shallow?: boolean): /*this*/KeyedIterable<any,any>;
221
+ }
222
+
223
+ declare class IndexedIterable<T> extends Iterable<number,T> {
224
+ static <T>(iter?: ESIterable<T>): IndexedIterable<T>;
225
+
226
+ @@iterator(): Iterator<T>;
227
+ toSeq(): IndexedSeq<T>;
228
+ fromEntrySeq<K,V>(): KeyedSeq<K,V>;
229
+ interpose(separator: T): this;
230
+ interleave(...iterables: ESIterable<T>[]): this;
231
+ splice(
232
+ index: number,
233
+ removeNum: number,
234
+ ...values: T[]
235
+ ): this;
236
+
237
+ zip<A>(
238
+ a: ESIterable<A>,
239
+ $?: null
240
+ ): IndexedIterable<[T,A]>;
241
+ zip<A,B>(
242
+ a: ESIterable<A>,
243
+ b: ESIterable<B>,
244
+ $?: null
245
+ ): IndexedIterable<[T,A,B]>;
246
+ zip<A,B,C>(
247
+ a: ESIterable<A>,
248
+ b: ESIterable<B>,
249
+ c: ESIterable<C>,
250
+ $?: null
251
+ ): IndexedIterable<[T,A,B,C]>;
252
+ zip<A,B,C,D>(
253
+ a: ESIterable<A>,
254
+ b: ESIterable<B>,
255
+ c: ESIterable<C>,
256
+ d: ESIterable<D>,
257
+ $?: null
258
+ ): IndexedIterable<[T,A,B,C,D]>;
259
+ zip<A,B,C,D,E>(
260
+ a: ESIterable<A>,
261
+ b: ESIterable<B>,
262
+ c: ESIterable<C>,
263
+ d: ESIterable<D>,
264
+ e: ESIterable<E>,
265
+ $?: null
266
+ ): IndexedIterable<[T,A,B,C,D,E]>;
267
+
268
+ zipWith<A,R>(
269
+ zipper: (value: T, a: A) => R,
270
+ a: ESIterable<A>,
271
+ $?: null
272
+ ): IndexedIterable<R>;
273
+ zipWith<A,B,R>(
274
+ zipper: (value: T, a: A, b: B) => R,
275
+ a: ESIterable<A>,
276
+ b: ESIterable<B>,
277
+ $?: null
278
+ ): IndexedIterable<R>;
279
+ zipWith<A,B,C,R>(
280
+ zipper: (value: T, a: A, b: B, c: C) => R,
281
+ a: ESIterable<A>,
282
+ b: ESIterable<B>,
283
+ c: ESIterable<C>,
284
+ $?: null
285
+ ): IndexedIterable<R>;
286
+ zipWith<A,B,C,D,R>(
287
+ zipper: (value: T, a: A, b: B, c: C, d: D) => R,
288
+ a: ESIterable<A>,
289
+ b: ESIterable<B>,
290
+ c: ESIterable<C>,
291
+ d: ESIterable<D>,
292
+ $?: null
293
+ ): IndexedIterable<R>;
294
+ zipWith<A,B,C,D,E,R>(
295
+ zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
296
+ a: ESIterable<A>,
297
+ b: ESIterable<B>,
298
+ c: ESIterable<C>,
299
+ d: ESIterable<D>,
300
+ e: ESIterable<E>,
301
+ $?: null
302
+ ): IndexedIterable<R>;
303
+
304
+ indexOf(searchValue: T): number;
305
+ lastIndexOf(searchValue: T): number;
306
+ findIndex(
307
+ predicate: (value: T, index: number, iter: this) => mixed,
308
+ context?: any
309
+ ): number;
310
+ findLastIndex(
311
+ predicate: (value: T, index: number, iter: this) => mixed,
312
+ context?: any
313
+ ): number;
314
+
315
+ concat(...iters: ESIterable<T>[]): this;
316
+
317
+ map<U>(
318
+ mapper: (value: T, index: number, iter: this) => U,
319
+ context?: any
320
+ ): /*this*/IndexedIterable<U>;
321
+
322
+ flatMap<U>(
323
+ mapper: (value: T, index: number, iter: this) => ESIterable<U>,
324
+ context?: any
325
+ ): /*this*/IndexedIterable<U>;
326
+
327
+ flatten(depth?: number): /*this*/IndexedIterable<any>;
328
+ flatten(shallow?: boolean): /*this*/IndexedIterable<any>;
329
+ }
330
+
331
+ declare class SetIterable<T> extends Iterable<T,T> {
332
+ static <T>(iter?: ESIterable<T>): SetIterable<T>;
333
+
334
+ @@iterator(): Iterator<T>;
335
+ toSeq(): SetSeq<T>;
336
+
337
+ concat(...iters: ESIterable<T>[]): this;
338
+
339
+ // `map` and `flatMap` cannot be defined further up the hiearchy, because the
340
+ // implementation for `KeyedIterable` allows the value type to change without
341
+ // constraining the key type. That does not work for `SetIterable` - the value
342
+ // and key types *must* match.
343
+ map<U>(
344
+ mapper: (value: T, value: T, iter: this) => U,
345
+ context?: any
346
+ ): /*this*/SetIterable<U>;
347
+
348
+ flatMap<U>(
349
+ mapper: (value: T, value: T, iter: this) => ESIterable<U>,
350
+ context?: any
351
+ ): /*this*/SetIterable<U>;
352
+
353
+ flatten(depth?: number): /*this*/SetIterable<any>;
354
+ flatten(shallow?: boolean): /*this*/SetIterable<any>;
355
+ }
356
+
357
+ declare class Collection<K,V> extends _Iterable<K,V, typeof KeyedCollection, typeof IndexedCollection, typeof SetCollection> {
358
+ size: number;
359
+ }
360
+
361
+ declare class KeyedCollection<K,V> extends Collection<K,V> mixins KeyedIterable<K,V> {
362
+ toSeq(): KeyedSeq<K,V>;
363
+ }
364
+
365
+ declare class IndexedCollection<T> extends Collection<number,T> mixins IndexedIterable<T> {
366
+ toSeq(): IndexedSeq<T>;
367
+ }
368
+
369
+ declare class SetCollection<T> extends Collection<T,T> mixins SetIterable<T> {
370
+ toSeq(): SetSeq<T>;
371
+ }
372
+
373
+ declare class Seq<K,V> extends _Iterable<K,V, typeof KeyedSeq, typeof IndexedSeq, typeof SetSeq> {
374
+ static <K,V>(iter: KeyedSeq<K,V>): KeyedSeq<K,V>;
375
+ static <T> (iter: SetSeq<T>): SetSeq<K,V>;
376
+ static <T> (iter?: ESIterable<T>): IndexedSeq<T>;
377
+ static <K,V>(iter: { [key: K]: V }): KeyedSeq<K,V>;
378
+
379
+ static isSeq(maybeSeq: any): boolean;
380
+ static of<T>(...values: T[]): IndexedSeq<T>;
381
+
382
+ size: ?number;
383
+ cacheResult(): this;
384
+ toSeq(): this;
385
+ }
386
+
387
+ declare class KeyedSeq<K,V> extends Seq<K,V> mixins KeyedIterable<K,V> {
388
+ static <K,V>(iter?: ESIterable<[K,V]>): KeyedSeq<K,V>;
389
+ static <K,V>(iter?: { [key: K]: V }): KeyedSeq<K,V>;
390
+ }
391
+
392
+ declare class IndexedSeq<T> extends Seq<number,T> mixins IndexedIterable<T> {
393
+ static <T>(iter?: ESIterable<T>): IndexedSeq<T>;
394
+ static of<T>(...values: T[]): IndexedSeq<T>;
395
+ }
396
+
397
+ declare class SetSeq<T> extends Seq<T,T> mixins SetIterable<T> {
398
+ static <T>(iter?: ESIterable<T>): IndexedSeq<T>;
399
+ static of<T>(...values: T[]): SetSeq<T>;
400
+ }
401
+
402
+ declare class List<T> extends IndexedCollection<T> {
403
+ static (iterable?: ESIterable<T>): List<T>;
404
+
405
+ static isList(maybeList: any): boolean;
406
+ static of<T>(...values: T[]): List<T>;
407
+
408
+ set<U>(index: number, value: U): List<T|U>;
409
+ delete(index: number): this;
410
+ remove(index: number): this;
411
+ insert<U>(index: number, value: U): List<T|U>;
412
+ clear(): this;
413
+ push<U>(...values: U[]): List<T|U>;
414
+ pop(): this;
415
+ unshift<U>(...values: U[]): List<T|U>;
416
+ shift(): this;
417
+
418
+ update<U>(updater: (value: this) => List<U>): List<U>;
419
+ update<U>(index: number, updater: (value: T) => U): List<T|U>;
420
+ update<U>(index: number, notSetValue: U, updater: (value: T) => U): List<T|U>;
421
+
422
+ merge<U>(...iterables: ESIterable<U>[]): List<T|U>;
423
+
424
+ mergeWith<U,V>(
425
+ merger: (previous: T, next: U, key: number) => V,
426
+ ...iterables: ESIterable<U>[]
427
+ ): List<T|U|V>;
428
+
429
+ mergeDeep<U>(...iterables: ESIterable<U>[]): List<T|U>;
430
+
431
+ mergeDeepWith<U,V>(
432
+ merger: (previous: T, next: U, key: number) => V,
433
+ ...iterables: ESIterable<U>[]
434
+ ): List<T|U|V>;
435
+
436
+ setSize(size: number): List<?T>;
437
+ setIn(keyPath: ESIterable<any>, value: any): List<T>;
438
+ deleteIn(keyPath: ESIterable<any>, value: any): this;
439
+ removeIn(keyPath: ESIterable<any>, value: any): this;
440
+
441
+ updateIn(keyPath: ESIterable<any>, notSetValue: any, value: any): List<T>;
442
+ updateIn(keyPath: ESIterable<any>, value: any): List<T>;
443
+
444
+ mergeIn(keyPath: ESIterable<any>, ...iterables: ESIterable<any>[]): List<T>;
445
+ mergeDeepIn(keyPath: ESIterable<any>, ...iterables: ESIterable<any>[]): List<T>;
446
+
447
+ withMutations(mutator: (mutable: this) => any): this;
448
+ asMutable(): this;
449
+ asImmutable(): this;
450
+
451
+ // Overrides that specialize return types
452
+ map<M>(
453
+ mapper: (value: T, index: number, iter: this) => M,
454
+ context?: any
455
+ ): List<M>;
456
+
457
+ flatMap<M>(
458
+ mapper: (value: T, index: number, iter: this) => ESIterable<M>,
459
+ context?: any
460
+ ): List<M>;
461
+
462
+ flatten(depth?: number): /*this*/List<any>;
463
+ flatten(shallow?: boolean): /*this*/List<any>;
464
+ }
465
+
466
+ declare class Map<K,V> extends KeyedCollection<K,V> {
467
+ static <K, V>(): Map<K, V>;
468
+ static <V>(obj?: {[key: string]: V}): Map<string, V>;
469
+ static <K, V>(iterable?: ESIterable<[K,V]>): Map<K, V>;
470
+
471
+ static isMap(maybeMap: any): boolean;
472
+
473
+ set<K_, V_>(key: K_, value: V_): Map<K|K_, V|V_>;
474
+ delete(key: K): this;
475
+ remove(key: K): this;
476
+ clear(): this;
477
+
478
+ update<K_,V_>(updater: (value: this) => Map<K_,V_>): Map<K_,V_>;
479
+ update<V_>(key: K, updater: (value: V) => V_): Map<K,V|V_>;
480
+ update<V_>(key: K, notSetValue: V_, updater: (value: V) => V_): Map<K,V|V_>;
481
+
482
+ merge<K_,V_>(
483
+ ...iterables: (ESIterable<[K_,V_]> | { [key: K_]: V_ })[]
484
+ ): Map<K|K_,V|V_>;
485
+
486
+ mergeWith<K_,W,X>(
487
+ merger: (previous: V, next: W, key: number) => X,
488
+ ...iterables: ESIterable<W>[]
489
+ ): Map<K,V|W|X>;
490
+
491
+ mergeDeep<K_,V_>(
492
+ ...iterables: (ESIterable<[K_,V_]> | { [key: K_]: V_ })[]
493
+ ): Map<K|K_,V|V_>;
494
+
495
+ mergeDeepWith<K_,W,X>(
496
+ merger: (previous: V, next: W, key: number) => X,
497
+ ...iterables: ESIterable<W>[]
498
+ ): Map<K,V|W|X>;
499
+
500
+ setIn(keyPath: ESIterable<any>, value: any): Map<K,V>;
501
+ deleteIn(keyPath: ESIterable<any>, value: any): this;
502
+ removeIn(keyPath: ESIterable<any>, value: any): this;
503
+
504
+ updateIn(keyPath: ESIterable<any>, notSetValue: any, value: any): Map<K,V>;
505
+ updateIn(keyPath: ESIterable<any>, value: any): Map<K,V>;
506
+
507
+ mergeIn(keyPath: ESIterable<any>, ...iterables: ESIterable<any>[]): Map<K,V>;
508
+ mergeDeepIn(keyPath: ESIterable<any>, ...iterables: ESIterable<any>[]): Map<K,V>;
509
+
510
+ withMutations(mutator: (mutable: this) => any): this;
511
+ asMutable(): this;
512
+ asImmutable(): this;
513
+
514
+ // Overrides that specialize return types
515
+
516
+ map<V_>(
517
+ mapper: (value: V, key: K, iter: this) => V_,
518
+ context?: any
519
+ ): Map<K,V_>;
520
+
521
+ flatMap<K_,V_>(
522
+ mapper: (value: V, key: K, iter: this) => ESIterable<[K_,V_]>,
523
+ context?: any
524
+ ): Map<K_,V_>;
525
+
526
+ flip(): Map<V,K>;
527
+
528
+ mapKeys<K_>(
529
+ mapper: (key: K, value: V, iter: this) => K_,
530
+ context?: any
531
+ ): Map<K_,V>;
532
+
533
+ flatten(depth?: number): /*this*/Map<any,any>;
534
+ flatten(shallow?: boolean): /*this*/Map<any,any>;
535
+ }
536
+
537
+ // OrderedMaps have nothing that Maps do not have. We do not need to override constructor & other statics
538
+ declare class OrderedMap<K,V> extends Map<K,V> {
539
+ static isOrderedMap(maybeOrderedMap: any): bool;
540
+ }
541
+
542
+ declare class Set<T> extends SetCollection<T> {
543
+ static <T>(iterable?: ESIterable<T>): Set<T>;
544
+
545
+ static isSet(maybeSet: any): boolean;
546
+ static of<T>(...values: T[]): Set<T>;
547
+ static fromKeys<T>(iter: ESIterable<[T,any]>): Set<T>;
548
+ static fromKeys(iter: { [key: string]: any }): Set<string>;
549
+
550
+ add<U>(value: U): Set<T|U>;
551
+ delete(value: T): this;
552
+ remove(value: T): this;
553
+ clear(): this;
554
+ union<U>(...iterables: ESIterable<U>[]): Set<T|U>;
555
+ merge<U>(...iterables: ESIterable<U>[]): Set<T|U>;
556
+ intersect<U>(...iterables: ESIterable<U>[]): Set<T&U>;
557
+ subtract<U>(...iterables: ESIterable<U>[]): Set<T>;
558
+
559
+ withMutations(mutator: (mutable: this) => any): this;
560
+ asMutable(): this;
561
+ asImmutable(): this;
562
+
563
+ // Overrides that specialize return types
564
+
565
+ map<M>(
566
+ mapper: (value: T, value: T, iter: this) => M,
567
+ context?: any
568
+ ): Set<M>;
569
+
570
+ flatMap<M>(
571
+ mapper: (value: T, value: T, iter: this) => ESIterable<M>,
572
+ context?: any
573
+ ): Set<M>;
574
+
575
+ flatten(depth?: number): /*this*/Set<any>;
576
+ flatten(shallow?: boolean): /*this*/Set<any>;
577
+ }
578
+
579
+ // OrderedSets have nothing that Sets do not have. We do not need to override constructor & other statics
580
+ declare class OrderedSet<T> extends Set<T> {
581
+ static isOrderedSet(maybeOrderedSet: any): bool;
582
+ }
583
+
584
+ declare class Stack<T> extends IndexedCollection<T> {
585
+ static <T>(iterable?: ESIterable<T>): Stack<T>;
586
+
587
+ static isStack(maybeStack: any): boolean;
588
+ static of<T>(...values: T[]): Stack<T>;
589
+
590
+ peek(): T;
591
+ clear(): this;
592
+ unshift<U>(...values: U[]): Stack<T|U>;
593
+ unshiftAll<U>(iter: ESIterable<U>): Stack<T|U>;
594
+ shift(): this;
595
+ push<U>(...values: U[]): Stack<T|U>;
596
+ pushAll<U>(iter: ESIterable<U>): Stack<T|U>;
597
+ pop(): this;
598
+
599
+ withMutations(mutator: (mutable: this) => any): this;
600
+ asMutable(): this;
601
+ asImmutable(): this;
602
+
603
+ // Overrides that specialize return types
604
+
605
+ map<U>(
606
+ mapper: (value: T, index: number, iter: this) => U,
607
+ context?: any
608
+ ): Stack<U>;
609
+
610
+ flatMap<U>(
611
+ mapper: (value: T, index: number, iter: this) => ESIterable<U>,
612
+ context?: any
613
+ ): Stack<U>;
614
+
615
+ flatten(depth?: number): /*this*/Stack<any>;
616
+ flatten(shallow?: boolean): /*this*/Stack<any>;
617
+ }
618
+
619
+ declare function Range(start?: number, end?: number, step?: number): IndexedSeq<number>;
620
+ declare function Repeat<T>(value: T, times?: number): IndexedSeq<T>;
621
+
622
+ //TODO: Once flow can extend normal Objects we can change this back to actually reflect Record behavior.
623
+ // For now fallback to any to not break existing Code
624
+ declare class Record<T: Object> {
625
+ static <T: Object>(spec: T, name?: string): /*T & Record<T>*/any;
626
+ get<A>(key: $Keys<T>): A;
627
+ set<A>(key: $Keys<T>, value: A): /*T & Record<T>*/this;
628
+ remove(key: $Keys<T>): /*T & Record<T>*/this;
629
+ }
630
+
631
+ declare function fromJS(json: any, reviver?: (k: any, v: Iterable<any,any>) => any): any;
632
+ declare function is(first: any, second: any): boolean;
633
+
634
+ export {
635
+ Iterable,
636
+ Collection,
637
+ Seq,
638
+
639
+ // These classes do not actually exist under these names. But it is useful to
640
+ // have the types available.
641
+ KeyedIterable,
642
+ IndexedIterable,
643
+ SetIterable,
644
+ KeyedCollection,
645
+ IndexedCollection,
646
+ SetCollection,
647
+ KeyedSeq,
648
+ IndexedSeq,
649
+ SetSeq,
650
+
651
+ List,
652
+ Map,
653
+ OrderedMap,
654
+ OrderedSet,
655
+ Range,
656
+ Repeat,
657
+ Record,
658
+ Set,
659
+ Stack,
660
+
661
+ fromJS,
662
+ is,
663
+ }