@push-stream-std/push-chunks-of (0.0.4)
Published 2026-07-19 23:31:23 +00:00 by Dvorak
Installation
@push-stream-std:registry=https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/npm install @push-stream-std/push-chunks-of@0.0.4"@push-stream-std/push-chunks-of": "0.0.4"About this package
push-chunks-of
Split stream into fixed-size chunks.
Published as @push-stream-std/push-chunks-of.
Synopsis
import chunksOf from '@push-stream-std/push-chunks-of';
source.pipe(chunksOf(3)).pipe(sink);
// Input: 1, 2, 3, 4, 5, 6, 7
// Output: [1,2,3], [4,5,6], [7]
Install
npm config set @push-stream-std:registry https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/
npm config set -- //hub.kl1.tenere.ai/api/packages/push-stream-std/npm/:_authToken "$PACKAGE_TOKEN"
npm install @push-stream-std/push-chunks-of
Description
A through stream that buffers incoming values and emits arrays of a fixed size. Each emitted chunk is a new array slice. When the source ends, any remaining partial buffer is emitted as a final chunk. Throws if size <= 0.
API
chunksOf(size, options)
Creates a chunking through stream.
- size
number– Fixed number of elements per chunk. Must be positive. - options
object(optional):- yieldPartial
boolean(defaulttrue) – Whether to emit a partial final chunk when the stream ends with leftover values.
- yieldPartial
- Returns A through stream with
pipe(),write(),end(),abort(),resume(),paused, andended.
Tests
npm test
Tests cover basic chunking with size 3, size 1 chunks, chunk size larger than the total stream values, empty source (no chunks emitted), and backpressure where the sink pauses after receiving one chunk.
Requirements
Node.js 18 or later. ESM only.
License
MIT
Keywords
push-stream
stream
chunks
batch