JSFiddle - React, Tailwind, and code Playground

by moob

JavaScript

var throttle = {};
throttle.timers = {};
throttle.debounceByIdent = function(fn, ident, delay){
            var context = this, args = arguments;
            clearTimeout(throttle.timers[ident]);
            throttle.timers[ident] = setTimeout(function () {
                fn.apply(context, args);
            }, delay);
    }; 
   
   
    var i = 5;
while(i--){ 
var dn = Date.now();
console.log(dn);
	var fn = function(){console.warn("YAYAYAYAYAYA"+i+" "+dn);};
    throttle.debounceByIdent(fn, 'hmm', 200);
    throttle.debounceByIdent(fn, 'hmm2', 2000);
}