Variable: decode()
const decode: <T>(base64: string, options?: DecodeOptions) => T;Decodes a compressed base64 string back into a value
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends Encodable | Encodable |
Parameters
| Parameter | Type | Description |
|---|---|---|
base64 | string | The compressed base64 string representing an encoded value |
options? | DecodeOptions | Decoding options. Resource limits default to 16 MiB total inflation, depth 32 and 1,048,576 array/collection entries. maxInflatedBytes counts each byte of inflated data once: nested layers are charged only for growth beyond their already-counted encoded input, so transient gross allocation is bounded by roughly maxDepth × maxInflatedBytes. Raise via limits for trusted payloads; violations throw E_UNDECODABLE_VALUE. Invalid limit values throw TypeError; Infinity explicitly opts out. Functions (fns:d records) are only rehydrated when allowFunctions is true; by default they throw @nhtio/encoder/exceptions!E_UNDECODABLE_VALUE | E_UNDECODABLE_VALUE. |
Returns
T
The decoded value
Throws
@nhtio/encoder/exceptions!E_NOT_AN_ENCODED_VALUE | E_NOT_AN_ENCODED_VALUE When the provided string is not a valid encoded value
Throws
@nhtio/encoder/exceptions!E_INVALID_VERSION | E_INVALID_VERSION When the encoded value has an invalid version
Throws
@nhtio/encoder/exceptions!E_INCOMPATIBLE_VERSION | E_INCOMPATIBLE_VERSION When the encoded value is from a version that is newer than the decoder version
Throws
@nhtio/encoder/exceptions!E_UNDECODABLE_VALUE | E_UNDECODABLE_VALUE When the encoded value cannot be decoded
WARNING
Only pass allowFunctions: true for payloads you trust: rehydrated functions are constructed with the Function constructor from the payload's own text, and decoding untrusted input with functions allowed enables arbitrary code execution.