push-stream-std

@push-stream-std/push-debounce (0.0.7)

Published 2026-07-21 03:57:52 +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-debounce@0.0.7
"@push-stream-std/push-debounce": "0.0.7"

About this package

@push-stream-std/push-debounce

Debounce stream values.

Published as @push-stream-std/push-debounce.

Synopsis

import { debounce } from '@push-stream-std/push-debounce';
import { values } from '@push-stream-std/push-pushable';
import { collect } from '@push-stream-std/push-concat';

const source = values(['h', 'he', 'hel', 'hell', 'hello']);
const debounced = debounce(50, { trailing: true });

collect(source.pipe(debounced), (err, result) => {
  console.log(result); // ['hello']
});

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-debounce

Why

A through stream that debounces incoming values. Each new value resets the debounce timer, emitting only after the specified wait period elapses without new input. Supports leading (emit first value immediately) and trailing (emit last value after quiet period) modes, making it suitable for search inputs, button clicks, and rate-limited event handling.

API

debounce(wait, options)

Returns a through stream that debounces values.

  • wait number — Debounce wait time in milliseconds.
  • options object (optional)
    • options.leading boolean — If true, emit the first value immediately on each burst. Default false.
    • options.trailing boolean — If true, emit the last value after the quiet period. Default true.
  • Returns through — A push-stream through that forwards debounced values downstream.

Tests

npm test

Tests cover leading-only, trailing-only, both combined, rapid sequential values, and abort/end during pending debounce.

Requirements

Node.js 22 or later. ESM only.

Keywords

push-stream stream debounce
Details
npm
2026-07-21 03:57:52 +00:00
0
SEE LICENSE IN LICENSE
latest
3.7 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