Socket
Socket
Sign inDemoInstall

debounceify

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    debounceify

Tiny async debouncer


Version published
Weekly downloads
1.4K
decreased by-11.62%
Maintainers
1
Install size
3.80 kB
Created
Weekly downloads
 

Readme

Source

debounceify

Tiny async debouncer

npm install debounceify

Usage

const debounceify = require('debounceify')

const debounced = debounceify(async function () {
  console.log('Running...')
  await new Promise(resolve => setTimeout(1000, resolve))
})

const a = debounced() // triggers the about function
const b = debounced()
const c = debounced()
const d = debounced() // these last 3 wait for the first one to finish
                      // then trigger one more.

await a
await b
await c
await d

API

fn = debounceify(asyncFunction)

Debounces the asyncFunction so that

  1. No parallel executions of asyncFunction will happen
  2. Debounces the stack, so if 10 calls happen while asyncFunction is running only one more will be triggered when it finishes.
  3. Forwards errors and return values.
debounceify.running

The active running job, null if none.

License

MIT

FAQs

Last updated on 12 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc