Repository
Current version released
11 months ago
fifo
Simple first-in-first-out queue for Deno.
import FIFO from "https://deno.land/x/fifo/mod.ts";
const queue = new FIFO<number>();
queue.push(1);
queue.push(2);
queue.push(3);
console.log(queue.length); // 3
console.log(queue.shift()); // 1
console.log(queue.shift()); // 2
console.log(queue.shift()); // 3
console.log(queue.shift()); // undefined
Supports both sync and async iteration.
// Consumes queue
for (const item of queue) {
console.log(item);
}
// Consumes queue, waits for new items
for await (const item of queue) {
console.log(item);
}