# promise-debounce

> Debounce any promise-returning function so that at any instant only one call is pending

Latest version **1.0.1** (published 2015-06-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install promise-debounce
pnpm add promise-debounce
yarn add promise-debounce
bun add promise-debounce
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-06-18 |
| First published | 2014-09-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/promise-debounce) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Jason Frame |
| Maintainers | jaz303 |
| Keywords | promise, debounce, async |

## Links

- npm: https://www.npmjs.com/package/promise-debounce
- Repository: https://github.com/jaz303/promise-debounce
- Issues: https://github.com/jaz303/promise-debounce/issues
- npm.io page: https://npm.io/package/promise-debounce

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-06-18
- 1.0.0 — 2014-09-04
- 0.0.2 — 2014-09-04
- 0.0.1 — 2014-09-04

## README

# promise-debounce

## Installation

### npm

Get it:

```shell
npm install promise-debounce
```

Require it:

```javascript
var debounce = require('promise-debounce');
````

## Example

```javascript
var getStatus = debounce(ajax.bind(null, "GET", "/status.json"));

// The three following calls will cause only a single AJAX request...

getStatus().then(function(status) {
	// ...
});	

getStatus().then(function(status) {
	// ...
});

getStatus().then(function(status) {
	// ...
});
```

## API

#### `var debounced = debounce(fn, [ctx])`

Returns a debounced version of `fn` with optional calling context `ctx`.

`fn` must be a function which returns a promise.

If `debounced` is called and no other call is currently pending, `fn` will be called and its promise returned. Otherwise - if another call is pending - the original promise will be returned.

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