Share your code.
just-debouncepublic
just-debounce
just a basic debounce function
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 debouncedelay
: debounce delay in msat_start:
if true, the function will be called at the beginning of the delay rather than the endguarantee
: ensures the time before the next call thefn
is not greater
than the delay period.
var db = var debounced = // logs 'hi' once after 100ms
var db = var debounced = // logs 'hi' once right away, but not a second time. calling after 100ms will log again
var db = var debounced = // logs 'hi2' once 100ms after the first call to debounced
license
MIT