Last active
July 26, 2022 06:33
-
-
Save evolify/e06ceec7ffef33fdcb3e656dfa1cbedb to your computer and use it in GitHub Desktop.
节流、防抖
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function debounce(callback, wait) { | |
let timeoutId = null; | |
return (...args) => { | |
window.clearTimeout(timeoutId); | |
timeoutId = window.setTimeout(() => { | |
callback.apply(null, args); | |
}, wait); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment