An open API service indexing awesome lists of open source software.

https://github.com/behnammodi/tlence

debounce and throttle techniques for performance
https://github.com/behnammodi/tlence

debounce debouncing delay javascript throttle throttling wait

Last synced: 7 months ago
JSON representation

debounce and throttle techniques for performance

Awesome Lists containing this project

README

          

# tlence

![tlence](https://user-images.githubusercontent.com/1549069/108704171-e1a4a880-7520-11eb-91cb-88e76b8e12db.png)

[![NPM](https://nodei.co/npm/tlence.png)](https://nodei.co/npm/tlence/)

[![install size](https://packagephobia.now.sh/badge?p=tlence)](https://packagephobia.now.sh/result?p=tlence) [![dependencies](https://david-dm.org/uxitten/tlence.svg)](https://david-dm.org/uxitten/tlence.svg)


Version


License


Downloads


Build Status

debounce and throttle techniques for performance

## install

```npm
npm install tlence
```

## use

### Throttle

```javascript
import { throttle } from 'tlence';

function log(server) {
console.log('connecting to', server);
}

const throttleLog = throttle(log, 5000);
// just run first call to 5s
throttleLog('local');
throttleLog('local');
throttleLog('local');
throttleLog('local');
throttleLog('local');
throttleLog('local');
```

### Debounce

```javascript
import { debounce, delay } from 'tlence';
const debounceLog = debounce(log, 5000);
// just run last call to 5s
debounceLog('local');
debounceLog('local');
debounceLog('local');
debounceLog('local');
debounceLog('local');
debounceLog('local');
```

### Delay

```javascript
import { delay } from 'tlence';
console.log('delay 1');
await delay(5000);
// run after 5s
console.log('delay 2');
```