mwg API
    Preparing search index...

    Function uncloneablePath

    • Where structuredClone would fail inside value, as a readable path (command.attacker. reactions.rules[0].when), or null when the whole value clones. A function, a symbol, a WeakMap/WeakSet, a Promise or a DOM node all fail; a class instance on its own does not (its own fields are copied and its prototype dropped), so the path points at the first field that actually cannot be copied rather than at the object holding it.

      Parameters

      • value: unknown
      • root: string = 'value'

      Returns string | null

      import { uncloneablePath } from '@datamoc/mwg/core';

      uncloneablePath({ target: { id: 'king', onHit: () => {} } }, 'command'); // 'command.target.onHit'
      uncloneablePath({ targetId: 'king' }, 'command'); // null