// ets_tracing: off import * as Tp from "../../Tuple/index.js" import { append_, empty } from "../core.js" import type { Chunk } from "../definition.js" import { forEach_ } from "./forEach.js" /** * The function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays */ export function unzip( as: Chunk> ): Tp.Tuple<[Chunk, Chunk]> { let fa: Chunk = empty() let fb: Chunk = empty() forEach_(as, ({ tuple: [a, b] }) => { fa = append_(fa, a) fb = append_(fb, b) }) return Tp.tuple(fa, fb) }