unzipWith
Import from @varavel/vdl-plugin-sdk/utils/arrays.
function unzipWith<T, R>(target, iteratee): R[];
Unzips an array of arrays, applying an iteratee function to regrouped elements.
Type Parameters
| Type Parameter |
|---|
T |
R |
Parameters
| Parameter | Type | Description |
|---|---|---|
target | readonly T[][] | The nested array to unzip. This is an array of arrays, where each inner array contains elements to be unzipped. |
iteratee | (...args) => R | A function to transform the unzipped elements. |
Returns
R[]
A new array of unzipped and transformed elements.
Example
const nestedArray = [[1, 2], [3, 4], [5, 6]];
const result = unzipWith(nestedArray, (item, item2, item3) => item + item2 + item3);
// result will be [9, 12]