npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@letmein_by10/arc-debounce

v1.0.2

Published

Debouncing utility for JavaScript/TypeScript

Readme

@letmein_by10/arc-debounce

A comprehensive TypeScript/JavaScript utility library for debouncing, throttling, and timing control functions. Built with modern TypeScript and optimized for both Node.js and browser environments.

Features

  • Debounce Functions: Delay execution until after calls have stopped
  • Throttle Functions: Limit execution to once per time period
  • 🔄 Rate Limiting: Control maximum calls per time window
  • Timing Utilities: Sleep, delay, and once functions
  • 🎯 TypeScript First: Full type safety with generic support
  • 🌐 Universal: Works in Node.js and browsers
  • 🚀 Zero Dependencies: Lightweight and fast
  • 📦 Tree Shakeable: Import only what you need

Installation

npm install @letmein_by10/arc-debounce
# or
yarn add @letmein_by10/arc-debounce
# or  
pnpm add @letmein_by10/arc-debounce

Quick Start

import { debounce, throttle, once, delay, sleep, rateLimit } from '@letmein_by10/arc-debounce';

// Debounce a search function
const debouncedSearch = debounce((query: string) => {
  console.log('Searching for:', query);
}, 300);

// Throttle a scroll handler
const throttledScroll = throttle(() => {
  console.log('Scroll event');
}, 100);

// Rate limit API calls
const limitedAPI = rateLimit(apiCall, 10, 60000); // Max 10 calls per minute

API Reference

debounce(func, delay, options?)

Creates a debounced function that delays invoking func until after delay milliseconds have elapsed since the last time the debounced function was invoked.

Parameters:

  • func: The function to debounce
  • delay: The number of milliseconds to delay
  • options: Optional configuration object
    • immediate: Execute function immediately on first call
    • maxWait: Maximum time to wait before forcing execution

Returns: A debounced function with additional methods:

  • cancel(): Cancel pending function execution
  • flush(): Execute the function immediately
  • pending(): Check if function execution is pending

throttle(func, wait, options?)

Creates a throttled function that only invokes func at most once per every wait milliseconds.

once(func)

Creates a function that is restricted to invoking func once. Repeat calls return the value of the first invocation.

delay(func, delay, maxInterval)

Creates a function that delays invoking func with debouncing but ensures execution at least once every maxInterval milliseconds.

sleep(ms)

Utility function to wait for a specified amount of time.

await sleep(1000); // Wait 1 second

rateLimit(func, maxCalls, windowMs)

Creates a function that will call the original function with rate limiting.

Examples

Debouncing User Input

import { debounce } from '@letmein_by10/arc-debounce';

const searchInput = document.getElementById('search') as HTMLInputElement;
const debouncedSearch = debounce((query: string) => {
  // API call here
  fetch(`/api/search?q=${query}`)
    .then(response => response.json())
    .then(data => console.log(data));
}, 300);

searchInput.addEventListener('input', (e) => {
  debouncedSearch((e.target as HTMLInputElement).value);
});

Throttling Scroll Events

import { throttle } from '@letmein_by10/arc-debounce';

const throttledScroll = throttle(() => {
  const scrollY = window.scrollY;
  console.log('Current scroll position:', scrollY);
}, 100);

window.addEventListener('scroll', throttledScroll);

Rate Limiting API Calls

import { rateLimit } from '@letmein_by10/arc-debounce';

const apiCall = async (data: any) => {
  return fetch('/api/data', {
    method: 'POST',
    body: JSON.stringify(data),
    headers: { 'Content-Type': 'application/json' }
  });
};

const limitedAPI = rateLimit(apiCall, 10, 60000); // Max 10 calls per minute

// Usage
const result = limitedAPI({ message: 'Hello' });
if (result === undefined) {
  console.log('Rate limit exceeded');
}

TypeScript Support

This package is built with TypeScript and provides full type safety:

// Generic function support
const debouncedFn = debounce(<T>(value: T): T => {
  return value;
}, 300);

// Type inference works automatically
const result: string = debouncedFn('hello'); // ✅ Type safe

License

MIT © pizle0210