Returns an immutable queue. Queues are useful if you want to treat 'older' or 'newer' items differently. Enqueing adds items at the back of the queue, while dequeing removes items from the front (ie. the oldest).

import { Queues } from "https://unpkg.com/ixfx/dist/collections.js"
let q = Queues.immutable(); // Create
q = q.enqueue(`a`, `b`); // Add two strings
const front = q.peek(); // `a` is at the front of queue (oldest)
q = q.dequeue(); // q now just consists of `b`
const q = Queues.immutable({capacity: 5, discardPolicy: `newer`});
  • Type Parameters

    • V

      Type of values stored

    Parameters

    • options: QueueOpts<V> = {}
    • Rest...startingItems: readonly V[]

      Index 0 is the front of the queue

    Returns IQueueImmutable<V>

    A new queue