@revoloo/cypress6
Version:
Cypress.io end to end testing tool
17 lines (14 loc) • 378 B
text/typescript
export const debounce = (callback) => {
let timeout
// Return a function to run debounced
return function (...args: any[]) {
// If there's a timer, cancel it
if (timeout) {
window.cancelAnimationFrame(timeout)
}
// Setup the new requestAnimationFrame()
timeout = window.requestAnimationFrame(() => {
callback.apply({}, args)
})
}
}