Class: DataStream

DataStream

DataStream is a wrapper for DataView which allows reading the data as a linear stream of data.


new DataStream(dataView)

Parameters:
Name Type Description
dataView

the DataView object to read from.

Author:
  • derschmale <http://www.derschmale.com>

Members


<static> BIG_ENDIAN

Big Endian encoding


<static> LITTLE_ENDIAN

Little Endian encoding


byteLength

The size of the data view in bytes.


bytesAvailable

The amount of bytes still left in the file until EOF.


endian

The endianness used by the data.


offset

The current byte offset into the file.

Methods


getChar()

Reads a single 8-bit string character from the stream.


getFloat32()

Reads a single float.


getFloat32Array(len)

Reads an array of single floats.

Parameters:
Name Type Description
len

The amount of elements to read.


getFloat64()

Reads a double float.


getFloat64Array(len)

Reads an array of double floats.

Parameters:
Name Type Description
len

The amount of elements to read.


getInt8()

Reads a single signed byte integer from the string.


getInt8Array(len)

Reads an array of signed bytes.

Parameters:
Name Type Description
len

The amount of elements to read.


getInt16()

Reads a single signed short integer from the string.


getInt16Array(len)

Reads an array of signed shorts.

Parameters:
Name Type Description
len

The amount of elements to read.


getInt32()

Reads a single 32 bit integer from the string.


getInt32Array(len)

Reads an array of signed 32-bit integers.

Parameters:
Name Type Description
len

The amount of elements to read.


getInt64AsFloat64()

Reads a 64-bit integer and stores it in a Number. The read value is not necessarily the same as what's stored, but may provide an acceptable approximation.


getInt64AsFloat64Array(len)

Reads an array of 64-bit integers into floats.

Parameters:
Name Type Description
len

The amount of elements to read.


getString( [len])

Reads a string.

Parameters:
Name Type Argument Description
len <optional>

The amount of characters in the string. If omitted, it reads until (and including) it encounters a "\0" character.


getUint8()

Reads a single unsigned byte integer from the string.


getUint8Array(len)

Reads an array of unsigned bytes.

Parameters:
Name Type Description
len

The amount of elements to read.


getUint16()

Reads a single unsigned short integer from the string.


getUint16Array(len)

Reads an array of unsigned shorts.

Parameters:
Name Type Description
len

The amount of elements to read.


getUint32()

Reads a single unsigned 32-bit integer from the string.


getUint32Array(len)

Reads an array of unsigned 32-bit integers.

Parameters:
Name Type Description
len

The amount of elements to read.