Skip to content

Commit 2751375

Browse files
committed
add documentation and type signatures in flow
1 parent 66d01cc commit 2751375

File tree

2 files changed

+222
-0
lines changed

2 files changed

+222
-0
lines changed

type-definitions/Immutable.d.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,19 @@ declare module Immutable {
802802
* ```
803803
*/
804804
zip(...collections: Array<Collection<any, any>>): List<any>;
805+
806+
/**
807+
* Returns a List "zipped" with the provided collections.
808+
*
809+
* Unlike `zip`, `zipAll` continues zipping until the longest collection is
810+
* exhausted. Missing values from shorter collections are filled with `undefined`.
811+
*
812+
* ```js
813+
* const a = List([ 1, 2 ]);
814+
* const b = List([ 3, 4, 5 ]);
815+
* const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
816+
* ```
817+
*/
805818
zipAll(...collections: Array<Collection<any, any>>): List<any>;
806819

807820
/**
@@ -1872,6 +1885,22 @@ declare module Immutable {
18721885
* ```
18731886
*/
18741887
zip(...collections: Array<Collection<any, any>>): OrderedSet<any>;
1888+
1889+
/**
1890+
* Returns a OrderedSet of the same type "zipped" with the provided
1891+
* collections.
1892+
*
1893+
* @see IndexedIterator.zipAll
1894+
*
1895+
* Unlike `zip`, `zipAll` continues zipping until the longest collection is
1896+
* exhausted. Missing values from shorter collections are filled with `undefined`.
1897+
*
1898+
* ```js
1899+
* const a = OrderedSet([ 1, 2 ]);
1900+
* const b = OrderedSet([ 3, 4, 5 ]);
1901+
* const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
1902+
* ```
1903+
*/
18751904
zipAll(...collections: Array<Collection<any, any>>): OrderedSet<any>;
18761905

18771906
/**
@@ -2088,6 +2117,19 @@ declare module Immutable {
20882117
* ```
20892118
*/
20902119
zip(...collections: Array<Collection<any, any>>): Stack<any>;
2120+
2121+
/**
2122+
* Returns a Stack "zipped" with the provided collections.
2123+
*
2124+
* Unlike `zip`, `zipAll` continues zipping until the longest collection is
2125+
* exhausted. Missing values from shorter collections are filled with `undefined`.
2126+
*
2127+
* ```js
2128+
* const a = Stack([ 1, 2 ]);
2129+
* const b = Stack([ 3, 4, 5 ]);
2130+
* const c = a.zipAll(b); // Stack [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
2131+
* ```
2132+
*/
20912133
zipAll(...collections: Array<Collection<any, any>>): Stack<any>;
20922134

20932135
/**
@@ -2624,6 +2666,19 @@ declare module Immutable {
26242666
* ```
26252667
*/
26262668
zip(...collections: Array<Collection<any, any>>): Seq.Indexed<any>;
2669+
2670+
/**
2671+
* Returns a Seq "zipped" with the provided collections.
2672+
*
2673+
* Unlike `zip`, `zipAll` continues zipping until the longest collection is
2674+
* exhausted. Missing values from shorter collections are filled with `undefined`.
2675+
*
2676+
* ```js
2677+
* const a = Seq([ 1, 2 ]);
2678+
* const b = Seq([ 3, 4, 5 ]);
2679+
* const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
2680+
* ```
2681+
*/
26272682
zipAll(...collections: Array<Collection<any, any>>): Seq.Indexed<any>;
26282683

26292684
/**
@@ -3160,6 +3215,18 @@ declare module Immutable {
31603215
* ```
31613216
*/
31623217
zip(...collections: Array<Collection<any, any>>): Collection.Indexed<any>;
3218+
/**
3219+
* Returns a Collection "zipped" with the provided collections.
3220+
*
3221+
* Unlike `zip`, `zipAll` continues zipping until the longest collection is
3222+
* exhausted. Missing values from shorter collections are filled with `undefined`.
3223+
*
3224+
* ```js
3225+
* const a = List([ 1, 2 ]);
3226+
* const b = List([ 3, 4, 5 ]);
3227+
* const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
3228+
* ```
3229+
*/
31633230
zipAll(...collections: Array<Collection<any, any>>): Collection.Indexed<any>;
31643231

31653232
/**

type-definitions/immutable.js.flow

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,37 @@ declare class IndexedCollection<+T> extends Collection<number, T> {
277277
e: Iterable<E>,
278278
..._: []
279279
): IndexedCollection<[T, A, B, C, D, E]>;
280+
281+
zipAll<A>(
282+
a: Iterable<A>,
283+
..._: []
284+
): IndexedCollection<[T, A]>;
285+
zipAll<A, B>(
286+
a: Iterable<A>,
287+
b: Iterable<B>,
288+
..._: []
289+
): IndexedCollection<[T, A, B]>;
290+
zipAll<A, B, C>(
291+
a: Iterable<A>,
292+
b: Iterable<B>,
293+
c: Iterable<C>,
294+
..._: []
295+
): IndexedCollection<[T, A, B, C]>;
296+
zipAll<A, B, C, D>(
297+
a: Iterable<A>,
298+
b: Iterable<B>,
299+
c: Iterable<C>,
300+
d: Iterable<D>,
301+
..._: []
302+
): IndexedCollection<[T, A, B, C, D]>;
303+
zipAll<A, B, C, D, E>(
304+
a: Iterable<A>,
305+
b: Iterable<B>,
306+
c: Iterable<C>,
307+
d: Iterable<D>,
308+
e: Iterable<E>,
309+
..._: []
310+
): IndexedCollection<[T, A, B, C, D, E]>;
280311

281312
zipWith<A, R>(
282313
zipper: (value: T, a: A) => R,
@@ -476,6 +507,37 @@ declare class IndexedSeq<+T> extends Seq<number, T> mixins IndexedCollection<T>
476507
..._: []
477508
): IndexedSeq<[T, A, B, C, D, E]>;
478509

510+
zipAll<A>(
511+
a: Iterable<A>,
512+
..._: []
513+
): IndexedSeq<[T, A]>;
514+
zipAll<A, B>(
515+
a: Iterable<A>,
516+
b: Iterable<B>,
517+
..._: []
518+
): IndexedSeq<[T, A, B]>;
519+
zipAll<A, B, C>(
520+
a: Iterable<A>,
521+
b: Iterable<B>,
522+
c: Iterable<C>,
523+
..._: []
524+
): IndexedSeq<[T, A, B, C]>;
525+
zipAll<A, B, C, D>(
526+
a: Iterable<A>,
527+
b: Iterable<B>,
528+
c: Iterable<C>,
529+
d: Iterable<D>,
530+
..._: []
531+
): IndexedSeq<[T, A, B, C, D]>;
532+
zipAll<A, B, C, D, E>(
533+
a: Iterable<A>,
534+
b: Iterable<B>,
535+
c: Iterable<C>,
536+
d: Iterable<D>,
537+
e: Iterable<E>,
538+
..._: []
539+
): IndexedSeq<[T, A, B, C, D, E]>;
540+
479541
zipWith<A, R>(
480542
zipper: (value: T, a: A) => R,
481543
a: Iterable<A>,
@@ -644,6 +706,37 @@ declare class List<+T> extends IndexedCollection<T> {
644706
..._: []
645707
): List<[T, A, B, C, D, E]>;
646708

709+
zipAll<A>(
710+
a: Iterable<A>,
711+
..._: []
712+
): List<[T, A]>;
713+
zipAll<A, B>(
714+
a: Iterable<A>,
715+
b: Iterable<B>,
716+
..._: []
717+
): List<[T, A, B]>;
718+
zipAll<A, B, C>(
719+
a: Iterable<A>,
720+
b: Iterable<B>,
721+
c: Iterable<C>,
722+
..._: []
723+
): List<[T, A, B, C]>;
724+
zipAll<A, B, C, D>(
725+
a: Iterable<A>,
726+
b: Iterable<B>,
727+
c: Iterable<C>,
728+
d: Iterable<D>,
729+
..._: []
730+
): List<[T, A, B, C, D]>;
731+
zipAll<A, B, C, D, E>(
732+
a: Iterable<A>,
733+
b: Iterable<B>,
734+
c: Iterable<C>,
735+
d: Iterable<D>,
736+
e: Iterable<E>,
737+
..._: []
738+
): List<[T, A, B, C, D, E]>;
739+
647740
zipWith<A, R>(
648741
zipper: (value: T, a: A) => R,
649742
a: Iterable<A>,
@@ -983,6 +1076,37 @@ declare class OrderedSet<+T> extends Set<T> {
9831076
..._: []
9841077
): OrderedSet<[T, A, B, C, D, E]>;
9851078

1079+
zipAll<A>(
1080+
a: Iterable<A>,
1081+
..._: []
1082+
): OrderedSet<[T, A]>;
1083+
zipAll<A, B>(
1084+
a: Iterable<A>,
1085+
b: Iterable<B>,
1086+
..._: []
1087+
): OrderedSet<[T, A, B]>;
1088+
zipAll<A, B, C>(
1089+
a: Iterable<A>,
1090+
b: Iterable<B>,
1091+
c: Iterable<C>,
1092+
..._: []
1093+
): OrderedSet<[T, A, B, C]>;
1094+
zipAll<A, B, C, D>(
1095+
a: Iterable<A>,
1096+
b: Iterable<B>,
1097+
c: Iterable<C>,
1098+
d: Iterable<D>,
1099+
..._: []
1100+
): OrderedSet<[T, A, B, C, D]>;
1101+
zipAll<A, B, C, D, E>(
1102+
a: Iterable<A>,
1103+
b: Iterable<B>,
1104+
c: Iterable<C>,
1105+
d: Iterable<D>,
1106+
e: Iterable<E>,
1107+
..._: []
1108+
): OrderedSet<[T, A, B, C, D, E]>;
1109+
9861110
zipWith<A, R>(
9871111
zipper: (value: T, a: A) => R,
9881112
a: Iterable<A>,
@@ -1092,6 +1216,37 @@ declare class Stack<+T> extends IndexedCollection<T> {
10921216
..._: []
10931217
): Stack<[T, A, B, C, D, E]>;
10941218

1219+
zipAll<A>(
1220+
a: Iterable<A>,
1221+
..._: []
1222+
): Stack<[T, A]>;
1223+
zipAll<A, B>(
1224+
a: Iterable<A>,
1225+
b: Iterable<B>,
1226+
..._: []
1227+
): Stack<[T, A, B]>;
1228+
zipAll<A, B, C>(
1229+
a: Iterable<A>,
1230+
b: Iterable<B>,
1231+
c: Iterable<C>,
1232+
..._: []
1233+
): Stack<[T, A, B, C]>;
1234+
zipAll<A, B, C, D>(
1235+
a: Iterable<A>,
1236+
b: Iterable<B>,
1237+
c: Iterable<C>,
1238+
d: Iterable<D>,
1239+
..._: []
1240+
): Stack<[T, A, B, C, D]>;
1241+
zipAll<A, B, C, D, E>(
1242+
a: Iterable<A>,
1243+
b: Iterable<B>,
1244+
c: Iterable<C>,
1245+
d: Iterable<D>,
1246+
e: Iterable<E>,
1247+
..._: []
1248+
): Stack<[T, A, B, C, D, E]>;
1249+
10951250
zipWith<A, R>(
10961251
zipper: (value: T, a: A) => R,
10971252
a: Iterable<A>,

0 commit comments

Comments
 (0)