Class: ViewableBuffer

ViewableBuffer

Flexible wrapper around ArrayBuffer that also provides typed array views on demand.

new ViewableBuffer (length)

Name Type Description
length number | ArrayBuffer | Uint8Array

The size of the buffer in bytes.

Members

bigUint64View BigUint64Array

View on the raw binary data as a BigUint64Array.

float32View Float32Array

View on the raw binary data as a Float32Array.

float64View Float64Array

View on the raw binary data as a Float64Array.

int16View Int16Array

View on the raw binary data as a Int16Array.

int32View Int32Array

View on the raw binary data as a Int32Array.

int8View Int8Array

View on the raw binary data as a Int8Array.

rawBinaryData ArrayBuffer

Underlying ArrayBuffer that holds all the data and is of capacity this.size.

size number

The size of the buffer in bytes.

uint32View Uint32Array

View on the raw binary data as a Uint32Array.

uint8View Uint8Array

View on the raw binary data as a Uint8Array.

Methods

sizeOf (type) number static

Returns the size of the given type in bytes.

Name Type Description
type string

One of int8, uint8, int16, uint16, int32, uint32, and float32.

Returns:
Type Description
number
  • size of the type in bytes

destroy () void

Destroys all buffer references. Do not use after calling this.

view (type) TypedArray

Returns the view of the given type.

Name Type Description
type string

One of int8, uint8, int16, uint16, int32, uint32, and float32.

Returns:
Type Description
TypedArray
  • typed array of given type