@seedalpha/debounce

1.2.10 • Public • Published

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

/@seedalpha/debounce/

    Package Sidebar

    Install

    npm i @seedalpha/debounce

    Weekly Downloads

    1

    Version

    1.2.10

    License

    ©2014 Seedalpha

    Unpacked Size

    3.11 kB

    Total Files

    5

    Last publish

    Collaborators

    • tom.raggett.trcuk.com
    • ac_inc