@olan88/q
v0.0.2
Published
Small TypeScript promise queue with dual CJS and ESM output
Readme
@olan88/Q
A small TypeScript promise queue package that works in both ESM and CommonJS.
Install
npm install @olan88/QUsage
ESM
import { Q } from "@olan88/Q";
const queue = new Q();
queue.add(async () => {
// runs first
});
queue.add(async () => {
// runs after previous task is finished
});
await queue.onIdle();CommonJS
const { Q } = require("@olan88/Q");
const queue = new Q();
queue.add(() => Promise.resolve("ok"));API
new Q()queue.add(job)- Accepts a function (
() => value | Promise) so the queue controls when it starts. - Returns a promise for the task result.
- Accepts a function (
queue.size- Number of queued/running tasks.
queue.onIdle()- Resolves when all currently queued tasks are done.
