@push-stream-std/push-delay (0.0.6)
Published 2026-07-20 18:59:30 +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-delay@0.0.6"@push-stream-std/push-delay": "0.0.6"About this package
push-delay
Delay each value by fixed or dynamic amount.
Published as @push-stream-std/push-delay.
Synopsis
import { delay } from '@push-stream-std/push-delay';
import { values } from '@push-stream-std/push-values';
import { collect } from '@push-stream-std/push-collect';
const source = values([1, 2, 3]);
const delayed = delay(100);
collect(source.pipe(delayed), (err, result) => {
console.log(result); // [1, 2, 3] each emitted 100ms apart
});
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-delay
Description
A through stream that delays each incoming value by a configurable amount. Supports both a fixed delay (number) and a dynamic delay computed per value (function). When ordered mode is true (default), values are emitted in original order regardless of individual delay durations. When false, each value is emitted as soon as its timer expires.
API
delay(options)
Returns a through stream that delays values.
- options
number | object— Either a fixed delay in milliseconds, or an options object:- options.delay
number | (data) => number— Delay in milliseconds, or a function returning delay per value. Default1000. - options.ordered
boolean— If true (default), preserve emission order. If false, emit each value when its timer fires.
- options.delay
- Returns
through— A push-stream through that delays values downstream.
Tests
npm test
Tests cover fixed delay, dynamic delay, ordered mode, unordered mode, zero-delay passthrough, abort during pending delays, and end-after-source-end.
Requirements
Node.js 18 or later. ESM only.
License
MIT
Keywords
push-stream
delay
schedule
timer