Skip to content

Function: zip()

ts
function zip<T>(...arrays): unknown[][];

Zips multiple arrays into tuples, stopping at the shortest array length. 将多个数组按最短长度 zip 为元组数组。

Type Parameters

Type Parameter
T extends readonly unknown[][]

Parameters

ParameterTypeDescription
...arraysTArrays to zip / 待 zip 的数组列表

Returns

unknown[][]

Zipped tuples / zip 后的元组数组

Example

ts
zip([1, 2], ['a', 'b'])
// => [[1, 'a'], [2, 'b']]

Since

1.2.0

Released under the MIT License.