UNPKG

seitu

Version:
25 lines • 990 B
import { i as Subscribable, n as Readable } from "./index-B0IeflOl.mjs"; //#region src/core/throttled/index.d.ts interface Throttled<T> extends Readable<T>, Subscribable<T> { /** Drop a pending trailing update and reset the throttle window. */ cancel: () => void; /** Emit a pending trailing update now and reset the window. No-op if nothing is pending. */ flush: () => void; } /** * Throttles updates from a source to at most once per `wait` ms (leading, then * trailing). Unsubscribed `get()` reads through; subscribed `get()` returns the * last emitted value. * * @example * ```ts twoslash * import { createStore, createThrottled } from 'seitu' * * const store = createStore('') * const throttled = createThrottled(store, 300) * throttled.subscribe(value => console.log('throttled:', value)) * ``` */ declare function createThrottled<T>(source: Readable<T> & Subscribable<T>, wait: number): Throttled<T>; //#endregion export { createThrottled as n, Throttled as t };