0.0.2 • Published 6 months ago

@erbelion/debounce v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

debounce

Get package from npm Downloads views likes

A simple debouncer.

Installation

yarn

yarn add @erbelion/debounce

npm

npm i @erbelion/debounce

Usage

import debounce from '@erbelion/debounce'

const refresh = debounce(() => {
    doSomething()
}, 1000) // delay in milliseconds

refresh() // invokes doSomething() after 1000ms, unless called again
refresh.invoke() // same as above

refresh.invokeNow() // invoke refresh() immediately

refresh.cancel() // cancels refresh() if it has been invoked

refresh.overwrite(() => {
    doSomethingElse()
}, 2000) // cancels refresh() and overwrites the debouncer

const refresh = debounce() // init without callable function and delay

refresh.reset() // cancels refresh(), resets callable function and delay
refresh.overwrite() // same as above
0.0.2

6 months ago

0.0.1

7 months ago