Waitgroup
A tiny version of Golang's WaitGroup with typings, promises, and zero dependencies.
Install / Use
/learn @jpwilliams/WaitgroupREADME
@jpwilliams/waitgroup
A tiny version of Golang's WaitGroup.
- Tiny (<1kB)
- Works with <img alt="browsers" title="This package works with browsers." height="16px" src="https://jsr.io/logos/browsers.svg" /> <img alt="Deno" title="This package works with Deno." height="16px" src="https://jsr.io/logos/deno.svg" /> <img alt="Node.js" title="This package works with Node.js" height="16px" src="https://jsr.io/logos/node.svg" /> <img alt="Cloudflare Workers" title="This package works with Cloudflare Workers." height="16px" src="https://jsr.io/logos/cloudflare-workers.svg" /> <img alt="Bun" title="This package works with Bun." height="16px" src="https://jsr.io/logos/bun.svg" />
- Typed
- Zero dependencies 🎉
There are too many package managers 🥲
# From npm
npm install @jpwilliams/waitgroup
yarn add @jpwilliams/waitgroup
pnpm add @jpwilliams/waitgroup
# From JSR
npx jsr add @jpwilliams/waitgroup
bunx jsr add @jpwilliams/waitgroup
deno add @jpwilliams/waitgroup
yarn dlx jsr add @jpwilliams/waitgroup
pnpm dlx jsr add @jpwilliams/waitgroup
import http from "http";
import { WaitGroup } from "@jpwilliams/waitgroup";
async function main() {
const wg = new WaitGroup();
const urls = [
"http://www.golang.org/",
"http://www.google.com/",
"http://www.somestupidname.com/",
];
urls.forEach((url) => {
// Increment the WaitGroup counter
wg.add(1);
// Fetch the URL
http.get(url, () => {
// Decrement the counter when the GET is complete
wg.done();
});
});
// Wait for all HTTP fetches to complete
await wg.wait();
}
main();
For most applications in Node.js, using built-ins like Promise.all will work perfectly, but sometimes this can be a really nice abstraction if the promises you have to keep track of are pretty spread out.
See jpwilliams/waitgroup-deno for a strictly Deno version, or @jpwilliams/waitgroup on JSR.
Related Skills
node-connect
340.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
340.5kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
84.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
340.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
