
Security News
Happy Birthday, Shai-Hulud
It has been one year since Shai-Hulud made its first appearance on npm.
devkits-debounce
Advanced tools
Debounce and throttle functions. Zero dependencies, lightweight utility for rate limiting function calls.
npm install -g devkits-debounce
# Run demo
debounce demo
# Run tests
debounce test
const { debounce, throttle } = require('devkits-debounce');
// Debounce search input
const search = debounce((query) => {
fetchResults(query);
}, 300);
// Throttle scroll handler
const onScroll = throttle(() => {
updatePosition();
}, 100);
debounce(fn, wait, options)Create a debounced version of a function.
| Param | Type | Description |
|---|---|---|
| fn | Function | Function to debounce |
| wait | number | Wait time in milliseconds (default: 0) |
| options.leading | boolean | Call on leading edge (default: false) |
| options.trailing | boolean | Call on trailing edge (default: true) |
| options.maxWait | number | Maximum wait before forcing execution |
| Returns | Function | Debounced function |
Methods:
.cancel() — Cancel pending execution.flush() — Execute immediately if pendingthrottle(fn, wait, options)Create a throttled version of a function.
| Param | Type | Description |
|---|---|---|
| fn | Function | Function to throttle |
| wait | number | Wait time in milliseconds (default: 0) |
| options.leading | boolean | Call on leading edge (default: true) |
| options.trailing | boolean | Call on trailing edge (default: true) |
| Returns | Function | Throttled function |
Methods:
.cancel() — Cancel pending execution.flush() — Execute immediately if pending// Search with debounce
const searchInput = document.getElementById('search');
const search = debounce((query) => {
api.search(query).then(renderResults);
}, 300);
searchInput.addEventListener('input', (e) => {
search(e.target.value);
});
// Scroll with throttle
const onScroll = throttle(() => {
const position = window.scrollY;
updateProgressBar(position);
}, 100);
window.addEventListener('scroll', onScroll);
// Debounce with leading edge
const debounced = debounce(() => {
console.log('Executed!');
}, 300, { leading: true, trailing: true });
// Throttle with only trailing edge
const throttled = throttle(() => {
console.log('Throttled!');
}, 1000, { leading: false, trailing: true });
// Cancel pending execution
const task = debounce(expensiveOperation, 1000);
task();
task.cancel(); // Won't execute
// Force immediate execution
const task2 = debounce(saveData, 5000);
task2();
task2.flush(); // Execute now
Open Collective: Open Collective - DevKits
Crypto: ETH/USDC 0xDea4a6A20fCB44467e45Ef378972F54B22dC59db
MIT — DevKits Team
FAQs
Debounce and throttle functions — zero dependencies
We found that devkits-debounce demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.

Security News
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.