encodeCborSequence
import { encodeCborSequence } from "jsr:@ende/cbor";function
function encodeCborSequence(values: CborType[]): Uint8ArrayEncodes an array of CborType values into a CBOR format sequence represented as a Uint8Array. RFC 8949 - Concise Binary Object Representation (CBOR)
Returns
A Uint8Array representing the encoded data.
Example: Usage
import { assertEquals } from "@ende/assert";
import { type CborType, decodeCborSequence, encodeCborSequence } from "@ende/cbor";
const rawMessage = [
"Hello World",
35,
0.5,
false,
-1,
null,
Uint8Array.from([0, 1, 2, 3]),
new Date(),
new Map<CborType, CborType>([[1, 2], ['3', 4], [[5], { a: 6 }]]),
];
const encodedMessage = encodeCborSequence(rawMessage);
const decodedMessage = decodeCborSequence(encodedMessage);
assertEquals(decodedMessage, rawMessage);