# debounceify

> Tiny async debouncer

Latest version **1.1.0** (published 2024-01-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install debounceify
pnpm add debounceify
yarn add debounceify
bun add debounceify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-01-12 |
| First published | 2021-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 37 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/debounceify
- Repository: https://github.com/mafintosh/debounceify
- Issues: https://github.com/mafintosh/debounceify/issues
- npm.io page: https://npm.io/package/debounceify

## Recent versions

- 1.1.0 (latest) — 2024-01-12
- 1.0.0 — 2021-01-17
- 0.0.0 — 2021-01-17

## README

# debounceify

Tiny async debouncer

```
npm install debounceify
```

## Usage

``` js
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

---
_Source: https://npm.io/package/debounceify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
