Skip to content

bendrucker/next-tick-debounce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

next-tick-debounce Build Status

Debounce multiple synchronous function calls into a single async call

Install

$ npm install --save next-tick-debounce

Usage

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

About

Debounce multiple synchronous function calls into a single async call

Resources

License

Stars

Watchers

Forks

Packages

No packages published