Keep track of the read index within a stream.
- length
- hasRemaining
- unused
- getReadIndex
- setReadIndex
- readFixedHex
- readBytes
- readByte
- readUInt16
- readUInt32
- readUInt64
- readBoolean
• new ReadStream(storage
, readStartIndex?
)
Create a new instance of ReadStream.
Name | Type | Default value | Description |
---|---|---|---|
storage |
Uint8Array |
undefined |
The data to access. |
readStartIndex |
number |
0 |
The index to start the reading from. |
▸ length(): number
Get the length of the storage.
number
The storage length.
▸ hasRemaining(remaining
): boolean
Does the storage have enough data remaining.
Name | Type | Description |
---|---|---|
remaining |
number |
The amount of space needed. |
boolean
True if it has enough data.
▸ unused(): number
How much unused data is there.
number
The amount of unused data.
▸ getReadIndex(): number
Get the current read index.
number
The current read index.
▸ setReadIndex(readIndex
): void
Set the current read index.
Name | Type | Description |
---|---|---|
readIndex |
number |
The current read index. |
void
▸ readFixedHex(name
, length
, moveIndex?
): string
Read fixed length as hex.
Name | Type | Default value | Description |
---|---|---|---|
name |
string |
undefined |
The name of the data we are trying to read. |
length |
number |
undefined |
The length of the data to read. |
moveIndex |
boolean |
true |
Move the index pointer on. |
string
The hex formatted data.
▸ readBytes(name
, length
, moveIndex?
): Uint8Array
Read an array of byte from the stream.
Name | Type | Default value | Description |
---|---|---|---|
name |
string |
undefined |
The name of the data we are trying to read. |
length |
number |
undefined |
The length of the array to read. |
moveIndex |
boolean |
true |
Move the index pointer on. |
Uint8Array
The value.
▸ readByte(name
, moveIndex?
): number
Read a byte from the stream.
Name | Type | Default value | Description |
---|---|---|---|
name |
string |
undefined |
The name of the data we are trying to read. |
moveIndex |
boolean |
true |
Move the index pointer on. |
number
The value.
▸ readUInt16(name
, moveIndex?
): number
Read a UInt16 from the stream.
Name | Type | Default value | Description |
---|---|---|---|
name |
string |
undefined |
The name of the data we are trying to read. |
moveIndex |
boolean |
true |
Move the index pointer on. |
number
The value.
▸ readUInt32(name
, moveIndex?
): number
Read a UInt32 from the stream.
Name | Type | Default value | Description |
---|---|---|---|
name |
string |
undefined |
The name of the data we are trying to read. |
moveIndex |
boolean |
true |
Move the index pointer on. |
number
The value.
▸ readUInt64(name
, moveIndex?
): BigInteger
Read a UInt64 from the stream.
Name | Type | Default value | Description |
---|---|---|---|
name |
string |
undefined |
The name of the data we are trying to read. |
moveIndex |
boolean |
true |
Move the index pointer on. |
BigInteger
The value.
▸ readBoolean(name
, moveIndex?
): boolean
Read a boolean from the stream.
Name | Type | Default value | Description |
---|---|---|---|
name |
string |
undefined |
The name of the data we are trying to read. |
moveIndex |
boolean |
true |
Move the index pointer on. |
boolean
The value.