push-stream-std

@push-stream-std/push-buffer (0.0.6)

Published 2026-07-20 12:18:51 +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.6
"@push-stream-std/push-buffer": "0.0.6"

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 (default 1000) – 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.
  • Returns A through stream with pipe(), write(), end(), abort(), resume(), paused, and ended.

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
Details
npm
2026-07-20 12:18:51 +00:00
0
SEE LICENSE IN LICENSE
3.7 KiB
Assets (1)
Versions (8) View all
0.0.10 2026-07-21
0.0.9 2026-07-21
0.0.8 2026-07-20
0.0.7 2026-07-20
0.0.6 2026-07-20