Skip to main content
Module

x/fun/mod.ts>array.zip

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function array.zip
import { array } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { zip } = array;

Collect the values of many arrays into an array of tuples. Each tuple contains an element from each of the input arrays at a shared index. The number of tuples in the returned array will match the minimum length of the input arrays. ie. If any input array is empty, then the output array will be empty.

Examples

Example 1

import * as A from "./array.ts";

const result1 = A.zip([1, 2, 3], ["a", "b", "c"]);
// [[1, "a"], [2, "b"], [3, "c"]]
const result2 = A.zip([], A.range(100)); // []

Type Parameters

A extends ReadonlyArray<AnyArray>

Parameters

...arrays: A

Returns

ReadonlyArray<[K in keyof A]: TypeOf<A[K]>>