Skip to content

unzip

Import from @varavel/vdl-plugin-sdk/utils/arrays.

function unzip<T>(zipped): Unzip<T>;

Gathers elements in the same position in an internal array from a grouped array of elements and returns them as a new array.

Type Parameters

Type Parameter Description
T extends unknown[] The type of elements in the nested array.

Parameters

Parameter Type Description
zipped readonly [...T[]][] The nested array to unzip.

Returns

Unzip\<T>

A new array of unzipped elements.

Example

const zipped = [['a', true, 1],['b', false, 2]];
const result = unzip(zipped);
// result will be [['a', 'b'], [true, false], [1, 2]]