Creates a throttled function that only invokes fn at most once per limit milliseconds.
fn
limit
The function to throttle.
Minimum time in milliseconds between calls (default: 300ms).
A throttled version of fn.
const log = (msg: string) => console.log(msg);const throttledLog = throttle(log, 1000);window.addEventListener("scroll", () => throttledLog("scrolling")); Copy
const log = (msg: string) => console.log(msg);const throttledLog = throttle(log, 1000);window.addEventListener("scroll", () => throttledLog("scrolling"));
1.1.0
Creates a throttled function that only invokes
fn
at most once perlimit
milliseconds.