Class: shaka.util.BufferUtils

A set of BufferSource utility functions.

Constructor

new BufferUtils()

A set of BufferSource utility functions.

Source:

Methods

equal(arr1nullable, arr2nullable) → {boolean}

Compare two buffers for equality. For buffers of different types, this compares the underlying buffers as binary data.
Parameters:
Name Type Attributes Description
arr1 BufferSource <nullable>
arr2 BufferSource <nullable>
Source:
Returns:
Type
boolean

toArrayBuffer(viewnon-null) → {ArrayBuffer}

Gets an ArrayBuffer that contains the data from the given TypedArray. Note this will allocate a new ArrayBuffer if the object is a partial view of the data.
Parameters:
Name Type Description
view BufferSource
Source:
Returns:
Type
ArrayBuffer

toDataView(buffer, offsetopt, lengthopt) → {DataView}

Creates a DataView over the given buffer.
Parameters:
Name Type Attributes Default Description
buffer BufferSource
offset number <optional>
0
length number <optional>
Source:
See:
  • toUint8
Returns:
Type
DataView

toUint8(data, offsetopt, lengthopt) → {Uint8Array}

Creates a new Uint8Array view on the same buffer. This clamps the values to be within the same view (i.e. you can't use this to move past the end of the view, even if the underlying buffer is larger). However, you can pass a negative offset to access the data before the view.
Parameters:
Name Type Attributes Default Description
data BufferSource
offset number <optional>
0 The offset from the beginning of this data's view to start the new view at.
length number <optional>
The byte length of the new view.
Source:
Returns:
Type
Uint8Array

toUint16(data, offsetopt, lengthopt) → {Uint16Array}

Creates a new Uint16Array view on the same buffer. This clamps the values to be within the same view (i.e. you can't use this to move past the end of the view, even if the underlying buffer is larger). However, you can pass a negative offset to access the data before the view.
Parameters:
Name Type Attributes Default Description
data BufferSource
offset number <optional>
0 The offset from the beginning of this data's view to start the new view at.
length number <optional>
The byte length of the new view.
Source:
Returns:
Type
Uint16Array

unsafeGetArrayBuffer_(view) → {ArrayBuffer}

Gets the underlying ArrayBuffer of the given view. The caller needs to ensure it uses the "byteOffset" and "byteLength" fields of the view to only use the same "view" of the data.
Parameters:
Name Type Description
view BufferSource
Source:
Returns:
Type
ArrayBuffer

view_(data, offset, length, Type) → {T}

Parameters:
Name Type Description
data BufferSource
offset number
length number
Type function(new:T, ArrayBuffer, number, number)
Source:
Returns:
Type
T