method StreamClass.prototype.collect
Private
StreamClass.prototype.collect(): Task<T[], E>

Collects every value, fail-fast: the first failure element rejects the Task with it (declared — so .result() reflects it bare and typed). The Result.all of streams.

NOT values(): in JS .values() produces an iterator (Array, Map, Set, ReadableStream) rather than consuming one, and partition().values filters failures out while this throws on them — the same word for opposite behaviour inside one module.

NOT all() either, tempting as the Result.all mirror was: every other language in this module's lineage spends "all" on the predicate — Rust's StreamExt::all(pred), Elixir's Enum.all?/2 — which is StreamClass#every here. collect is Rust's word for gathering and collides with nothing.

Rust gets one collect for both this and StreamClass#results because the target type picks the behaviour; JS cannot dispatch on return type, so the two need two names.

await Stream.from(['a', 'b']).collect(); // ['a', 'b']

Return Type

Task<T[], E>

Usage

import { StreamClass } from "lib/stream/stream.ts";