@push-stream-std/push-buffer (0.0.4)
Published 2026-07-19 23:20:04 +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-buffer@0.0.4"@push-stream-std/push-buffer": "0.0.4"About this package
push-buffer
Buffer stream during backpressure with overflow strategies.
Published as @push-stream-std/push-buffer.
Synopsis
import buffer from '@push-stream-std/push-buffer';
const buffered = buffer({
size: 100,
overflow: 'drop-oldest',
onOverflow: (count) => console.warn('overflow', count)
});
source.pipe(buffered).pipe(sink);
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-buffer
Description
A through stream that decouples producer and consumer speeds by buffering values during backpressure. When the downstream sink is paused, incoming values are stored in an internal buffer with configurable overflow handling. Uses a head pointer pattern for amortized O(1) reads from the buffer.
API
buffer(options)
Creates a buffering through stream.
- options
object(optional):- size
number(default1000) – Maximum buffer size. - overflow
string(default'block') – Overflow strategy:'block'(drop new values when full),'drop-oldest'(remove oldest entry),'drop-newest'(ignore newest entry), or'error'(emit an error and end the stream). - onOverflow
(count) => void(optional) – Called on each overflow event with the cumulative overflow count.
- size
- Returns A through stream with
pipe(),write(),end(),abort(),resume(),paused, andended.
Tests
npm test
Tests cover buffering when sink is paused, passthrough when sink is not paused, buffer size limit with block strategy, drop-oldest and drop-newest overflow behaviors, onOverflow callback invocation, abort handling, and empty source passthrough.
Requirements
Node.js 18 or later. ESM only.
License
MIT
Keywords
push-stream
stream
buffer
backpressure