Options
All
  • Public
  • Public/Protected
  • All
Menu
ngdoc

object

name

Utilities.type:RingBuffer

description

A fixed size binary ringbuffer built on top of a Javascript ArrayBuffer The RingBuffer allows pushing, popping and peeking chunks of data as well as popping and peeking typed structures using popAs and peekAs.

property

{number} offset The offset to the start of valid data in the ArrayBuffer

property

{number} count The count of valid data in the ArrayBuffer

Hierarchy

  • RingBuffer

Index

Constructors

constructor

  • new RingBuffer(ringBufferSize: number, autoexpand?: boolean): RingBuffer
  • ndgoc

    method

    name

    Utilities.type:RingBuffer#constructor

    methodof

    Utilities.type:RingBuffer

    description

    Constructor for RingBuffer, creates a new RingBuffer with an internal buffer of the given number of bytes. If you try to push more bytes than this internal size, an exception will be thrown.

    Parameters

    • ringBufferSize: number

      The number of bytes to allocate for the internal ring buffer.

    • Default value autoexpand: boolean = false

    Returns RingBuffer

Properties

Private _autoexpand

_autoexpand: boolean

Private _count

_count: number

Private _initialSize

_initialSize: number

Private _offset

_offset: number

Private ringBuffer

ringBuffer: ArrayBuffer

Accessors

count

count:

Private endPointer

endPointer:

offset

offset:

Methods

peek

  • peek(length: number): ArrayBuffer
  • ngdoc

    method

    name

    Utilities.type:RingBuffer#peek

    methodof

    Utilities.type:RingBuffer

    description

    Peek at the next length bytes in the ring buffer. No internal ringbuffer state is updated.

    Exceptions

    • {@link type:RingBufferEmptyError RingBufferEmptyError}: There are fewer than length bytes stored in the RingBuffer.
    throws

    {RingBufferEmptyError} If there are fewer than length bytes in the ringbuffer

    Parameters

    • length: number

      The numbero of bytes to return

    Returns ArrayBuffer

    A copy of the peeked bytes.

peekAs

  • peekAs(fmt: string): Array<number>
  • ngdoc

    method

    name

    Utilities.type:RingBuffer#peekAs

    methodof

    Utilities.type:RingBuffer

    description

    Peek a formatted structure from the ring buffer according to a format string

    Exceptions

    • {@link type:RingBufferEmptyError RingBufferEmptyError}: There are fewer than length bytes stored in the RingBuffer.

    For example, say we want to pop a uint8_t, uint16_t, uint16_t structure off of the ring buffer. We could call peekAs("BHH"). This is logically equivalent to val = peek(expectedBufferSize(fmt)); return unpackArrayBuffer(fmt, val);

    throws

    {RingBufferEmptyError} If there are fewer bytes in the ringbuffer than required by fmt

    Parameters

    • fmt: string

      The format string defining what we want to peek

    Returns Array<number>

    The structure popped off of the buffer as a list of numbers

pop

  • pop(length: number): ArrayBuffer
  • ngdoc

    method

    name

    Utilities.type:RingBuffer#pop

    methodof

    Utilities.type:RingBuffer

    description

    Pop length bytes from the ring buffer and return them as an ArrayBuffer.

    • Exceptions

    • {@link type:RingBufferEmptyError RingBufferEmptyError}: There are fewer than length bytes stored in the RingBuffer.
    throws

    {RingBufferEmptyError} If there are fewer than length bytes in the ringbuffer

    Parameters

    • length: number

      The numbero of bytes to return

    Returns ArrayBuffer

    The popped bytes that are removed now from the ring buffer

popAs

  • popAs(fmt: string): Array<number>
  • ngdoc

    method

    name

    Utilities.type:RingBuffer#popAs

    methodof

    Utilities.type:RingBuffer

    description

    Pop a formatted structure from the ring buffer according to a format string

    • Exceptions

    • {@link type:RingBufferEmptyError RingBufferEmptyError}: There are fewer than length bytes stored in the RingBuffer.

    For example, say we want to pop a uint8_t, uint16_t, uint16_t structure off of the ring buffer. We could call popAs("BHH"). This is logically equivalent to val = pop(expectedBufferSize(fmt)); return unpackArrayBuffer(fmt, val);

    throws

    {RingBufferEmptyError} If there are fewer bytes in the ringbuffer than required by fmt

    Parameters

    • fmt: string

      The format string defining what we want to pop

    Returns Array<number>

    The structure popped off of the buffer as a list of numbers

push

  • push(chunk: ArrayBuffer | SharedArrayBuffer): void
  • ngdoc

    method

    name

    Utilities.type:RingBuffer#push

    methodof

    Utilities.type:RingBuffer

    description

    Push a chunk of data onto this ring buffer. If the ring buffer would overflow, raise an exception.

    Exceptions

    • {@link type:InsufficientSpaceError InsufficientSpaceError}: There is an internal max ringbuffer size. If this is exceeded, an error is thrown.
    throws

    {InsufficientSpaceError} There is an internal max ringbuffer size. If this is exceeded, an error is thrown.

    Parameters

    • chunk: ArrayBuffer | SharedArrayBuffer

      The next chunk of data that we would like to parse into reports

    Returns void

reset

  • reset(): void
  • ngdoc

    method

    name

    Utilities.type:RingBuffer#reset

    methodof

    Utilities.type:RingBuffer

    description

    Reset the internal state of the ring buffer back to a clean slate.

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc