function unzip
unzip<T, U>(pairs: readonly [T, U][]): [T[], U[]]Builds two separate arrays from the given array of 2-tuples, with the first returned array holding all first tuple elements and the second one holding all the second elements.
import { unzip } from "@std/collections/unzip"; import { assertEquals } from "@std/assert/assert_equals"; const parents = [ ["Maria", "Jeff"], ["Anna", "Kim"], ["John", "Leroy"], ] as [string, string][]; const [moms, dads] = unzip(parents); assertEquals(moms, ["Maria", "Anna", "John"]); assertEquals(dads, ["Jeff", "Kim", "Leroy"]);
Type Parameters
TU