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

multi-debounce

v1.1.0

Published

Custom firebase persistence for browser extensions

Readme

Multi-Debounce

Smart debouncing utility that allows immediate execution on certain triggers (like Enter key or paste) while maintaining standard debouncing for regular input changes.

Why Multi-Debounce?

When building search inputs, you typically want to:

  • Debounce regular typing to avoid excessive API calls
  • Execute immediately when user presses Enter or pastes text
  • Avoid complex state management that comes with controlling this behavior in React

With standard useDebounce, you'd need additional state to handle immediate execution scenarios. Multi-Debounce solves this by providing multiple debounced functions with different delays that automatically cancel each other.

Installation

npm install multi-debounce

Usage

React Hook

import { useMultiDebounce } from "multi-debounce/useMultiDebounce";

function SearchInput() {
  const search = useMultiDebounce((query: string) => {
    console.log("Searching for:", query);
    // Make API call here
  });

  const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    // Debounced search with 200ms delay
    search.m(e.target.value);
  };

  const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
    if (e.key === "Enter") {
      // Immediate search, cancels any pending debounced calls
      search.none((e.target as HTMLInputElement).value);
    }
  };

  const handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
    // Immediate search on paste
    search.none(e.clipboardData.getData("text"));
  };

  return (
    <input
      type="text"
      onChange={handleInputChange}
      onKeyDown={handleKeyDown}
      onPaste={handlePaste}
      placeholder="Search..."
    />
  );
}

Vanilla JavaScript

import { multiDebounce } from "multi-debounce/mutliDebounce";

const search = multiDebounce((query) => {
  console.log("Searching for:", query);
  // Make API call here
});

// Regular typing - debounced
input.addEventListener("input", (e) => {
  search.m(e.target.value);
});

// Enter key - immediate
input.addEventListener("keydown", (e) => {
  if (e.key === "Enter") {
    search.none(e.target.value);
  }
});

// Paste - immediate
input.addEventListener("paste", (e) => {
  search.none(e.clipboardData.getData("text"));
});

Available Delays

The library provides pre-configured delays:

{
  none: 0,      // Immediate execution
  xs: 10,       // 10ms
  s: 50,        // 50ms
  m: 200,       // 200ms (good for search)
  l: 1000,      // 1 second
  xl: 3000,     // 3 seconds
  0: 0,         // Numeric alternatives
  50: 50,
  100: 100,
  200: 200,
  500: 500,
  1000: 1000,
  2000: 2000,
  3000: 3000
}

Custom Delays

You can provide custom delay configurations:

const customDelays = {
  immediate: 0,
  fast: 100,
  slow: 800,
};

// React
const debouncedFn = useMultiDebounce(myFunction, customDelays);

// Vanilla JS
const debouncedFn = multiDebounce(myFunction, customDelays);

// Usage
debouncedFn.immediate(data); // Executes immediately
debouncedFn.fast(data); // 100ms delay
debouncedFn.slow(data); // 800ms delay

Advanced Usage

Manual Control

const search = multiDebounce(searchFunction);

// Cancel all pending calls
search.cancelAll();

// Execute all pending calls immediately
search.flushAll();

// Cancel specific delay
search.m.cancel();

// Flush specific delay
search.m.flush();

Form Validation Example

function EmailInput() {
  const validateEmail = useMultiDebounce((email: string) => {
    // Validate email format and availability
    if (isValidEmail(email)) {
      checkEmailAvailability(email);
    }
  });

  return (
    <input
      type="email"
      onChange={(e) => validateEmail.m(e.target.value)} // 200ms delay
      onBlur={(e) => validateEmail.s(e.target.value)} // 50ms delay on blur
    />
  );
}

TypeScript Support

Fully typed with TypeScript. Generic types preserve function signatures:

const typedDebounce = useMultiDebounce(
  (id: number, name: string) => Promise<User>,
  { quick: 100, normal: 300 },
);

// TypeScript knows these return Promise<User>
typedDebounce.quick(1, "John");
typedDebounce.normal(2, "Jane");

License

MIT