Version 1.7.0
Creates a new instance of StreamDataView from a string. e.g. from the string of toByteString()
Param | Type | Description |
---|---|---|
str | string | Byte string like ‘48 65 6C 6C 6F’ |
Returns StreamDataView
New instance of StreamDataView.
Creates a new instance of StreamDataView from a string.
Param | Type | Description |
---|---|---|
str | string | Text string like ‘Hello’ |
utf8 | boolean | (optional) Handle the string as uft-8. |
Returns StreamDataView
New instance of StreamDataView.
The constructor of this class.
Param | Type | Description |
---|---|---|
buffer | ArrayBuffer , number | Array buffer. |
bigEndian | boolean | (optional) Use big endian for numbers. (default: little endian) |
If buffer is omitted, the buffer length is dynamically. (initially 0
(zero))
See resize-method for more information. A omitted buffer sets the stream length mode to auto-resize.
Returns the array buffer of the data view.
Returns ArrayBuffer
The buffer of this data view.
Moves the offset relative in a direction.
Param | Type | Description |
---|---|---|
length | number | Positive or negative number byte length. |
Returns void
Moves the offset to zero.
Returns void
Returns the current offset.
Returns number
Offset
Sets a new offset to an absolute position.
Param | Type | Description |
---|---|---|
offset | number | New offset (starts from zero) |
Returns void
Reads a 8-bit singed integer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
Returns number
INT8 value.
Reads a 8-bit unsinged integer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
Returns number
UINT8 value.
Reads the next 8-bit singed integer from current offset.
Returns number
INT8 value.
Reads the next 8-bit unsinged integer from curret offset.
Returns number
UINT8 value.
Reads a 16-bit singed integer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
Returns number
INT16 value.
Reads a 16-bit unsinged integer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
Returns number
UINT16 value.
Reads the next 16-bit singed integer.
Returns number
INT16 value.
Reads the next 16-bit unsinged integer.
Returns number
UINT16 value.
Reads a 32-bit singed integer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
Returns number
INT32 value.
Reads a 32-bit unsinged integer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
Returns number
UINT32 value.
Reads the next 32-bit singed integer.
Returns number
INT32 value.
Reads the next 32-bit unsinged integer.
Returns number
UINT32 value.
Reads a float. (32-bit, signed)
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
Returns number
FLOAT value.
Reads a double. (64-bit signed)
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
Returns number
DOUBLE value.
Reads the next float. (32-bit, signed)
Returns number
FLOAT value.
Reads the next double. (64-bit, signed)
Returns number
DOUBLE value.
Writes a 8-bit signed integer to the buffer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
value | number | Value to write. |
Returns void
Writes a 8-bit unsigned integer to the buffer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
value | number | Value to write. |
Returns void
Writes the next 8-bit signed integer to the buffer.
Param | Type | Description |
---|---|---|
value | number | Value to write. |
Returns void
Writes the next 8-bit unsigned integer to the buffer.
Param | Type | Description |
---|---|---|
value | number | Value to write. |
Returns void
Writes a 16-bit signed integer to the buffer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
value | number | Value to write. |
Returns void
Writes a 16-bit unsigned integer to the buffer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
value | number | Value to write. |
Returns void
Writes the next 16-bit signed integer to the buffer.
Param | Type | Description |
---|---|---|
value | number | Value to write. |
Returns void
Writes the next 16-bit unsigned integer to the buffer.
Param | Type | Description |
---|---|---|
value | number | Value to write. |
Returns void
Writes a 32-bit signed integer to the buffer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
value | number | Value to write. |
Returns void
Writes a 32-bit unsigned integer to the buffer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
value | number | Value to write. |
Returns void
Writes the next 32-bit signed integer to the buffer.
Param | Type | Description |
---|---|---|
value | number | Value to write. |
Returns void
Writes the next 32-bit unsigned integer to the buffer.
Param | Type | Description |
---|---|---|
value | number | Value to write. |
Returns void
Writes a float to the buffer. (32-bit, signed)
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
value | number | Value to write. |
Returns void
Writes a double to the buffer. (64-bit, signed)
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
value | number | Value to write. |
Returns void
Writes the next float to the buffer. (32-bit, signed)
Param | Type | Description |
---|---|---|
value | number | Value to write. |
Returns void
Writes the next double to the buffer. (64-bit, signed)
Param | Type | Description |
---|---|---|
value | number | Value to write. |
Returns void
Reads an array of bytes.
Param | Type | Description |
---|---|---|
offset | number | (optional) Buffer offset. |
length | number | (optional) Buffer length. |
Returns Uint8Array
Byte array like [42, 12, 255, 0]
Reads the next array of bytes.
Param | Type | Description |
---|---|---|
length | number | (optional) Buffer length. (default: remaining length) |
Returns Uint8Array
Byte array like [42, 12, 255, 0]
Writes a byte array to the buffer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
data | Uint8Array | ArrayBuffer | number[] | Byte array to write. |
Returns void
Writes the next byte array to the buffer.
Param | Type | Description |
---|---|---|
data | Uint8Array | ArrayBuffer | number[] | Byte array to write. |
Returns void
Reads a string from the buffer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
length | number | Buffer length. |
utf8 | boolean | (optional) Use utf-8 encoding. (default: ascii) |
untilTerminator | boolean | (optional) Only returns the string until zero terminator. |
Returns string
String as utf8 or ascii.
Returns a string from the buffer.
Param | Type | Description |
---|---|---|
length | number | Buffer length. |
utf8 | boolean | (optional) Use utf-8 encoding. (default: ascii) |
untilTerminator | boolean | (optional) Only returns the string until zero terminator. Does not affect the offset shifting. |
Returns string
String as utf8 or ascii.
Sets a string to the buffer.
Param | Type | Description |
---|---|---|
offset | number | Buffer offset. |
data | string | Data to write. |
utf8 | boolean | (optional) Use utf-8. (default: ascii) |
length | number | (optional) Optional fixed length write on buffer. |
Returns number
The the length in byte of the string. Useful for dynamic length.
Sets a string to the buffer.
Param | Type | Description |
---|---|---|
data | string | Data to write. |
utf8 | boolean | (optional) Use uff-8. (default: ascii) |
length | number | (optional) Optional fixed length write on buffer. |
Returns void
Converts the buffer to a pretty print byte string.
Returns string
Byte string like ‘48 65 6C 6C 6F’.
Converts the buffer to a text string.
Param | Type | Description |
---|---|---|
utf8 | boolean | (optional) Handle it as UTF8 string otherwise ASCII. |
Returns string
Text string as utf8 or ascii.
Parses a string of bytes like ‘48 65 6C 6C 6F’. Also see the method ‘toByteString’.
Param | Type | Description |
---|---|---|
str | string | Byte string. |
Returns void
Resize the buffer size. NOTE: It creates a new buffer.
Param | Type | Description |
---|---|---|
length | number | New length of stream. |
Returns void
Crops the stream at its current offset. e.g. You have a stream of 10 bytes but only 4 bytes used. (offset at 4). This method uses the integrated resize-method.
Returns void
Returns the length in bytes of this stream buffer.
Returns number
Clears the buffer and resets the offset.
Returns void
Copyright (c) 2018 - 2021 Dominik Geng