# debounce-by-key

> useful for employing a group of functions within a single debounce scope and/or employing a single function across a group of debounce scopes

Latest version **0.1.1** (published 2017-09-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install debounce-by-key
pnpm add debounce-by-key
yarn add debounce-by-key
bun add debounce-by-key
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-09-02 |
| First published | 2017-09-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jason Yung |
| Maintainers | bitstrider |
| Keywords | debounce, key, string, id, scope |

## Links

- npm: https://www.npmjs.com/package/debounce-by-key
- Repository: https://github.com/bitstrider/debounce-by-key
- Homepage: https://github.com/bitstrider/debounce-by-key#readme
- Issues: https://github.com/bitstrider/debounce-by-key/issues
- npm.io page: https://npm.io/package/debounce-by-key

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2017-09-02
- 0.1.0 — 2017-09-02

## README

# debounce-by-key
[![debounce-by-key](https://img.shields.io/npm/v/debounce-by-key.svg)]()
[![debounce-by-key](https://img.shields.io/npm/l/debounce-by-key.svg)]()

useful for employing a group of functions within a single debounce scope and/or employing a single function across a group of debounce scopes

## Installation

```sh
npm install debounce-by-key --save
```

## Usage

This module provides a single function that takes a single options arg (*optional*) and returns a `Promise` that *resolves* if the debounce state is **non-blocking**, and *rejects* if its **blocking**.

### debounce([options])
- options `{Object}`
- return: `Promise`

#### [options]
- `key` the string identifier of the debounce scope. Defaults to `''`
- `duration` the time in milliseconds of the **blocking** state. Defaults to `1000`

## Example

```javascript
const debounce = require('debounce-by-key')

const sayHi = ()=>{console.log('hello world')}


/* no-args */
debounce().then(sayHi)
debounce().then(sayHi) //⛔ will not run


/* multiple functions, single scope */
debounce({key:'say hi'}).then(() => console.log('hola mundo') )
debounce({key:'say hi'}).then(() => console.log('hello world') ) //⛔ will not run
debounce({key:'say hi'}).then(() => console.log('bonjour monde') ) //⛔ will not run


/* single function, mutliple scopes */
debounce({key:'say hi 1'}).then(sayHi)
debounce({key:'say hi 2'}).then(sayHi) //✅ will run


/* duration arg */
const d = () => debounce({key:'say hi 3', duration:1000}).then(sayHi)

d()
setTimeout(d,500) //⛔ will not run
setTimeout(d,1500) //✅ will run



```

## Tests

```sh
npm install
npm test
```

## Dependencies

None

## Dev Dependencies

- [tap](https://github.com/tapjs/node-tap): A Test-Anything-Protocol library


## License

ISC

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