JS/TS API Reference

Below are the TypeScript API reference for the Sia serialization library.

Constructor

Creates a new Sia instance. If content is provided, the Sia instance will be initialized with the provided content.

Attributes

NameDescription
contentThe current content of the Sia instance.
offsetThe current offset of the Sia instance pointer.
sizeThe length of the content.
dataViewThe DataView of the Sia instance.

Methods

NameDescription
seekChanges the offset of the Sia instance pointer.
skipChanges the offset of the Sia instance pointer by the given amount.
setContentReplaces the content of the Sia instance with the given content.
embedSiaAdds the content of the provided Sia instance to the current content.
embedBytesAdds the provided bytes to the current content.
addUInt8Adds an unsigned 8-bit integer to the current content.
addUInt16Adds an unsigned 16-bit integer to the current content.
addUInt32Adds an unsigned 32-bit integer to the current content.
addUInt64Adds an unsigned 64-bit integer to the current content.
addInt8Adds a signed 8-bit integer to the current content.
addInt16Adds a signed 16-bit integer to the current content.
addInt32Adds a signed 32-bit integer to the current content.
addInt64Adds a signed 64-bit integer to the current content.
addUtfzAdds a null-terminated UTF-8 string to the current content.
addAsciiAdds an ASCII string to the current content.
addString8Adds a string of 8-bit length to the current content.
addString16Adds a string of 16-bit length to the current content.
addString32Adds a string of 32-bit length to the current content.
addString64Adds a string of 64-bit length to the current content.
addByteArrayNAdds a byte array of specified length to the current content.
addByteArray8Adds a byte array of 8-bit length to the current content.
addByteArray16Adds a byte array of 16-bit length to the current content.
addByteArray32Adds a byte array of 32-bit length to the current content.
addByteArray64Adds a byte array of 64-bit length to the current content.
addBoolAdds a boolean value to the current content.
addBigIntAdds a BigInt value to the current content.
addArray8Adds an array of items to the current content prefixed with an 8-bit length. The provided function is called for each item to serialize it.
addArray16Adds an array of items to the current content prefixed with a 16-bit length. The provided function is called for each item to serialize it.
addArray32Adds an array of items to the current content prefixed with a 32-bit length. The provided function is called for each item to serialize it.
addArray64Adds an array of items to the current content prefixed with a 64-bit length. The provided function is called for each item to serialize it.
readUInt8Reads an unsigned 8-bit integer from the current position.
readUInt16Reads an unsigned 16-bit integer from the current position.
readUInt32Reads an unsigned 32-bit integer from the current position.
readUInt64Reads an unsigned 64-bit integer from the current position.
readInt8Reads a signed 8-bit integer from the current position.
readUtfzReads a null-terminated UTF-8 string from the current position.
readAsciiReads an ASCII string from the current position.
readString8Reads a string of 8-bit length from the current position.
readString16Reads a string of 16-bit length from the current position.
readString32Reads a string of 32-bit length from the current position.
readString64Reads a string of 64-bit length from the current position.
readByteArrayNReads a byte array of specified length from the current position.
readByteArray8Reads a byte array of 8-bit length from the current position.
readByteArray16Reads a byte array of 16-bit length from the current position.
readByteArray32Reads a byte array of 32-bit length from the current position.
readByteArray64Reads a byte array of 64-bit length from the current position.
readBoolReads a boolean value from the current position.
readBigIntReads a BigInt value from the current position.
readArray8Reads an array of items from the current position using the 8-bit length prefix. The provided function is called for each item to deserialize it.
readArray16Reads an array of items from the current position using the 16-bit length prefix. The provided function is called for each item to deserialize it.
readArray32Reads an array of items from the current position using the 32-bit length prefix. The provided function is called for each item to deserialize it.
readArray64Reads an array of items from the current position using the 64-bit length prefix. The provided function is called for each item to deserialize it.

Utility Methods

seek

Changes the offset of the Sia instance pointer.

skip

Changes the offset of the Sia instance pointer by the given amount.

setContent

Replaces the content of the Sia instance with the given content.

embedSia

Adds the contents of the provided Sia instance to the current Sia instance.

embedBytes

Adds the provided bytes to the current content.

Add Methods

addUInt8

Adds an unsigned 8-bit integer to the current content.

addUInt16

Adds an unsigned 16-bit integer to the current content.

addUInt32

Adds an unsigned 32-bit integer to the current content.

addUInt64

Adds an unsigned 64-bit integer to the current content.

addInt8

Adds a signed 8-bit integer to the current content.

addInt16

Adds a signed 16-bit integer to the current content.

addInt32

Adds a signed 32-bit integer to the current content.

addInt64

Adds a signed 64-bit integer to the current content.

addUtfz

Adds a null-terminated UTF-8 string to the current content.

addAscii

Adds an ASCII string to the current content.

addString8

Adds a string of 8 bytes to the current content.

addString16

Adds a string of 16 bytes to the current content.

addString32

Adds a string of 32 bytes to the current content.

addString64

Adds a string of 64 bytes to the current content.

addByteArrayN

Adds a byte array of specified length to the current content.

addByteArray8

Adds a byte array of specified length to the current content.

addByteArray16

Adds a byte array of specified length to the current content.

addByteArray32

Adds a byte array of specified length to the current content.

addByteArray64

Adds a byte array of specified length to the current content.

addBool

Adds a boolean value to the current content.

addBigInt

Adds a BigInt value to the current content.

addArray8

Adds an array of items to the current content, prefixed with an 8-bit length. The provided function is called for each item to serialize it.

addArray16

Adds an array of items to the current content, prefixed with a 16-bit length. The provided function is called for each item to serialize it.

addArray32

Adds an array of items to the current content, prefixed with a 32-bit length. The provided function is called for each item to serialize it.

addArray64

Adds an array of items to the current content, prefixed with a 64-bit length. The provided function is called for each item to serialize it.

Read Methods

readUInt8

Reads an unsigned 8-bit integer from the current position.

readUInt16

Reads an unsigned 16-bit integer from the current position.

readUInt32

Reads an unsigned 32-bit integer from the current position.

readUInt64

Reads an unsigned 64-bit integer from the current position.

readInt8

Reads a signed 8-bit integer from the current position.

readInt16

Reads a signed 16-bit integer from the current position.

readInt32

Reads a signed 32-bit integer from the current position.

readInt64

Reads a signed 64-bit integer from the current position.

readUtfz

Reads a null-terminated UTF-8 string from the current position.

readAscii

Reads an ASCII string from the current position.

readString8

Reads a string of 8 bytes from the current position.

readString16

Reads a string of 16 bytes from the current position.

readString32

Reads a string of 32 bytes from the current position.

readString64

Reads a string of 64 bytes from the current position.

readByteArray8

Reads a byte array of specified length from the current position. If asReference is true, returns a view into the underlying buffer instead of copying the data.

readByteArray16

Reads a byte array of specified length from the current position. If asReference is true, returns a view into the underlying buffer instead of copying the data.

readByteArray32

Reads a byte array of specified length from the current position. If asReference is true, returns a view into the underlying buffer instead of copying the data.

readByteArray64

Reads a byte array of specified length from the current position. If asReference is true, returns a view into the underlying buffer instead of copying the data.

readBool

Reads a boolean value from the current position.

readBigInt

Reads a BigInt value from the current position.

readArray8

Reads an array of items from the current position, using the 8-bit length prefix. The provided function is called for each item to deserialize it.

readArray16

Reads an array of items from the current position, using the 16-bit length prefix. The provided function is called for each item to deserialize it.

readArray32

Reads an array of items from the current position, using the 32-bit length prefix. The provided function is called for each item to deserialize it.

readArray64

Reads an array of items from the current position, using the 64-bit length prefix. The provided function is called for each item to deserialize it.

How was this page?

Timeleap SA.

Pl. de l'Industrie 2, 1180 Rolle, Switzerland

Logo

Social Media

Tokenomics

Info