Class: ByteBuffer

ByteBuffer(array)

A structured wrapper around an array buffer that provides byte-level access to its data.

Constructor

new ByteBuffer(array)

Constructs a wrapper around an array buffer that enables byte-level access to its data. This wrapper strives to minimize secondary allocations when subarrays are accessed. The one exception is when double precision floating point data is access that is not properly aligned.
Parameters:
Name Type Description
array ArrayBuffer An array buffer containing source data.
Source:

Members

(static, constant) BIG_ENDIAN :Boolean

Access the underlying data in big endian order, where the most significant bits of the data are encountered first.
Type:
  • Boolean
Source:

(static, constant) BYTE_SIZE :Number

The size of a byte.
Type:
  • Number
Source:

(static, constant) DOUBLE_SIZE :Number

The size of a double precision floating point number.
Type:
  • Number
Source:

(static, constant) FLOAT_SIZE :Number

The size of a single precision floating point number.
Type:
  • Number
Source:

(static, constant) INT16_SIZE :Number

The size of a 16-bit integer.
Type:
  • Number
Source:

(static, constant) INT32_SIZE :Number

The size of a 32-bit integer.
Type:
  • Number
Source:

(static, constant) LITTLE_ENDIAN :Boolean

Access the underlying data in little endian order, where the least significant bits of the data are encountered first.
Type:
  • Boolean
Source:

array :ArrayBuffer

The raw data of the array buffer.
Type:
  • ArrayBuffer
Source:

data :DataView

A data view on the array buffer. This data view is used to extract integer and floating point data from that array buffer.
Type:
  • DataView
Source:

position :Number

The current position in the array buffer. This position is implicitly used to access all data.
Type:
  • Number
Source:

Methods

getByte() → {Number}

Get a byte from the current position and advance the position.
Source:
Returns:
Type
Number

getByteArray(numBytes) → {Uint8Array}

Get a byte array from the current position and advance the position. To avoid secondary allocation, a TypedArray shadows the underlying ArrayBuffer.
Parameters:
Name Type Description
numBytes Number The number of bytes in the desired array.
Source:
Returns:
Type
Uint8Array

getDouble() → {Number}

Get a double precision floating point number from the current position and advance the position.
Source:
Returns:
Type
Number

getDoubleArray(numDoubles) → {Float64Array}

Get a single precision floating point array from the current position and advance the position. To avoid secondary allocation, a TypedArray shadows the underlying ArrayBuffer.
Parameters:
Name Type Description
numDoubles Number The number of double precision floating point numbers in the desired array.
Source:
Returns:
Type
Float64Array

getFloat() → {Number}

Get a single precision floating point number from the current position and advance the position.
Source:
Returns:
Type
Number

getFloatArray(numFloats) → {Float32Array}

Get a single precision floating point array from the current position and advance the position. To avoid secondary allocation, a TypedArray shadows the underlying ArrayBuffer.
Parameters:
Name Type Description
numFloats Number The number of single precision floating point numbers in the desired array.
Source:
Returns:
Type
Float32Array

getInt16() → {Number}

Get a 16-bit integer from the current position and advance the position.
Source:
Returns:
Type
Number

getInt16Array(numInt16s) → {Int16Array}

Get a 16-bit integer array from the current position and advance the position. To avoid secondary allocation, a TypedArray shadows the underlying ArrayBuffer.
Parameters:
Name Type Description
numInt16s Number The number of 16-bit integers in the desired array.
Source:
Returns:
Type
Int16Array

getInt32() → {Number}

Get a 32-bit integer from the current position and advance the position.
Source:
Returns:
Type
Number

getInt32Array(numInt32s) → {Int32Array}

Get a single precision floating point array from the current position and advance the position. To avoid secondary allocation, a TypedArray shadows the underlying ArrayBuffer.
Parameters:
Name Type Description
numInt32s Number The number of 32-bit integers in the desired array.
Source:
Returns:
Type
Int32Array

hasRemaining() → {Boolean}

Indicates whether there remains any data to be accessed sequentially.
Source:
Returns:
True if more data can be accessed sequentially.
Type
Boolean

limit() → {Number}

Return the total size of the underlying data.
Source:
Returns:
The size of the underlying data.
Type
Number

order(order)

Set the byte order of the underlying data.
Parameters:
Name Type Description
order Boolean The byte order of the underlying data.
Source:

seek(position)

Advance to a specific position.
Parameters:
Name Type Description
position Number The specified position.
Source:

skipBytes(numBytes)

Skip over the specified number of bytes.
Parameters:
Name Type Description
numBytes Number The number of bytes to skip.
Source:

skipDoubles(numDoubles)

Skip over the specified number of double precision floating point numbers.
Parameters:
Name Type Description
numDoubles Number The number of double precision floating point numbers to skip.
Source:

skipFloats(numFloats)

Skip over the specified number of single precision floating point numbers.
Parameters:
Name Type Description
numFloats Number The number of single precision floating point numbers to skip.
Source:

skipInt16s(numInt16s)

Skip over the specified number of 16-bit integers.
Parameters:
Name Type Description
numInt16s Number The number of 16-bit integers to skip.
Source:

skipInt32s(numInt32s)

Skip over the specified number of 32-bit integers.
Parameters:
Name Type Description
numInt32s Number The number of 32-bit integers to skip.
Source: