Skip to content

Function: createDecodeBudget() ​

ts
function createDecodeBudget(limits?: DecodeLimits): DecodeBudget;

Creates an opaque budget sharing total inflated bytes across decode() calls. Limits are merged with DEFAULT_DECODE_LIMITS and must be positive finite numbers or Infinity; invalid values throw TypeError. Depth remains per call and array-length caps remain per value. Diagnostics are read-only.

Parameters ​

ParameterType
limits?DecodeLimits

Returns ​

DecodeBudget

Example ​

ts
const budget = createDecodeBudget();
const schema = decode<{ datetimeFormats: string[] }>(payload, { budget });
const formats = schema.datetimeFormats.map((flag) => decode(flag, { budget }));