structuredClone, with a failure that names what could not be copied and where, instead of the bare DataCloneError a journal or undo checkpoint would otherwise surface far from the code that put a live object there.
structuredClone
DataCloneError
import { cloneData } from '@datamoc/mwg/core';const checkpoint = cloneData({ turn: 3, hp: { king: 12 } }, 'state');cloneData({ onHit: () => {} }, 'command'); // throws: command.onHit cannot be structured-cloned ... Copy
import { cloneData } from '@datamoc/mwg/core';const checkpoint = cloneData({ turn: 3, hp: { king: 12 } }, 'state');cloneData({ onHit: () => {} }, 'command'); // throws: command.onHit cannot be structured-cloned ...
structuredClone, with a failure that names what could not be copied and where, instead of the bareDataCloneErrora journal or undo checkpoint would otherwise surface far from the code that put a live object there.