Skip to main content
Module

x/proc/mod3.ts>enumerate

A better way to work with processes in Deno.
Go to Latest
function enumerate
Re-export
import { enumerate } from "https://deno.land/x/proc@0.20.33/mod3.ts";

Enumerable factory.

Use this instead of creating an Enumerable directly as it more flexible and prevents stacking (a potential performance issue).

Examples

Convert an array into AsyncIterable.

for await (const n of enumerate([1, 2, 3])) {
  console.log(n);
}

Use enumerate to read a file line by line.

const file = await Deno.open(resolve("./warandpeace.txt.gz"));

for await (const line of enumerate(file.readable).run("gunzip").lines) {
  console.log(line);
}

Parameters

optional
iter: AsyncIterable<T> | Iterable<T> | null

An Iterable or AsynIterable; null or undefined assume empty.