Skip to main content

Class: WriteStream

Keep track of the write index within a stream.

Table of contents

Constructors

Methods

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

NameTypeDescription
writeIndexnumberThe current write index.

Returns

void


writeFixedHex

writeFixedHex(name, length, val): void

Write fixed length stream.

Parameters

NameTypeDescription
namestringThe name of the data we are trying to write.
lengthnumberThe length of the data to write.
valstringThe data to write.

Returns

void


writeBytes

writeBytes(name, length, val): void

Write fixed length stream.

Parameters

NameTypeDescription
namestringThe name of the data we are trying to write.
lengthnumberThe length of the data to write.
valUint8ArrayThe data to write.

Returns

void


writeUInt8

writeUInt8(name, val): void

Write a byte to the stream.

Parameters

NameTypeDescription
namestringThe name of the data we are trying to write.
valnumberThe data to write.

Returns

void


writeUInt16

writeUInt16(name, val): void

Write a UInt16 to the stream.

Parameters

NameTypeDescription
namestringThe name of the data we are trying to write.
valnumberThe data to write.

Returns

void


writeUInt32

writeUInt32(name, val): void

Write a UInt32 to the stream.

Parameters

NameTypeDescription
namestringThe name of the data we are trying to write.
valnumberThe data to write.

Returns

void


writeUInt64

writeUInt64(name, val): void

Write a UInt64 to the stream.

Parameters

NameTypeDescription
namestringThe name of the data we are trying to write.
valBigIntegerThe data to write.

Returns

void


writeUInt256

writeUInt256(name, val): void

Write a UInt256 to the stream.

Parameters

NameTypeDescription
namestringThe name of the data we are trying to write.
valBigIntegerThe data to write.

Returns

void


writeBoolean

writeBoolean(name, val): void

Write a boolean to the stream.

Parameters

NameTypeDescription
namestringThe name of the data we are trying to write.
valbooleanThe data to write.

Returns

void