Debounce

debounce

debounce a function.

Creates and returns a new debounced version of the passed function that will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked.

Get it: npm install --save debounce

API: debounce(fn, wait, [ immediate || false ])

Sample usage:

1
2
3
4
5
6
7
var debounce = require('debounce');
window.onresize = debounce(resize, 200);

function resize(e) {
  console.log('height', window.innerHeight);
  console.log('width', window.innerWidth);
}

GIF FTW!

debounce.gif

Suggest a module

Comments