mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
build(utils): build26 from 45504a2b
This commit is contained in:
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
//#region src/function/throttle.d.ts
|
||||
/** A throttled function that can be cancelled. */
|
||||
interface Throttled<Args extends unknown[]> {
|
||||
(...args: Args): void;
|
||||
/** Cancel any pending trailing-edge invocation. */
|
||||
cancel(): void;
|
||||
}
|
||||
interface ThrottleOptions {
|
||||
/**
|
||||
* When `true`, the first call invokes `fn` immediately (leading edge) and
|
||||
* starts the cooldown window. Calls during cooldown are coalesced and fire
|
||||
* on the trailing edge. If no calls arrive during the window the next call
|
||||
* is treated as a fresh leading invocation.
|
||||
*/
|
||||
leading?: boolean;
|
||||
}
|
||||
/**
|
||||
* Throttle: limits `fn` to at most once per `ms` window.
|
||||
*
|
||||
* - Default (no options): trailing-edge only — the first call schedules a
|
||||
* timer; subsequent calls within the window update the arguments. The
|
||||
* function fires once per window with the latest arguments.
|
||||
* - `{ leading: true }`: leading + trailing — the first call invokes
|
||||
* immediately and opens a cooldown window. Subsequent calls within the
|
||||
* window are coalesced to a single trailing-edge invocation.
|
||||
*/
|
||||
declare function throttle<Args extends unknown[]>(fn: (...args: Args) => void, ms: number, options?: ThrottleOptions): Throttled<Args>;
|
||||
//#endregion
|
||||
export { ThrottleOptions, Throttled, throttle };
|
||||
//# sourceMappingURL=throttle.d.ts.map
|
||||
Reference in New Issue
Block a user