@openhps/core
    Preparing search index...

    Function cloneDeep

    • Deep clone a value.

      Replaces require('lodash.clonedeep'). That was a bare CommonJS require in a file re-exported through the public barrel, which tsc leaves untouched in the ESM output — so any native-ESM consumer hit "require is not defined in ES module scope" the moment the package was imported.

      structuredClone is not a substitute here: the serialization layer clones typedjson member metadata, which holds constructor references and serializer/deserializer hooks, and structuredClone throws on functions. Matching lodash, functions are therefore carried over by reference rather than cloned, and prototypes are preserved so class instances stay their own type.

      Type Parameters

      • T

      Parameters

      • value: T

        Value to clone

      • seen: WeakMap<object, any> = ...

        Tracks visited objects so cyclic graphs terminate

      Returns T

      A deep copy of the value