No description
- TypeScript 100%
|
|
||
|---|---|---|
| .github/workflows | ||
| .vscode | ||
| examples | ||
| src | ||
| .gitignore | ||
| bun.lock | ||
| eslint.config.ts | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| tsup.config.ts | ||
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 maqueue
Usage
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