UNPKG

@johngw/stream

Version:

Reactive programming tools using the WHATWG Streams API.

29 lines 645 B
/** * Debouncing behavior to queue the trailing event. * * @group Transformers * @see {@link debounce:function} * @example * ``` * --a----T20--b-c----T20--d------| * * debounce(20) * // Same as... * debounce(20, new DebounceTrailingBehavior()) * * ---T20-a------T20-c------T20-d-- * ``` */ export class DebounceTrailingBehavior { postTimer(state, chunk, controller) { const enqueue = !state.queued; if (enqueue) { controller.enqueue(chunk); return { ...state, queued: enqueue, }; } } } //# sourceMappingURL=TrailingBehavior.js.map