Skip to main content

zip

Functions​

zip()​

zip<T, U>(arrayOrPromise1, arrayOrPromise2): Promise<[T, U][]>

Creates an array of arrays, where the first element of the provided arrays are grouped together, and the second element of the provided arrays are grouped together.

Type Parameters​

Type Parameter
T
U

Parameters​

ParameterTypeDescription
arrayOrPromise1T[] | Promise<T[]>The first array or Promise of an array to iterate over.
arrayOrPromise2U[] | Promise<U[]>The first array or Promise of an array to iterate over.

Returns​

Promise<[T, U][]>

A Promise that resolves with a new array of arrays.

Example​

const array1 = [1, 2, 3];
const array2 = ["a", "b", "c"];
const result = await zip(array1, array2);
console.log(result); // Output: [[1, "a"], [2, "b"], [3, "c"]]

Defined in​

src/zip/index.ts:18