UNPKG

@johngw/stream

Version:

Reactive programming tools using the WHATWG Streams API.

31 lines 764 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DebounceLeadingBehavior = void 0; /** * Debouncing behavior to queue the leading event. * * @group Transformers * @see {@link debounce:function} * @example * ``` * --a-b-c--T20-d--| * * debounce(20, new DebounceLeadingBehavior()) * * --a----------d--- * ``` */ class DebounceLeadingBehavior { preTimer(state, chunk, controller) { const enqueue = !state.timer && !state.queued; if (enqueue) { controller.enqueue(chunk); return { ...state, queued: enqueue, }; } } } exports.DebounceLeadingBehavior = DebounceLeadingBehavior; //# sourceMappingURL=LeadingBehavior.js.map