Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

throttle

Creates a throttled function that only invokes fn at most once per every wait milliseconds. The first call executes immediately (leading edge). If called again during the wait period, the last call will be executed at the end of the wait period (trailing edge).

@example
const throttled = throttle((name) => console.log('called', name), 1000)
throttled('Alice') // logs 'called Alice' immediately
throttled('Bob') // skipped (within 1000ms)
throttled('Charlie') // skipped (within 1000ms)
// after 1000ms, logs 'called Charlie' again (trailing call)
function throttle<T extends (this: any, ...args: any[]) => unknown>(callback: T, wait: number): (this: ThisParameterType<T>, ...args: Parameters<T>) => void;
§
throttle<T extends (this: any, ...args: any[]) => unknown>(callback: T, wait: number): (this: ThisParameterType<T>, ...args: Parameters<T>) => void
[src]

§Type Parameters

§
T extends (this: any, ...args: any[]) => unknown
[src]

§Parameters

§
callback: T
[src]

The function to throttle

§
wait: number
[src]

The number of milliseconds to throttle invocations to

§Return Type

§
(this: ThisParameterType<T>, ...args: Parameters<T>) => void
[src]

A throttled version of the function