push-stream-std

@push-stream-std/push-delay (0.0.8)

Published 2026-07-21 03:57:59 +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.8
"@push-stream-std/push-delay": "0.0.8"

About this package

@push-stream-std/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-pushable';
import { collect } from '@push-stream-std/push-concat';

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

Why

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. Default 1000.
    • options.ordered boolean — If true (default), preserve emission order. If false, emit each value when its timer fires.
  • 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 22 or later. ESM only.

Keywords

push-stream delay schedule timer
Details
npm
2026-07-21 03:57:59 +00:00
1
SEE LICENSE IN LICENSE
latest
3.7 KiB
Assets (1)
Versions (5) View all
0.0.8 2026-07-21
0.0.7 2026-07-20
0.0.6 2026-07-20
0.0.5 2026-07-19
0.0.3 2026-07-19