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

Package detail

just-debounce-it

angus-c236.1kMIT3.2.0TypeScript support: included

return a debounced function

function, debounce, no-dependencies, just

readme

just-debounce-it

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-debounce-it
yarn add just-debounce-it

Return a debounced function

import debounce from "just-debounce-it";

const fn1 = debounce(() => console.log("Hello"), 500);
fn1();
fn1();
fn1();
// 500ms later logs 'hello' once

const fn2 = debounce(() => console.log("Hello"), 500, true);
fn2(); // logs hello immediately
fn2();
fn2();
// 500ms later logs 'hello' once

const fn3 = debounce(() => console.log("Hello"), 500);
fn3();
fn3();
fn3();
fn3.cancel();
// function cancelled before 'hello' is logged

const fn4 = debounce(() => console.log("Hello"), 500);
fn4();
fn4();
fn4();
fn4.flush();
// immediately invoke the debounced function

changelog

just-debounce-it

3.2.0

Minor Changes

  • Rename node module .js -> .cjs

3.1.1

Patch Changes

  • fix: reorder exports to set default last #488

3.1.0

Minor Changes

  • package.json updates to fix #467 and #483