Skip to main content

unzip

Functions

unzip()

unzip<T, U>(arrayOrPromise): Promise<[T[], U[]]>

Unzips an array of tuples into two arrays.

Type Parameters

Type ParameterDescription
TThe type of the first element in the tuple.
UThe type of the second element in the tuple.

Parameters

ParameterTypeDescription
arrayOrPromise[T, U][] | Promise<[T, U][]>Array or Promise of an array to unzip

Returns

Promise<[T[], U[]]>

A Promise that resolves with a new array of arrays.

Example

const array = [[1, 'a'], [2, 'b'], [3, 'c']];
const result = await unzip(array);
console.log(result); // Output: [[1, 2, 3], ['a', 'b', 'c']]

Defined in

src/unzip/index.ts:19