Cleanup a bit of javascript

This commit is contained in:
the-djmaze 2023-02-21 12:59:56 +01:00
parent 0b8ec5c664
commit 938c209869
3 changed files with 54 additions and 48 deletions

8
dev/prototype.js vendored
View file

@ -53,7 +53,7 @@
return function(...args) {
timer && clearTimeout(timer);
timer = setTimeout(()=>{
func.apply(this, args)
func.apply(this, args);
timer = 0;
}, ms);
};
@ -68,12 +68,10 @@
Function.prototype.throttle = function(ms) {
let func = this, timer;
return function(...args) {
if (!timer) {
timer = setTimeout(()=>{
func.apply(this, args)
timer = timer || setTimeout(()=>{
func.apply(this, args);
timer = 0;
}, ms);
}
};
};
}