UNPKG

@maz-ui/utils

Version:

Utils of maz-ui for JavaScript/TypeScript users

12 lines (11 loc) 303 B
function i(e, a) { let l = !1, n, t; return function(...o) { l ? (clearTimeout(n), n = setTimeout(() => { Date.now() - t >= a && (e.apply(this, o), t = Date.now()); }, Math.max(a - (Date.now() - t), 0))) : (e.apply(this, o), t = Date.now(), l = !0); }; } export { i as throttle };