bs-toolkit
v1.1.1
Published
A lightweight, type-safe debounce and throttle utility library for performance optimization
Downloads
5
Maintainers
Readme
bs-toolkit
A lightweight, type-safe debounce and throttle utility library that works in both browser and Node.js environments.
Installation
npm install bs-toolkit
# or
yarn add bs-toolkitExamples
import { debounce, throttle } from "bs-toolkit";
const onInput = debounce(() => {
console.log("Input finalized (debounced)");
}, 300);
const inputEl = document.getElementById("search-input");
inputEl?.addEventListener("input", onInput);
const onScroll = throttle(() => {
console.log("Scroll event triggered (throttled)");
}, 500);
window.addEventListener("scroll", onScroll);