Skip to content

Commit 60b2396

Browse files
committed
Improve docs and ts types for zip and zipAll
1 parent e705ae6 commit 60b2396

File tree

1 file changed

+11
-140
lines changed

1 file changed

+11
-140
lines changed

type-definitions/Immutable.d.ts

Lines changed: 11 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -883,36 +883,7 @@ declare module Immutable {
883883
* ```
884884
*/
885885
zip<U>(other: Collection<any, U>): List<[T,U]>;
886-
887-
/**
888-
* Returns a List "zipped" with the provided collection.
889-
*
890-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
891-
* <!-- runkit:activate
892-
* { "preamble": "const { List } = require(\"immutable\");" }
893-
* -->
894-
* ```js
895-
* const a = List([ 1, 2, 3 ]);
896-
* const b = List([ 4, 5, 6 ]);
897-
* const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
898-
* ```
899-
*/
900886
zip<U,V>(other: Collection<any, U>, other2: Collection<any,V>): List<[T,U,V]>;
901-
902-
/**
903-
* Returns a List "zipped" with the provided collections.
904-
*
905-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
906-
*
907-
* <!-- runkit:activate
908-
* { "preamble": "const { List } = require(\"immutable\");" }
909-
* -->
910-
* ```js
911-
* const a = List([ 1, 2, 3 ]);
912-
* const b = List([ 4, 5, 6 ]);
913-
* const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
914-
* ```
915-
*/
916887
zip(...collections: Array<Collection<any, any>>): List<any>;
917888

918889
/**
@@ -930,6 +901,8 @@ declare module Immutable {
930901
* const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
931902
* ```
932903
*/
904+
zipAll<U>(other: Collection<any, U>): List<[T,U]>;
905+
zipAll<U,V>(other: Collection<any, U>, other2: Collection<any,V>): List<[T,U,V]>;
933906
zipAll(...collections: Array<Collection<any, any>>): List<any>;
934907

935908
/**
@@ -2048,8 +2021,6 @@ declare module Immutable {
20482021
* Returns an OrderedSet of the same type "zipped" with the provided
20492022
* collections.
20502023
*
2051-
* @see IndexedIterator.zip
2052-
*
20532024
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
20542025
*
20552026
* ```js
@@ -2060,47 +2031,13 @@ declare module Immutable {
20602031
* ```
20612032
*/
20622033
zip<U>(other: Collection<any, U>): OrderedSet<[T,U]>;
2063-
2064-
/**
2065-
* Returns an OrderedSet of the same type "zipped" with the provided
2066-
* collections.
2067-
*
2068-
* @see IndexedIterator.zip
2069-
*
2070-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
2071-
*
2072-
* ```js
2073-
* const a = OrderedSet([ 1, 2, 3 ])
2074-
* const b = OrderedSet([ 4, 5, 6 ])
2075-
* const c = a.zip(b)
2076-
* // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2077-
* ```
2078-
*/
20792034
zip<U,V>(other1: Collection<any, U>, other2: Collection<any, V>): OrderedSet<[T,U,V]>;
2080-
2081-
/**
2082-
* Returns an OrderedSet of the same type "zipped" with the provided
2083-
* collections.
2084-
*
2085-
* @see IndexedIterator.zip
2086-
*
2087-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
2088-
*
2089-
* ```js
2090-
* const a = OrderedSet([ 1, 2, 3 ])
2091-
* const b = OrderedSet([ 4, 5, 6 ])
2092-
* const c = a.zip(b)
2093-
* // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2094-
* ```
2095-
*/
20962035
zip(...collections: Array<Collection<any, any>>): OrderedSet<any>;
20972036

20982037
/**
20992038
* Returns a OrderedSet of the same type "zipped" with the provided
21002039
* collections.
21012040
*
2102-
* @see IndexedIterator.zipAll
2103-
*
21042041
* Unlike `zip`, `zipAll` continues zipping until the longest collection is
21052042
* exhausted. Missing values from shorter collections are filled with `undefined`.
21062043
*
@@ -2110,13 +2047,15 @@ declare module Immutable {
21102047
* const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
21112048
* ```
21122049
*/
2050+
zipAll<U>(other: Collection<any, U>): OrderedSet<[T,U]>;
2051+
zipAll<U,V>(other1: Collection<any, U>, other2: Collection<any, V>): OrderedSet<[T,U,V]>;
21132052
zipAll(...collections: Array<Collection<any, any>>): OrderedSet<any>;
21142053

21152054
/**
21162055
* Returns an OrderedSet of the same type "zipped" with the provided
21172056
* collections by using a custom `zipper` function.
21182057
*
2119-
* @see IndexedIterator.zipWith
2058+
* @see Seq.Indexed.zipWith
21202059
*/
21212060
zipWith<U, Z>(
21222061
zipper: (value: T, otherValue: U) => Z,
@@ -2331,31 +2270,7 @@ declare module Immutable {
23312270
* ```
23322271
*/
23332272
zip<U>(other: Collection<any, U>): Stack<[T,U]>;
2334-
2335-
/**
2336-
* Returns a Stack "zipped" with the provided collections.
2337-
*
2338-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
2339-
*
2340-
* ```js
2341-
* const a = Stack([ 1, 2, 3 ]);
2342-
* const b = Stack([ 4, 5, 6 ]);
2343-
* const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2344-
* ```
2345-
*/
23462273
zip<U,V>(other: Collection<any, U>, other2: Collection<any,V>): Stack<[T,U,V]>;
2347-
2348-
/**
2349-
* Returns a Stack "zipped" with the provided collections.
2350-
*
2351-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
2352-
*
2353-
* ```js
2354-
* const a = Stack([ 1, 2, 3 ]);
2355-
* const b = Stack([ 4, 5, 6 ]);
2356-
* const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2357-
* ```
2358-
*/
23592274
zip(...collections: Array<Collection<any, any>>): Stack<any>;
23602275

23612276
/**
@@ -2370,6 +2285,8 @@ declare module Immutable {
23702285
* const c = a.zipAll(b); // Stack [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
23712286
* ```
23722287
*/
2288+
zipAll<U>(other: Collection<any, U>): Stack<[T,U]>;
2289+
zipAll<U,V>(other: Collection<any, U>, other2: Collection<any,V>): Stack<[T,U,V]>;
23732290
zipAll(...collections: Array<Collection<any, any>>): Stack<any>;
23742291

23752292
/**
@@ -2906,31 +2823,7 @@ declare module Immutable {
29062823
* ```
29072824
*/
29082825
zip<U>(other: Collection<any, U>): Seq.Indexed<[T,U]>;
2909-
2910-
/**
2911-
* Returns a Seq "zipped" with the provided collections.
2912-
*
2913-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
2914-
*
2915-
* ```js
2916-
* const a = Seq([ 1, 2, 3 ]);
2917-
* const b = Seq([ 4, 5, 6 ]);
2918-
* const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2919-
* ```
2920-
*/
29212826
zip<U,V>(other: Collection<any, U>, other2: Collection<any, V>): Seq.Indexed<[T,U,V]>;
2922-
2923-
/**
2924-
* Returns a Seq "zipped" with the provided collections.
2925-
*
2926-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
2927-
*
2928-
* ```js
2929-
* const a = Seq([ 1, 2, 3 ]);
2930-
* const b = Seq([ 4, 5, 6 ]);
2931-
* const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2932-
* ```
2933-
*/
29342827
zip(...collections: Array<Collection<any, any>>): Seq.Indexed<any>;
29352828

29362829
/**
@@ -2945,6 +2838,8 @@ declare module Immutable {
29452838
* const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
29462839
* ```
29472840
*/
2841+
zipAll<U>(other: Collection<any, U>): Seq.Indexed<[T,U]>;
2842+
zipAll<U,V>(other: Collection<any, U>, other2: Collection<any, V>): Seq.Indexed<[T,U,V]>;
29482843
zipAll(...collections: Array<Collection<any, any>>): Seq.Indexed<any>;
29492844

29502845
/**
@@ -3525,33 +3420,7 @@ declare module Immutable {
35253420
* ```
35263421
*/
35273422
zip<U>(other: Collection<any, U>): Collection.Indexed<[T,U]>;
3528-
3529-
/**
3530-
* Returns a Collection of the same type "zipped" with the provided
3531-
* collections.
3532-
*
3533-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
3534-
*
3535-
* ```js
3536-
* const a = List([ 1, 2, 3 ]);
3537-
* const b = List([ 4, 5, 6 ]);
3538-
* const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
3539-
* ```
3540-
*/
35413423
zip<U,V>(other: Collection<any, U>, other2: Collection<any, V>): Collection.Indexed<[T,U,V]>;
3542-
3543-
/**
3544-
* Returns a Collection of the same type "zipped" with the provided
3545-
* collections.
3546-
*
3547-
* Like `zipWith`, but using the default `zipper`: creating an `Array`.
3548-
*
3549-
* ```js
3550-
* const a = List([ 1, 2, 3 ]);
3551-
* const b = List([ 4, 5, 6 ]);
3552-
* const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
3553-
* ```
3554-
*/
35553424
zip(...collections: Array<Collection<any, any>>): Collection.Indexed<any>;
35563425

35573426
/**
@@ -3566,6 +3435,8 @@ declare module Immutable {
35663435
* const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
35673436
* ```
35683437
*/
3438+
zipAll<U>(other: Collection<any, U>): Collection.Indexed<[T,U]>;
3439+
zipAll<U,V>(other: Collection<any, U>, other2: Collection<any, V>): Collection.Indexed<[T,U,V]>;
35693440
zipAll(...collections: Array<Collection<any, any>>): Collection.Indexed<any>;
35703441

35713442
/**

0 commit comments

Comments
 (0)