Skip to main content
Module

x/itertools/mod.ts>enumerate

🦕 A TypeScript port of Python's itertools and more-itertools for Deno
Latest
function enumerate
import { enumerate } from "https://deno.land/x/itertools@v1.1.2/mod.ts";

Returns an iterable of enumeration pairs. Iterable must be a sequence, an iterator, or some other object which supports iteration. The elements produced by returns a tuple containing a counter value (starting from 0 by default) and the values obtained from iterating over given iterable.

Example:

import { enumerate } from 'itertools';

console.log([...enumerate(['hello', 'world'])]);
// [0, 'hello'], [1, 'world']]

Parameters

iterable: Iterable<T>
optional
start = [UNSUPPORTED]

Returns

Iterable<[number, T]>