https://github.com/bendrucker/next-tick-debounce
Debounce multiple synchronous function calls into a single async call
https://github.com/bendrucker/next-tick-debounce
Last synced: about 1 year ago
JSON representation
Debounce multiple synchronous function calls into a single async call
- Host: GitHub
- URL: https://github.com/bendrucker/next-tick-debounce
- Owner: bendrucker
- License: mit
- Created: 2015-09-03T15:49:45.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-11-13T19:35:07.000Z (over 7 years ago)
- Last Synced: 2024-11-18T23:59:21.738Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# next-tick-debounce [](https://travis-ci.org/bendrucker/next-tick-debounce)
> Debounce multiple synchronous function calls into a single async call
## Install
```
$ npm install --save next-tick-debounce
```
## Usage
```js
var debounce = require('next-tick-debounce')
var i = 0
var debounced = debounce(function () {
console.log(i++)
})
debounced()
debounced()
debounced()
//=> 0 (only called once)
setTimeout(debounced, 10)
//=> 1
```
The debounced function runs with the last set of arguments/context.
## API
#### `debounce(fn)` -> `function`
##### fn
*Required*
Type: `fn`
A function that should run at most once per tick.
## License
MIT © [Ben Drucker](http://bendrucker.me)