0.5.9 • Published 4 years ago

stormcloud v0.5.9

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Stormcloud

A simple library for delaying function calls.

Includes throttle and debounce.

Read about throttle and debounce

Demo

See It in Action

Install

npm install stormcloud

How to Use

import {throttle, debounce} from "stormcloud";

let consoleLogThrottled = throttle(function () {
  console.log("throttle")
}, 1000);

let consoleLogDebounced = debounce(function () {
  console.log("debounce")
}, 1000);

window.addEventListener('scroll', function(e) {
  consoleLogThrottled();
  consoleLogDebounced();
});

How it Works

throttle

let throttledFunction = throttle(originalFunction, 500);

If throttledFunction is called more often than every 500 milliseconds, it will be slowed down to being called every 500 milliseconds.

debounce

let debouncedFunction = debounce(originalFunction, 500);

If debouncedFunction is called more often than every 500 milliseconds, it will not be called until there's a gap of more than 500 milliseconds between calls.

License

MIT

Happy Coding ✌️

0.5.8

4 years ago

0.5.9

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago