8000 GitHub - behnammodi/tlence: debounce and throttle techniques for performance
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

behnammodi/tlence

Repository files navigation

tlence

tlence

NPM

install size dependencies

Version License Downloads Build Status

debounce and throttle techniques for performance

install

npm install tlence

use

Throttle

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

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

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

About

debounce and throttle techniques for performance

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0