函数延时执行
Opened this issue · 0 comments
hszy00232 commented
/**
* @param {[type]} functor [函子]
* @param {[type]} wait [延迟时间]
* @return {[type]} [延迟wait时间执行一次functor]
*/
function throttle(functor, wait){
var timer = null;
return function() {
var _args = [].slice.call(arguments);
if(!timer){
timer = setTimeout(function() {
timer = null;
}, wait);
return functor.apply(this, _args);
}
}
}