push-stream-std

@push-stream-std/push-chunks-of (0.0.5)

Published 2026-07-20 18:59:22 +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.5
"@push-stream-std/push-chunks-of": "0.0.5"

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 (default true) – Whether to emit a partial final chunk when the stream ends with leftover values.
  • Returns A through stream with pipe(), write(), end(), abort(), resume(), paused, and ended.

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
Details
npm
2026-07-20 18:59:22 +00:00
0
SEE LICENSE IN LICENSE
3.3 KiB
Assets (1)
Versions (5) View all
0.0.7 2026-07-21
0.0.6 2026-07-20
0.0.5 2026-07-20
0.0.4 2026-07-19
0.0.3 2026-07-19