Queue
Module Collections.Queues
Queues.QueueMutable
A queue has the logic of waiting in line at the bakery. First in, first out.
Immutable
Section titled “Immutable”Queues.immutable creates a queue, returning type Interface IQueueImmutable .
import { Queues } from "https://unpkg.com/@ixfx/collections/bundle"
let q = Queues.immutable();q = q.enqueue(`a`, `b`); // Add two stringsconst front = q.peek; // `a`, since it's the front of the queue (oldest)q = q.dequeue(); // q now just consists of `b`
Mutable
Section titled “Mutable”import { Queues } from "https://unpkg.com/@ixfx/collections/bundle"
const q = new Queues.QueueMutable();q.enqueue(`a`, `b`); // Add two stringsconst item = q.dequeue(); // Remove & return `a` from front of queueq.peek; // `b`
QueueMutable class also has events to monitor changes to the data.
Importing
Section titled “Importing”// Sub moduleimport { Queue } from "@ixfx/collections.js"// Eg: Queue.immutable();
// Whole moduleimport * as Collections from "@ixfx/collections.js"// Eg: Collections.Queue.immutable();
// From bundleimport { Collections } from "@ixfx"// Eg: Collections.Queue.immutable();
// And within your HTML's <HEAD> </HEAD> block:<script type="importmap">{ "imports": { "@ixfx":"/ixfx/index.js", "@ixfx/": "/ixfx/" } }</script>
// Sub module from parentimport { Queue } from "@ixfx/collections.js"// Eg: Queue.immutable();
// Whole parent moduleimport * as Collections from "@ixfx/collections.js"// Eg: Collections.Queue.immutable();
// From the bundleimport { Collections } from "@ixfx/bundle.js"// Eg: Collections.Queue.immutable();
// Sub module from parentimport { Queue } from "https://unpkg.com/@ixfx/collections/bundle"// Eg: Queue.immutable();
// Whole parent moduleimport * as Collections from "https://unpkg.com/@ixfx/collections/bundle"// Eg: Collections.Queue.immutable();
// Single module from the bundleimport { Collections } from "https://unpkg.com/@ixfx/bundle"// Eg: Collections.Queue.immutable();