Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@seedalpha/debounce

seedalpha11©2014 Seedalpha1.2.10

Creates and returns a new debounced version of the passed function which will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing behavior that should only happen after the input ha

iterator, object, array

readme

debounce

Creates and returns a new debounced version of the passed function which will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing behavior that should only happen after the input has stopped arriving.

For example: rendering a preview of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on.

Changelog

1.0.0:

  • Initial release

Installation

$ npm install seed-debounce --save

Usage

var debounce = require('seed-debounce');

var count = 0;

var fn = debounce(function() {
    count++;
}, 300);

fn();
fn();
fn();

count === 1; // true

setTimeout(function(){
  count === 2; // true
}, 300);

Development

$ git clone git@github.com:seedalpha/debounce.git
$ cd debounce
$ npm install
$ npm test

Author

Vladimir Popov vlad@seedalpha.net

License

©2014 Seedalpha