Skip to main content
Module

x/bencodex/mod.ts>DecodingOptions

An alternative take on implementing Bencodex in TypeScript/JavaScript
Latest
interface DecodingOptions
import { type DecodingOptions } from "https://deno.land/x/bencodex@0.2.2/mod.ts";

Options for decoding a Bencodex value.

Properties

optional
onInvalidKeyOrder: "error" | "ignore"

Whether to silently ignore or stop decoding and report an error when dictionary keys are not ordered according to the Bencodex specification. The default value is "error".

When this option is set to "ignore" and the decoder encounters duplicate dictionary keys, the behavior is undefined and depends on the implementation of the dictionaryConstructor. In case of BencodexDictionary (default), the key appeared the latest will be used.

When this option is set to "error", decode function throws an DecodingErrorKind when it encounters duplicate dictionary keys.

optional
dictionaryConstructor: new (entries: Iterable<[Key, Value]>) => Dictionary

The Dictionary type to use for representing decoded dictionaries. The default value is BencodexDictionary. You can set this option to other implementations of Dictionary such as Map<Key, Value>.