Simple debounce for all javascript environments, can be used in React, Vanilla js, Svelte, Node and more. Easy to use and lightweight
- Multiple callbacks
- Optional Delay
- default delay 350 miliseconds
Debounce-helper can use any version of Node to run.
Npm
npm i @joshmg-77/debounce-helper --save-dev
Yarn
yarn add @joshmg-77/debounce-helper --dev
Using ES6 Modules
import debounce from '@joshmg-77/debounce-helper'
const fn = debounce((params) => console.log("avoid excessive clicks", params), 5000)
fn()
After 5 second
Result: avoid excessive clicks
Without ES6 Modules
const debounce = require('@joshmg-77/debounce-helper')
const fn = debounce((params) => console.log("avoid excessive clicks", params), 5000)
fn()
After 5 second
Result: avoid excessive clicks
import debounce from '@joshmg-77/debounce-helper'
const fn1 = () => console.log('some code')
const fn2 = () => console.log('foo bar')
const fn3 = () => console.log('service call')
const [Fn1, Fn2, Fn3] = debounce([fn1, fn2, fn3])
Fn1()
Fn2()
Fn3()
After 350 miliseconds
Result:
'some code'
'foo bar'
'service call'
GPL