Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fathym_common/src/src.deps.ts>zip

The Fathym Reference Architecture provides the common foundation for applications built in Typescript.
Go to Latest
function zip
import { zip } from "https://deno.land/x/fathym_common@v0.0.155/src/src.deps.ts";

Builds N-tuples of elements from the given N arrays with matching indices, stopping when the smallest array's end is reached.

Examples

Example 1

import { zip } from "https://deno.land/std@0.224.0/collections/zip.ts";
import { assertEquals } from "https://deno.land/std@0.224.0/assert/assert_equals.ts";

const numbers = [1, 2, 3, 4];
const letters = ["a", "b", "c", "d"];
const pairs = zip(numbers, letters);

assertEquals(
  pairs,
  [
    [1, "a"],
    [2, "b"],
    [3, "c"],
    [4, "d"],
  ],
);

Type Parameters

T extends unknown[]

the type of the tuples produced by this function.

Parameters

...arrays: [K in keyof T]: ReadonlyArray<T[K]>