/debounce-fn

Return a debounced version of the given function

Primary LanguageJavaScript

debounce-fn

Return a debounced version of the given function

Install

$ npm install debounce-fn

Usage

var debounce = require('debounce-fn')
var yo = debounce(printYo, 300) // debounce for 300ms. if second argument is not passed, default is 250ms.

yo()
yo()
yo()
setTimeout(yo, 300)

// first two calls will be debounced, and will give two outputs:
// "yo"
// "yo"

function printYo () {
  console.log('yo')
}