import { default } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/queue.js";
Processes data sequentially by the given handler
function and prevents
concurrency conflicts, it returns a Queue instance that we can push
data into.
Examples
Example 1
Example 1
import queue from "@ayonli/jsext/queue";
const list: string[] = [];
const q = queue(async (str: string) => {
await Promise.resolve(null);
list.push(str);
});
q.onError(err => {
console.error(err);
})
await q.push("foo");
await q.push("foo");
console.log(list.length);
q.close();
// output:
// 2