# debounce-es6

> debounce library written in es6

Latest version **1.1.0** (published 2018-06-08) · ISC license · 0 weekly downloads

## Install

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

## 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 | 2018-06-08 |
| First published | 2018-06-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | @carlessanzmateu |
| Maintainers | carlessanzmateu |
| Keywords | debounce, javascript, js, es6, ES2015 |

## Links

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

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.0 (latest) — 2018-06-08

## README

# Debounce ES6

Debounce library fully written in ES6

How to **install**:

> npm install debounce-es6

**Usage:**

```javascript

import DebounceES6 from 'debounce-es6';

const debounceES6 = new DebounceES6();

const delayTime = 300 //mms
const isImmediate = false

debounceES6.debounce(() => {
  console.log('some foo texto to be debounced');
}, delayTime, isImmediate);

````

## Features

This library is designed in order to debounce the function used as callback. The `debounceES6.debounce` method will delay the execution during the time set in the `await` parameter.

Also, is available to set the `new DebounceES6()` as global and the library will send just the last stack of calls in the await time.

## Api
### debounce method

```javascript
// function as callback
// awaitTime as number in mms
// immediate as boolean

.debounce( function, awaitTime, immediate )
```

## Just debounce example

```javascript

import DebounceES6 from 'debounce-es6';

const debounceES6 = new DebounceES6();

const delayTime = 300 //mms
const isImmediate = false

debounceES6.debounce(() => {
  console.log('some foo texto to be debounced');
}, delayTime, isImmediate);

```
## Debounce last stack of calls (if the await time does not get acomplished between calls)

```javascript

import DebounceES6 from 'debounce-es6';

const debounceES6 = new DebounceES6();

const delayTime = 300 //mms
const isImmediate = false

someFooMethod() {
  debounceES6.debounce(() => {
    console.log('some foo text to be debounced');
  }, delayTime, isImmediate);
}

...

for(var i = 0; i < 5; i++) {
  this.someFooMethod()
}

// NOT EXPECTED OUTPUT
// ** wait for 300 mms **
//some foo text to be debounced

// ** wait for 300 mms **
//some foo text to be debounced

// ** wait for 300 mms **
//some foo text to be debounced

// ** wait for 300 mms **
//some foo text to be debounced

// ** wait for 300 mms **
//some foo text to be debounced


// REAL EXPECTED OUTPUT:
//some foo text to be debounced

```

In that case, if we set during the loop `immediate` parameter as true, the output will be:

```javascript
// ** wait for 300 mms **
//some foo text to be debounced

// ** wait for 300 mms **
//some foo text to be debounced

// ** wait for 300 mms **
//some foo text to be debounced

// ** wait for 300 mms **
//some foo text to be debounced

// ** wait for 300 mms **
//some foo text to be debounced
```

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