@push-stream-std/push-debounce (0.0.3)
Published 2026-07-19 21:14:07 +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.3"@push-stream-std/push-debounce": "0.0.3"About this package
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-values';
import { collect } from '@push-stream-std/push-collect';
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
Description
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. Defaultfalse. - options.trailing
boolean— If true, emit the last value after the quiet period. Defaulttrue.
- options.leading
- 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 18 or later. ESM only.
License
MIT
Keywords
push-stream
stream
debounce