Function decodeCborSequence
- decode
Cbor (input): CborType[]Sequence Parameters
- input: Uint8Array
The value to decode of type CBOR-sequence-encoded Uint8Array.
Returns CborType[]
A CborType array representing the decoded data.
Example: Usage
import { assertEquals } from "@std/assert";
import { type CborType, decodeCborSequence, encodeCborSequence } from "@std/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);- input: Uint8Array
Decodes a CBOR-sequence-encoded Uint8Array into the JavaScript equivalent values represented as a CBorType array. RFC 8949 - Concise Binary Object Representation (CBOR)
Limitations:
Notice: This decoder handles the tag numbers 0, and 1 automatically, all others returned are wrapped in a CborTag instance.