method Enumerable.prototype.collect
Enumerable.prototype.collect(): Promise<T[]>

Collect all items from this async iterable into an array.

This consumes the entire iterable and returns a Promise that resolves to an array containing all items.

Examples

Collect process output

import { run } from "jsr:@j50n/proc";

const lines = await run("echo", "-e", "a\\nb\\nc").lines.collect();
// ["a", "b", "c"]

Return Type

Promise<T[]>

A Promise resolving to an array of all items.

Usage

import { Enumerable } from ".";