fn
zip
v0.0.10testedCombines several arrays into an array of tuples, stopping at the shortest input
Examples
ts
zip([1, 2, 3], ['a', 'b', 'c']) // => [[1, 'a'], [2, 'b'], [3, 'c']]ts
zip([1, 2], ['a', 'b'], [true, false]) // => [[1, 'a', true], [2, 'b', false]]ts
zip([1, 2, 3], ['a']) // => [[1, 'a']] (truncated to the shortest)Signatures
ts
export function zip<A>(a: A[]): Array<[A]>;ts
export function zip<A, B>(a: A[], b: B[]): Array<[A, B]>;ts
export function zip<A, B, C>(a: A[], b: B[], c: C[]): Array<[A, B, C]>;ts
export function zip<A, B, C, D>(a: A[], b: B[], c: C[], d: D[]): Array<[A, B, C, D]>;ts
export function zip<A, B, C, D, E>(a: A[], b: B[], c: C[], d: D[], e: E[]): Array<[A, B, C, D, E]>;Parameters
| Parameter | Type | Description |
|---|---|---|
arrays? | any[][] | The arrays to zip together |
Returns
any[][]An array of tuples; its length equals the shortest input array