Skip to content

oracular / serialize

Function: serialize() ​

ts
function serialize(state): string;

Defined in: serialize.ts:33

The state as a JSON string, for the host app to persist wherever it likes. The state is plain data, so this is JSON.stringify after a shape check. The output never contains event props.

Parameters ​

ParameterTypeDescription
stateEngineStateThe state to persist.

Returns ​

string

A JSON string that deserialize restores losslessly.

Throws ​

TypeError when state is not an engine state.

Example ​

ts
localStorage.setItem('oracular', serialize(state));

Released under the MIT License.