@metreeca/core - v0.9.17
    Preparing search index...

    Function immutable

    • Creates an immutable deep clone.

      Plain objects, arrays, and functions with custom properties are recursively cloned and frozen. Functions without custom properties are returned as-is. Other object types (Date, RegExp, Buffer, etc.) are returned as-is to preserve their functionality.

      Caution

      Circular references are not supported. Do not pass objects with cycles.

      Type Parameters

      • T

        The type of the value to be cloned

      Parameters

      • value: T

        The value to make immutable

      Returns T

      A deeply immutable clone of value

      RangeError - Stack overflow when value contains circular references

      • Only plain objects (those with Object.prototype) and arrays are cloned and frozen. All other objects (Date, RegExp, Map, Set, class instances, objects with null prototype, etc.) are returned as-is to preserve their functionality.
      • This function is idempotent: calling it multiple times on the same value returns the same reference after the first call, making it safe and efficient to use defensively.
      • For functions with custom properties, built-in read-only properties (length, name, prototype) are preserved unchanged while custom writable properties are frozen recursively. Non-configurable custom properties are skipped and remain in their original state.
      • Accessor properties (getters/setters) are preserved as-is without freezing the accessor functions themselves. Getters may still return mutable values.