Class: WriteStream
Keep track of the write index within a stream.
Table of contents
Constructors
Methods
- length
- unused
- finalBytes
- finalHex
- getWriteIndex
- setWriteIndex
- writeFixedHex
- writeBytes
- writeUInt8
- writeUInt16
- writeUInt32
- writeUInt64
- writeUInt256
- writeBoolean
Constructors
constructor
• new WriteStream()
Create a new instance of ReadStream.
Methods
length
▸ length(): number
Get the length of the stream.
Returns
number
The stream length.
unused
▸ unused(): number
How much unused data is there.
Returns
number
The amount of unused data.
finalBytes
▸ finalBytes(): Uint8Array
Get the final stream as bytes.
Returns
Uint8Array
The final stream.
finalHex
▸ finalHex(): string
Get the final stream as hex.
Returns
string
The final stream as hex.
getWriteIndex
▸ getWriteIndex(): number
Get the current write index.
Returns
number
The current write index.
setWriteIndex
▸ setWriteIndex(writeIndex
): void
Set the current write index.
Parameters
Name | Type | Description |
---|---|---|
writeIndex | number | The current write index. |
Returns
void
writeFixedHex
▸ writeFixedHex(name
, length
, val
): void
Write fixed length stream.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the data we are trying to write. |
length | number | The length of the data to write. |
val | string | The data to write. |
Returns
void
writeBytes
▸ writeBytes(name
, length
, val
): void
Write fixed length stream.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the data we are trying to write. |
length | number | The length of the data to write. |
val | Uint8Array | The data to write. |
Returns
void
writeUInt8
▸ writeUInt8(name
, val
): void
Write a byte to the stream.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the data we are trying to write. |
val | number | The data to write. |
Returns
void
writeUInt16
▸ writeUInt16(name
, val
): void
Write a UInt16 to the stream.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the data we are trying to write. |
val | number | The data to write. |
Returns
void
writeUInt32
▸ writeUInt32(name
, val
): void
Write a UInt32 to the stream.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the data we are trying to write. |
val | number | The data to write. |
Returns
void
writeUInt64
▸ writeUInt64(name
, val
): void
Write a UInt64 to the stream.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the data we are trying to write. |
val | BigInteger | The data to write. |
Returns
void
writeUInt256
▸ writeUInt256(name
, val
): void
Write a UInt256 to the stream.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the data we are trying to write. |
val | BigInteger | The data to write. |
Returns
void
writeBoolean
▸ writeBoolean(name
, val
): void
Write a boolean to the stream.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the data we are trying to write. |
val | boolean | The data to write. |
Returns
void