Class Buffer<A>

First-in, first-out (FIFO) buffer (queue) with default item values. Optionally circular based on limit. Can be switched to LIFO with reverse.

Type Parameters

  • A

Hierarchy

  • Buffer

Constructors

  • Type Parameters

    • A

    Parameters

    • limit: number = Infinity

      The length after which the buffer becomes circular, i.e., discards oldest items.

    Returns Buffer<A>

Properties

#list: List<A>
#reversed: boolean = false
length: number = 0
limit: number = Infinity

The length after which the buffer becomes circular, i.e., discards oldest items.

Methods

  • Returns {
        next: (() => {
            done: false;
            value: A;
        } | {
            done: true;
            value: undefined;
        });
        [iterator]() => { next: () => { value: A; done: false; } | { done: true; value: undefined; }; [Symbol.iterator](): ...; };
    }

    • next: (() => {
          done: false;
          value: A;
      } | {
          done: true;
          value: undefined;
      })
        • (): {
              done: false;
              value: A;
          } | {
              done: true;
              value: undefined;
          }
        • Returns {
              done: false;
              value: A;
          } | {
              done: true;
              value: undefined;
          }

    • [iterator]:function
      • Returns { next: () => { value: A; done: false; } | { done: true; value: undefined; }; [Symbol.iterator](): ...; }

  • Return the oldest item from the buffer.

    Returns A

  • Add an item to the end of the buffer.

    Parameters

    • value: A

    Returns void

  • Parameters

    • f: ((value) => void)
        • (value): void
        • Parameters

          • value: A

          Returns void

    Returns void

  • Type Parameters

    • A

    Parameters

    • iterable: Iterable<A>
    • limit: number

    Returns Buffer<A>

Generated using TypeDoc