maqueue
v1.1.0
Published
Modern Asynchronous Queue, a dead-simple and lightweight queue for enqueuing asynchronous tasks with single concurrency.
Readme
maqueue - Modern Asynchronous Queue
A dead-simple and lightweight (250B) queue for enqueuing asynchronous tasks with single concurrency.
Installation
Use any package manager you prefer.
bun add maqueueUsage
Import and instantiate the queue using...
import { AsyncQueue } from "maqueue";
const queue = new AsyncQueue();...finally, use run to perform an async task in the queue!
const p1 = queue.run(async () => {
console.log("running 1");
await wait(3000);
return 1;
});
const p2 = queue.run(async () => {
console.log("running 2");
await wait(2000);
return 2;
});
const p3 = queue.run(async () => {
console.log("running 3");
await wait(1000);
return 3;
});
const outputs = await Promise.all([p1, p2, p3]);
console.log(outputs);$ bun example.ts
running 1
running 2
running 3
[1, 2, 3]See the whole file in examples/index.ts
