Holds a data in a ring-buffer.

Type Parameters

  • T

Implements

  • IReadOnlyDataBuffer<T>

Constructors

  • Constructor.

    Type Parameters

    • T

    Parameters

    • size: number = 0

      An optional buffer size.

    Returns DataBuffer<T>

Properties

length: number = 0

Methods

  • Takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.

    Parameters

    • index: number

    Returns T

  • Clears this DataBuffer.

    Parameters

    • Optionalsize: number

      An optional new buffer size.

    Returns void

  • Returns an iterator of a section of this buffer.

    Parameters

    • filter: (value: T) => boolean

      An optional callback filter.

    Returns DataBufferView<T>

  • Adds data to this DataBuffer.

    Parameters

    • ...elements: T[]

      The new elements.

    Returns void

  • Returns an iterator of a section of this buffer.

    Parameters

    • start: number

      The beginning index of the specified portion of the buffer.

    • Optionalend: number

      The end index of the specified portion of the buffer. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the buffer.

    Returns DataBufferView<T>

  • Returns an iterator of a section of this buffer.

    Parameters

    • start: number

      The beginning index of the specified portion of the buffer.

    • Optionalend: number

      The end index of the specified portion of the buffer. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the buffer.

    • Optionalfilter: (value: T) => boolean

      An optional callback filter.

    Returns DataBufferView<T>