encodeState
functionsignature
encodeState(input, options): EncodeResultEncodes a value into something JSON.stringify can carry losslessly.
Parameters
| Name | Type | Description |
|---|---|---|
input | unknown | Any value, including one holding Map, Set, Date, BigInt or cycles. |
| Name | Type | Description |
|---|---|---|
options | EncodeOptions | Redaction and size limits. |
Returns
EncodeResult — The encoded value plus a report of anything that could not be represented.
Example
example
const { value } = encodeState({ index: new Map([['a', 1]]) });
JSON.stringify(value); // safe, and decodeState restores the Map