@blockchaincommons/dcbor - v1.0.0-beta.1
    Preparing search index...
    • Decode a single dCBOR item from data, enforcing every deterministic encoding rule (canonical numeric forms, NFC text, map-key order, no trailing bytes). Throws CborError on any violation.

      Parameters

      • data: Uint8Array

      Returns Cbor

      const value = decodeCbor(hexToBytes("a1616101")); // {"a": 1}
      expectMap(value).size; // 1

      Underrun | UnsupportedHeaderValue | NonCanonicalNumeric | InvalidSimpleValue | InvalidUtf8 | NonCanonicalString | UnusedData | MisorderedMapKey | DuplicateMapKey - see CborErrorDetailsByCode.

      Decoded byte strings are zero-copy views aliasing the input buffer - mutating the input after decoding (or mutating the returned bytes) changes the other side. Call .slice() first if you need an independent copy. This is deliberate: the zero-copy decode performance profile is part of the library's contract.