Added some tests
This commit is contained in:
10
test/debounce/debounce.js
Normal file
10
test/debounce/debounce.js
Normal file
@ -0,0 +1,10 @@
|
||||
const debounce = (fn, wait = 0) => {
|
||||
let inDebounce;
|
||||
return function() {
|
||||
const context = this,
|
||||
args = arguments;
|
||||
clearTimeout(inDebounce);
|
||||
inDebounce = setTimeout(() => fn.apply(context, args), wait);
|
||||
};
|
||||
};
|
||||
module.exports = debounce
|
||||
Reference in New Issue
Block a user