@cartbc/codecs-core
v0.0.4
Published
Core types and helpers for encoding and decoding byte arrays on Cartes
Downloads
10
Maintainers
Readme
[![npm][npm-image]][npm-url] [![npm-downloads][npm-downloads-image]][npm-url] [![semantic-release][semantic-release-image]][semantic-release-url] [![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]
@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 Uint8Array
s 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.