method StreamClass.prototype.chunkBy
Private
StreamClass.prototype.chunkBy(key: (value: T) => unknown): StreamClass<T[], E>

Chunks consecutive values sharing a key — Elixir's chunk_by/2; a key change closes the chunk. Failures are transparent: they pass through without closing the chunk around them, consistent with dedup.

await Stream.from([1, 3, 2, 4, 5]).chunkBy((n) => n % 2).collect(); // [[1, 3], [2, 4], [5]]

Parameters

key: (value: T) => unknown

Return Type

Usage

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