onmessage = (e) => { const data = JSON.stringify(e.data.editorState, getCircularReplacer(), e.data.spaces); postMessage(data); }; const getCircularReplacer = () => { return (key, value) => { if (key === 'containers') { return [...value.entries()] .map(([Key, Value]) => ({ Key, Value })); } if (key === 'symbols') { return [...value.entries()] .map(([Key, Value]) => ({ Key, Value })); } if (key === 'linkedContainers') { return Array.from(value); } return value; }; };