0.0.5 • Published 2 years ago

lightweight-debounce-throttle v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Lightweight Debounce Throttle

Lightweight TypeScript native debounce and throttle

Usage

Install

# With NPM:
npm install lightweight-debounce-throttle

# With Yarn:
yarn add lightweight-debounce-throttle

# With PNPM:
pnpm add lightweight-debounce-throttle

Debounce

import { debounce } from "lightweight-debounce-throttle";

const { exec } = debounce(
  (message) => {
    console.log(message);
  }, // callback
  1000 // delay time (milliseconds. optional, defaults to 500)
);
window.addEventListener("resize", (e) => {
  exec(`Your window width is ${e.target.innerWidth}px!`);
});

Throttle

import { throttle } from "lightweight-debounce-throttle";

const { exec } = throttle(
  (message) => {
    console.log(message);
  }, // callback
  1000 // delay time (milliseconds. optional, defaults to 500)
);
button.addEventListener("click", () => {
  apiCall()
});
0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago