Interface: DecodeOptions
Options that control how a value is decoded.
WARNING
Decoding must be treated as untrusted input handling by default. Only enable allowFunctions for payloads you produced yourself or otherwise fully trust.
Properties
| Property | Type | Description |
|---|---|---|
allowFunctions? | boolean | Allow fns:d records in the payload to be rehydrated into live functions. Rehydration ultimately calls the Function constructor, so this must only be enabled for trusted input. Defaults to false, in which case any fns:d record throws E_UNDECODABLE_VALUE. |
allowUnsafeKeys? | boolean | Allow plain object keys named __proto__, constructor, or prototype. Defaults to false, in which case such keys throw E_UNDECODABLE_VALUE. When enabled, these keys are still defined safely as own, enumerable data properties using Object.defineProperty without invoking setters on Object.prototype, preventing prototype pollution. |
budget? | DecodeBudget | Share inflation accounting across decode() calls. Uses the budget's limits; passing both budget and limits throws TypeError. Depth is still per call. |
limits? | DecodeLimits | Per-call resource limits, merged with DEFAULT_DECODE_LIMITS (16 MiB total inflation, depth 32, 1,048,576 array/collection entries). Raise for trusted payloads only; violations throw E_UNDECODABLE_VALUE. Invalid limits throw TypeError. Infinity explicitly disables a limit. |
onDisallowedFunction? | "throw" | "skip" | Controls how fns:d records are handled when allowFunctions is not true. Defaults to 'throw', preserving the default rejection. 'skip' returns a no-op function (() => undefined) without calling FunctionSerializer or reading data._s. |