tlence

1.2.3 • Public • Published

tlence

tlence

NPM

install size dependencies

Version License Downloads

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');

Readme

Keywords

none

Package Sidebar

Install

npm i tlence

Weekly Downloads

345

Version

1.2.3

License

ISC

Unpacked Size

5.55 kB

Total Files

9

Last publish

Collaborators

  • itten