cbor2
    Preparing search index...

    Interface CommentOptions

    Comment options on top of the decode options.

    interface CommentOptions {
        boxed?: boolean;
        cde?: boolean;
        collapseBigInts?: boolean;
        convertUnsafeIntsToFloat?: boolean;
        createObject?: ObjectCreator;
        dcbor?: boolean;
        diagnosticSizes?: DiagnosticSizes;
        encoding?: "base64" | "hex" | null;
        ignoreGlobalTags?: boolean;
        initialDepth?: number;
        keepNanPayloads?: boolean;
        maxDepth?: number;
        minCol: number;
        noPrefixHex?: boolean;
        preferBigInt?: boolean;
        preferMap?: boolean;
        pretty?: boolean;
        rejectBigInts?: boolean;
        rejectDuplicateKeys?: boolean;
        rejectFloats?: boolean;
        rejectInts?: boolean;
        rejectLargeNegatives?: boolean;
        rejectLongFloats?: boolean;
        rejectLongLoundNaN?: boolean;
        rejectNegativeZero?: boolean;
        rejectSimple?: boolean;
        rejectStreaming?: boolean;
        rejectStringsNotNormalizedAs?: StringNormalization | null;
        rejectSubnormals?: boolean;
        rejectUndefined?: boolean;
        rejectUnsafeFloatInts?: boolean;
        requirePreferred?: boolean;
        saveOriginal?: boolean;
        sortKeys?: KeySorter | null;
        tags?: TagDecoderMap | null;
    }

    Hierarchy (View Summary)

    Index

    Properties

    boxed?: boolean

    Should numbers and strings be created as boxed instances, which retain their original encoding for round-tripping?

    If this is true, saveOriginal is also set to true. Think of this as "saveOriginal + extras". The thought is that most use cases for saveOriginal will want the original encoding of an object or array, and won't care about the original encoding of strings and numbers. Turning this on also has the side-effect of making all CBOR maps decode as JS Map objects, rather than plain Objects, since the string keys will need to be instances of String.

    false
    
    cde?: boolean

    Turn on all options for draft-ietf-cbor-cde-05.

    collapseBigInts?: boolean

    Should bigints that can fit into normal integers be collapsed into normal integers?

    true
    
    convertUnsafeIntsToFloat?: boolean

    In dCBOR, JS numbers between 2^53 and 2^64 get encoded as CBOR integers. When decoding, present them as JS numbers instead of BigInt, losing accuracy.

    createObject?: ObjectCreator

    Create an object from an array of key-value pairs. The default implementation creates a plain JS object if all of the keys are strings, otherwise creates a Map (unless preferMap or boxed is set, in which case a Map is always created).

    dcbor?: boolean

    Turn on all options for draft-mcnally-deterministic-cbor-11.

    diagnosticSizes?: DiagnosticSizes

    When producing diagnostic output, should the size of an element always be appended to that element using an underscore when calling diagnose?

    DiagnosticSizes.PREFERRED
    
    encoding?: "base64" | "hex" | null

    If the input is a string, how should it be decoded into a byte stream? Ignored if the input is a Uint8Array.

    null
    
    ignoreGlobalTags?: boolean

    Do not consider the global tag registry when decoding tags.

    initialDepth?: number

    For the root object, how many levels of nesting is it already? Happens with tag 24.

    0
    
    keepNanPayloads?: boolean

    Keep NaN payloads by creating an instance of NAN when needed. Ignored if rejectLongLoundNaN is true.

    maxDepth?: number

    Maximum allowed depth to parse into CBOR structures. This limit is security-relevant for untrusted inputs. May be set to Infinity for trusted inputs, but be careful!

    1024
    
    minCol: number

    The '--' separating bytes from description must be in at least this column.

    0
    
    noPrefixHex?: boolean

    Don't add the initial 0xHEX line to comment output.

    false
    
    preferBigInt?: boolean

    Always generate bigint numbers from CBOR integers (major type 0 or 1).

    This would be used in profiles that want to crisply distinguish between float and int types. On the encode side, you might want avoidInts=true and collapseBigInts=true to pair with this. If true, convertUnsafeIntsToFloat is ignored.

    preferMap?: boolean

    Always generate Map instances when decoding, instead of trying to generate object instances when all of the keys are strings.

    A slight performance improvement if you don't need plain objects. If you have the boxed option on, this option has no effect, and Maps are always produced.

    pretty?: boolean

    Pretty-print diagnostic format.

    false
    
    rejectBigInts?: boolean

    If there are bigint (tag 2/3) in the incoming data, throw an exception.

    false
    
    rejectDuplicateKeys?: boolean

    If there are duplicate keys in a map, should we throw an exception?

    Note: this is more compute-intensive than expected at the moment, but that will be fixed eventually.

    false
    
    rejectFloats?: boolean

    Reject any floating point numbers.

    This might be used in profiles that are not expecting floats to prevent one from being coerced to an integer-looking number without the receiver knowing.

    false
    
    rejectInts?: boolean

    Reject any mt 0/1 numbers.

    This might be used in profiles that expect all numbers to be encoded as floating point.

    false
    
    rejectLargeNegatives?: boolean

    Reject negative integers in the range [CBOR_NEGATIVE_INT_MAX ... STANDARD_NEGATIVE_INT_MAX - 1].

    false
    
    rejectLongFloats?: boolean

    Reject floating point numbers that should have been encoded in shorter form, including having been encoded as an integer.

    rejectLongLoundNaN?: boolean

    Reject NaNs that are not encoded as 0x7e00.

    This includes non-trivial NaNs without a quiet bit, with a sign bit, or with a payload. It also includes NaNs that are encoded with a float larger than f16.

    false
    
    rejectNegativeZero?: boolean

    If negative zero (-0.0) is received, throw an error.

    false
    
    rejectSimple?: boolean

    Reject simple values other than true, false, undefined, and null.

    false
    
    rejectStreaming?: boolean

    Reject any attempt to decode streaming CBOR.

    Enforces the Definite-Length-Only (DLO) constraint.

    false
    
    rejectStringsNotNormalizedAs?: StringNormalization | null

    Reject strings that are not normalized with the given normalization form. Don't use this without Unicode expertise.

    rejectSubnormals?: boolean

    Reject subnormal floating point numbers.

    false
    
    rejectUndefined?: boolean

    Reject the undefined simple value.

    Usually used with rejectSimple.

    false
    
    rejectUnsafeFloatInts?: boolean

    For dCBOR, reject "integers" between 2^53 and 2^64 that were encoded as floats.

    requirePreferred?: boolean

    Reject integers and additional-information lengths that could have been encoded in a smaller encoding.

    Usually rejectLongFloats is also desired.

    false
    
    saveOriginal?: boolean

    Save the original bytes associated with every object as a property of that object for exact round-tripping. Use getEncoded(obj) to retrieve the associated bytes. If you need the original encoded form of primitive items such as numbers and strings, set boxed: true as well.

    sortKeys?: KeySorter | null

    If non-null, keys being decoded MUST be in this order. Note that this is a superset of rejectDuplicateKeys, and is slightly more efficient.

    null
    
    tags?: TagDecoderMap | null

    If non-null, prefer any tags in the map to ones have have been registered with Tag.registerDecoder.