method StreamClass.prototype.chunkEvery
Private
StreamClass.prototype.chunkEvery(
count: number,
step?,
leftover?: T[] | "discard"
): StreamClass<T[], E>

Groups values into arrays of count, sliding by step (Elixir's full chunk_every/4): step < count overlaps windows, step > count skips between them. leftover rules the trailing partial chunk: emitted as-is by default, 'discard' drops it, an array pads it up to count. Failures pass through between chunks without breaking the one being assembled — a bad row never voids the batch around it.

await Stream.from([1, 2, 3, 4, 5]).chunkEvery(2).collect(); // [[1, 2], [3, 4], [5]]
await Stream.from([1, 2, 3, 4, 5]).chunkEvery(3, 2, 'discard').collect(); // [[1, 2, 3], [3, 4, 5]]
await Stream.from([1, 2, 3, 4]).chunkEvery(3, 3, [0, 0]).collect(); // [[1, 2, 3], [4, 0, 0]]

Parameters

count: number
optional
step = count
optional
leftover: T[] | "discard"

Return Type

Usage

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