ReferencebufferCount
Reference · 12
bufferCount
bufferCount
Accumulates values into a fixed-length array and emits it.
Signature
bufferCount(bufferSize: number, startBufferEvery?: number): OperatorFunction
Marble diagram
in: --1-2-3-4-5--|
bufferCount(2): ----[1,2]-[3,4]-[5]-|
What it does
Collects next values into an array of length bufferSize and emits the finished buffer. When the stream completes, it emits the remainder (even if smaller than bufferSize). The startBufferEvery parameter controls sliding windows.
When to use
Batching events before sending (logs, analytics), grouping WebSocket messages, chunked loading.
See also
bufferTime, window, pairwise
script.ts
CONSOLE · Console output
Hit Run to see the result...