Skip to content

Instantly share code, notes, and snippets.

@oliv37
oliv37 / throttle.js
Last active July 19, 2019 18:07
throttle es6 implementation with immediate call
function throttle(func, wait = 100) {
let timer = null;
return function(...args) {
if (timer === null) {
func.apply(this, args);
timer = setTimeout(() => timer = null, wait);
}
};
}