Skip to content

Instantly share code, notes, and snippets.

function debouncer(callBack, timer) {
let timeoutId;
return function () {
let context = this;
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
callBack.apply(context, arguments);
clearTimeout(timeoutId);
}, timer);
};
function throttling(callBack, timer) {
let isBusy = false;
let timeoutId;
return function () {
let context = this;
if (!isBusy) {
isBusy = true;
callBack.call(context, ...arguments);
timeoutId = setTimeout(() => {