transformCBORValueToNative()
Transforms the CBOR values to native JS values.
Values are decoded as:
- Positive integers (
CBORPositiveInteger):NumberorBigIntdepending on the size. - Negative integers (
CBORNegativeInteger):NumberorBigIntdepending on the size. - Byte strings (
CBORByteString):Uint8Array. - Text strings (
CBORTextString):String. Those with invalid UTF-8 encoding are considered invalid. - Arrays (
CBORArray):Arrayof transformed values. - Maps (
CBORMap): JS object where integer and float keys are converted to strings withNumber.toString(). As such, integer 1 and float 1.0 are considered the same key. Maps with duplicate keys after stringify-ing them are considered invalid. Maps with the text key__proto__are also considered invalid. - Floats (
CBORFloat16,CBORFloat32,CBORFloat64):Number. This may cause minor accuracy issues for float16 and 32. - Simple values (
CBORSimple):true,false,null,undefined. Everything else is considered invalid. - Tagged values (
CBORTagged): Tags are ignored and the underlying value is transformed.
Unlike decodeCBOR(), this also validates the data and will throw CBORInvalidError on invalid data.
Definition
function transformCBORValueToNative(cbor: CBORValue): unknown;
Parameters
cbor: CBOR values except for breaks.