@refinio/one.models
    Preparing search index...

    A queue implementation where the reader promises block until new data is available.

    Type Parameters

    • T
    Index

    Constructors

    • Constructs a new priority queue.

      Type Parameters

      • T

      Parameters

      • maxDataQueueLength: number = Number.POSITIVE_INFINITY
      • maxPendingPromiseCount: number = Number.POSITIVE_INFINITY
      • defaultTimeout: number = Number.POSITIVE_INFINITY

        Default timeout used for remove() call when no timeout was specified. Defaults to Number.POSITIVE_INFINITY.

      Returns default<T>

    Accessors

    • get data(): T[]

      Get a copy of the internal data buffer.

      Note that the elements themselves are not copied, so if the contents are not native types, do not modify them.

      Returns T[]

    Methods

    • Add data to the queue.

      This will throw if the queue is full.

      Parameters

      • data: T
      • priority: number = 0

        lower values will have higher priority

      Returns void

    • Cancels all pending remove promises.

      Parameters

      • Optional_err: Error

      Returns void

    • Get element from queue.

      If no element is in the queue, then the promise will not resolve, until there is.

      Parameters

      • Optionaltimeout: number

        Timeout as unsigned 32-bit integer or Number.POSITIVE_INFINITY. If undefined use the default value passed to the constructor.

      Returns Promise<T>

    • Compare function for sorting priorities.

      Parameters

      • a: [number, unknown]
      • b: [number, unknown]

      Returns number