1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 2x 2x | // https://codeburst.io/throttling-and-debouncing-in-javascript-646d076d0a44 export function throttle(fn, delay) { let lastCall = 0; return function(...args) { const now = new Date().getTime(); if (now - lastCall < delay) { return; } lastCall = now; return fn(...args); }; } |