import { enumerate } from "https://deno.land/x/proc@0.22.1/mod.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);
}