1.1.0 • Published 4 years ago

just-debounce v1.1.0

Weekly downloads
1,114,876
License
MIT
Repository
github
Last release
4 years ago

just-debounce

just a basic debounce function

changes

  • 1.1.0: added typescript definitions

Why?

I searched npm and the first 3 pages of results for "debounce" did not have a small correctly implemented version of debounce

Usage

arguments

  • fn: the function to debounce
  • delay: debounce delay in ms
  • atStart: if true, the function will be called at the beginning of the delay rather than the end
  • guarantee: additional calls to debounced function will not reset they delay. This guarantees that if the function is called frequently, it will fire once every delay rather than waiting for a break in calls.
var db = require('just-debounce');

var debounced = db(function (v) {
  console.log(v);
}, 100);

debounced('hi');
debounced('hi');
// logs 'hi' once after 100ms
var db = require('just-debounce');

var debounced = db(
  function (v) {
    console.log(v);
  },
  100,
  true
);

debounced('hi');
debounced('hi');
// logs 'hi' once right away, but not a second time. calling after 100ms will log again
var db = require('just-debounce');

var debounced = db(
  function (v) {
    console.log(v);
  },
  100,
  false,
  true
);

debounced('hi');
setTimeout(function () {
  debounced('hi2');
}, 80);

// logs 'hi2' once 100ms after the first call to debounced

license

MIT

@everything-registry/sub-chunk-1995sync-indexsveltify-cmsvite-plugin-shopify-modulesvite-plugin-shopify-theme-settings@ctfdio/picocss-themesjackorg-webflowjeuxuijung@brucearmstrong/sass-librarylayui-customdfeuk-frontenddfeuk-frontend-manualuhnoxi-music-webuhnoxi-music-web-build@artesa/feathers-pinia@appigram/draftjs-diff@buerto/webflowtest-utils@benovshe/sasslibrary@dfdao/network@dfares/network@df0/network@darkforest_eth/network@finsweet/form-logic@finsweet/plus-dashboard@finsweet/attributes-cmsfilter@finsweet/attributes-cmsload@finsweet/attributes-a11y@finsweet/attributes-rangeslider@finsweet/attributes-scrolldisable@finsweet/attributes-selectcustom@finsweet/attributes-combobox@finsweet/attributes-docs@headgum/tko-mapping@fomantic/glob-watcher@gogreen/go-green-chart@infinitebrahmanuniverse/nolb-jus@lofcz/sweetalert2-neutral@isogand/react-native-sliding-counter@litedexdev/litedex-core-swap@faizanhaider/iconsax@min98/layui-custom@khavan/btc_frontend@igniswap/igni-swap-lib@s-ui/tealium-tracker@projectsophon/network@rhodesjason/loxdb@nowmade/sveltify-cmsn8n-nodes-caldavpoki-uirequire-lessrangoli-cssprototyper-vaultsite-sentinelsimply-uihcm-jsm2m-chartjs-plugin-crosshair@weareinreach/i18next-keys-ondemand@umi-ag/swap-widget@umi-ag/terminal@thismr/bitmindtest-core@temporalio/ui@vcita/design-system@zalastax/nolb-jusalisselisss-lab3altr-accessorscurio-vaultdarkforest_terraform_eth_networkbrowserify-less-transfrombridgeline-kabinetdraft-js-difffeathers-pinia@sequencemedia/glob-watcher
1.1.0

4 years ago

1.0.0

10 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago