Skip to content

Variable: encode()

ts
const encode: <T>(what: T) => string;

Encodes a value into a compressed base64 string

Type Parameters

Type ParameterDefault type
T extends EncodableEncodable

Parameters

ParameterTypeDescription
whatTThe value to be encoded

Returns

string

A compressed base64 string representing the encoded value

Throws

@nhtio/encoder/exceptions!E_ENCODING_FAILED | E_ENCODING_FAILED When the value cannot be encoded

Throws

@nhtio/encoder/exceptions!E_CIRCULAR_REFERENCE | E_CIRCULAR_REFERENCE When the value contains dangerous circular references

Throws

@nhtio/encoder/exceptions!E_UNENCODABLE_VALUE | E_UNENCODABLE_VALUE When the value contains unencodable data types