# just-debounce

> a simple debounce with no dependencies or crazy defaults

Latest version **1.1.0** (published 2021-02-17) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2021-02-17 |
| First published | 2014-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Michael Hayes |
| Maintainers | hayes |
| Keywords | debounce |

## Links

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

## Recent versions

- 1.1.0 (latest) — 2021-02-17
- 1.0.0 — 2015-06-03
- 0.0.3 — 2014-11-29
- 0.0.2 — 2014-04-04
- 0.0.1 — 2014-04-04

## README

# just-debounce

just a basic debounce function

# changes

- `1.1.0`: added typescript definitions

# Why?

I searched npm and the first 3 pages of results for "debounce" did not have a small correctly
implemented version of debounce

# Usage

### arguments

- `fn`: the function to debounce
- `delay`: debounce delay in ms
- `atStart:` if true, the function will be called at the beginning of the delay rather than the end
- `guarantee`: additional calls to debounced function will not reset they `delay`. This guarantees
  that if the function is called frequently, it will fire once every `delay` rather than waiting for
  a break in calls.

```javascript
var db = require('just-debounce');

var debounced = db(function (v) {
  console.log(v);
}, 100);

debounced('hi');
debounced('hi');
// logs 'hi' once after 100ms
```

```javascript
var db = require('just-debounce');

var debounced = db(
  function (v) {
    console.log(v);
  },
  100,
  true
);

debounced('hi');
debounced('hi');
// logs 'hi' once right away, but not a second time. calling after 100ms will log again
```

```javascript
var db = require('just-debounce');

var debounced = db(
  function (v) {
    console.log(v);
  },
  100,
  false,
  true
);

debounced('hi');
setTimeout(function () {
  debounced('hi2');
}, 80);

// logs 'hi2' once 100ms after the first call to debounced
```

# license

MIT

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