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

x/iter/mod.ts>pair

A bunch of utilities for working with iterables, many inspired by the native array methods.
Latest
function pair
import { pair } from "https://deno.land/x/iter@v3.2.3/mod.ts";

Creates a new iterable containing tuples of each element of it1 and it2.

Examples

Example 1

import * as iter from "https://deno.land/x/iter/mod.ts";

const pairs = iter.pair([1, 2, 3], ["a", "b", "c"]);

for (pair of pairs) {
  console.log(pair);
}

// -> [1, "a"]
// -> [2, "b"]
// -> [3, "c"]

Parameters

it1: Iterable<T>
  • Iterable to be mapped to the first element of each tuple in the new iterator.
it2: Iterable<U>
  • Iterable to be mapped to the second element of each tuple in the new iterator.

Returns

An iterable containing pairs of items taken from it1 and it2