0.0.4 • Published 6 months ago

@cartbc/codecs-core v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

npm npm-downloads semantic-release code-style-prettier

@cartbc/codecs-core

This package contains the core types and function for encoding and decoding data structures on Cartes. It can be used standalone, but it is also exported as part of the Cartes JavaScript SDK @cartbc/cartes-web3.js.

Types

bytes

Concatenates an array of Uint8Arrays into a single Uint8Array. Reuses the original byte array when applicable.

codec

Defines an offset in bytes

Functions

assertions

Asserts that a given byte array is not empty

combine-codec

Combines an encoder and a decoder into a codec. The encoder and decoder must have the same fixed size, max size and description. If a description is provided, it will override the encoder and decoder descriptions.

fix-codec

Creates a fixed-size encoder from a given encoder.

@param encoder - The encoder to wrap into a fixed-size encoder. @param fixedBytes - The fixed number of bytes to write. @param description - A custom description for the encoder.

map-codec

Converts an encoder A to a encoder B by mapping their values.

reverse-codec

Reverses the bytes of a fixed-size encoder.