Helios API/ API Reference/ Namespaces/

Cbor

Helper methods for (de)serializing data to/from Cbor.

Note: Each decoding method mutates the input bytes by shifting it to the following CBOR element.

Index

Functions

decodeBool

decodeBool(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

decodeBytes

decodeBytes(bytes): number[]

Parameters

NameType
bytesnumber[]

Returns

number[]

decodeConstr

decodeConstr(bytes, fieldDecoder): number

Parameters

NameType
bytesnumber[]
fieldDecoderDecoder

Returns

number

decodeConstrTag

decodeConstrTag(bytes): number

Parameters

NameType
bytesnumber[]

Returns

number

decodeHead

decodeHead(bytes): [number, bigint]

Parameters

NameType
bytesnumber[]

Returns

[number, bigint]

decodeIndefHead

decodeIndefHead(bytes): number

Parameters

NameType
bytesnumber[]

Returns

number

decodeInteger

decodeInteger(bytes): bigint

Parameters

NameType
bytesnumber[]

Returns

bigint

decodeList

decodeList(bytes, itemDecoder): void

Parameters

NameType
bytesnumber[]
itemDecoderDecoder

Returns

void

decodeMap

decodeMap(bytes, pairDecoder): void

Parameters

NameType
bytesnumber[]
pairDecoderDecoder

Returns

void

decodeNull

decodeNull(bytes): void

Parameters

NameType
bytesnumber[]

Returns

void

decodeObject

decodeObject(bytes, fieldDecoder): Set<number>

Parameters

NameType
bytesnumber[]
fieldDecoderDecoder

Returns

Set<number>

decodeTag

decodeTag(bytes): bigint

Parameters

NameType
bytesnumber[]

Returns

bigint

decodeTuple

decodeTuple(bytes, tupleDecoder): number

Parameters

NameType
bytesnumber[]
tupleDecoderDecoder

Returns

number

decodeUtf8

decodeUtf8(bytes): string

Parameters

NameType
bytesnumber[]

Returns

string

decodeUtf8Internal

decodeUtf8Internal(bytes): string

Parameters

NameType
bytesnumber[]

Returns

string

encodeBool

encodeBool(b): number[]

Parameters

NameType
bboolean

Returns

number[]

encodeBytes

encodeBytes(bytes, splitIntoChunks?): number[]

Parameters

NameType
bytesnumber[]
splitIntoChunks?boolean

Returns

number[]

encodeConstr

encodeConstr(tag, fields): number[]

Parameters

NameType
tagnumber
fieldsCborData[] | number[][]

Returns

number[]

encodeConstrTag

encodeConstrTag(tag): number[]

Parameters

NameType
tagnumber

Returns

number[]

encodeDefList

encodeDefList(list): number[]

Parameters

NameType
listCborData[] | number[][]

Returns

number[]

encodeDefListStart

encodeDefListStart(n): number[]

Parameters

NameType
nbigint

Returns

number[]

encodeHead

encodeHead(m, n): number[]

Parameters

NameType
mnumber
nbigint

Returns

number[]

encodeIndefHead

encodeIndefHead(m): number[]

Parameters

NameType
mnumber

Returns

number[]

encodeIndefList

encodeIndefList(list): number[]

Parameters

NameType
listCborData[] | number[][]

Returns

number[]

encodeIndefListEnd

encodeIndefListEnd(): number[]

Returns

number[]

encodeIndefListStart

encodeIndefListStart(): number[]

Returns

number[]

encodeInteger

encodeInteger(n): number[]

Parameters

NameType
nbigint

Returns

number[]

encodeList

encodeList(list): number[]

Parameters

NameType
listCborData[] | number[][]

Returns

number[]

encodeListInternal

encodeListInternal(list): number[]

Parameters

NameType
listCborData[] | number[][]

Returns

number[]

encodeMap

encodeMap(pairList): number[]

Parameters

NameType
pairList[number[] | CborData, number[] | CborData][]

Returns

number[]

encodeMapInternal

encodeMapInternal(pairList): number[]

Parameters

NameType
pairList[number[] | CborData, number[] | CborData][]

Returns

number[]

encodeNull

encodeNull(): number[]

Returns

number[]

encodeObject

encodeObject(object): number[]

Parameters

NameType
objectMap<number, number[] | CborData>

Returns

number[]

encodeTag

encodeTag(tag): number[]

Parameters

NameType
tagbigint

Returns

number[]

encodeTuple

encodeTuple(tuple): number[]

Parameters

NameType
tuplenumber[][]

Returns

number[]

encodeUtf8

encodeUtf8(str, split?): number[]

Parameters

NameType
strstring
split?boolean

Returns

number[]

isBytes

isBytes(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isConstr

isConstr(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isDefBytes

isDefBytes(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isDefList

isDefList(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isIndefBytes

isIndefBytes(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isIndefList

isIndefList(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isList

isList(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isMap

isMap(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isNull

isNull(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isObject

isObject(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isTuple

isTuple(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean

isUtf8

isUtf8(bytes): boolean

Parameters

NameType
bytesnumber[]

Returns

boolean