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
- Host: GitHub
- URL: https://github.com/behnammodi/tlence
- Owner: behnammodi
- License: mit
- Created: 2018-12-30T08:32:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T02:22:29.000Z (over 2 years ago)
- Last Synced: 2024-05-21T15:33:34.770Z (over 1 year ago)
- Topics: debounce, debouncing, delay, javascript, throttle, throttling, wait
- Language: JavaScript
- Homepage: https://npmjs.com/package/tlence
- Size: 665 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# tlence

[](https://nodei.co/npm/tlence/)
[](https://packagephobia.now.sh/result?p=tlence) [](https://david-dm.org/uxitten/tlence.svg)
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');
```