ThrottledFunction

import { ThrottledFunction } from "jsr:@ende/async/unstable-throttle";

interface ยท experimental

interface ThrottledFunction<T extends Array<unknown>>

A throttled function that will be executed at most once during the specified timeframe in milliseconds.

Call signatures

Call signature

(...args: T): void

Properties

throttling

readonly throttling: boolean

Returns a boolean indicating whether the function is currently being throttled.

lastExecution

readonly lastExecution: number

Returns the timestamp of the last execution of the throttled function. It is set to -Infinity if it has not been called yet, or reset is called after the last call.

Methods

clear

clear(): void

Clears the throttling state. ThrottledFunction.lastExecution will be reset to -Infinity and ThrottledFunction.throttling will be reset to false.

flush

flush(): void

Execute the last throttled call (if any) and clears the throttling state.

Source