Skip to content

Queue

Module Collections.Queues

A queue has the logic of waiting in line at the bakery. First in, first out.

Immutable

Queues.immutable creates a queue, returning type Interface IQueueImmutable .

import { Queues } from "https://unpkg.com/ixfx/dist/collections.js"
let q = Queues.immutable();
q = q.enqueue(`a`, `b`); // Add two strings
const front = q.peek; // `a`, since it's the front of the queue (oldest)
q = q.dequeue(); // q now just consists of `b`

Mutable

Queues.QueueMutable
import { Queues } from "https://unpkg.com/ixfx/dist/collections.js"
const q = new Queues.QueueMutable();
const item = q.dequeue(); // Remove & return `a` from front of queue
q.peek; // `b`

QueueMutable class also has events to monitor changes to the data.