mwg API
    Preparing search index...

    Function cloneData

    • 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.

      Type Parameters

      • T

      Parameters

      • value: T
      • label: string

      Returns T

      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 ...