debounce-micro
wrap a function in a debounce microtask
Install
$ npm i debounce-micro
Example
let x = 0
const fn = debounce((y: number) => (x += y))
fn(1)
fn(2)
expect(x).toEqual(0)
queueMicrotask(() => {
expect(x).toEqual(2) // instead of 3
done()
})
API
Table of Contents
debounce
Wraps a function in a debounce microtask.
Parameters
-
inner
function (...args: Array<any>): any The function to wrap in the debounce
Returns any A debounced function
Contribute
All contributions are welcome!
License
MIT © 2021 stagas