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

async-minikit

v1.0.3

Published

A tiny zero-dependency async toolkit for Node.js and browsers. Includes sleep, sleepUntil, retry, timeout, debounceAsync, and throttleAsync.

Readme


✨ Features

  • sleep(ms) – delay execution
  • sleepUntil(condition) – wait until a condition becomes true
  • retry(fn, options) – retry failed async operations
  • timeout(promise, ms) – enforce a timeout on a promise
  • debounceAsync(fn, ms) – debounce async functions
  • throttleAsync(fn, ms) – throttle async functions
  • Zero dependencies
  • Works everywhere (Node, Bun, Deno, Browser)
  • Fully typed (TypeScript)

Perfect for backends, scripts, workers, SDKs, UI logic, and automation tools.


📦 Installation

npm install async-minikit

Or:

yarn add async-minikit
pnpm add async-minikit
bun add async-minikit

🚀 Quick Examples

1. Sleep

import { sleep } from 'async-minikit';

await sleep(500);
console.log('500ms passed');

2. Sleep until condition

import { sleepUntil } from 'async-minikit';

let ready = false;
setTimeout(() => (ready = true), 1000);

await sleepUntil(() => ready, 100);
console.log('Ready!');

3. Retry async logic

import { retry } from 'async-minikit';

const result = await retry(() => fetch('https://api.example.com/data'), { retries: 3, delay: 200 });

4. Timeout a promise

import { timeout, sleep } from 'async-minikit';

await timeout(sleep(5000), 1000); // throws after 1s

5. Debounce async function

import { debounceAsync } from 'async-minikit';

const save = debounceAsync(async () => {
  console.log('Saving...');
}, 300);

save();
save();
save(); // Only one call executes

6. Throttle async function

import { throttleAsync } from 'async-minikit';

const load = throttleAsync(async () => {
  console.log('Loading...');
}, 1000);

setInterval(load, 200);

📚 API Reference

sleep(ms: number): Promise<void>

Waits N milliseconds.


sleepUntil(condition, interval?)

Polls until condition becomes true.

await sleepUntil(() => userLoggedIn, 100);

retry(fn, { retries, delay })

Retries an async function until it succeeds.

Defaults:

retries: 3;
delay: 100;

timeout(promise, ms)

Rejects if the promise doesn’t resolve before ms.


debounceAsync(fn, ms)

Ensures the wrapped function only runs after no calls occur for ms.


throttleAsync(fn, ms)

Runs the function at most once per ms.


🛠️ TypeScript Support

Everything is strongly typed:

import type { AsyncFn } from 'async-minikit';

Includes .d.ts type declarations with tsup.


🧪 Running Tests

npm test

Uses Vitest.


🔨 Build

npm run build

Builds ESM + CJS outputs into /dist.


🤝 Contributing

PRs, issues, and ideas are welcome!

Star the repo ⭐ to support development.


📄 License

MIT © 2025


🚀 Spread the Word

If you like this library:

  • ⭐ Star the GitHub repo
  • Share it on Twitter/X
  • Write a blog post
  • Use it in your side projects

Thank you! 🙌