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

x/proc/tools/deps/proc.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.21.7/tools/deps/proc.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.