Creates an immutable deep clone.
Values are processed according to their type:
Date, Map, Set, class
instances, or objects with null prototype)This function is idempotent at every depth: every cloned object and array is branded internally, so calling it again on a frozen clone, or on any nested member extracted from one, returns the same reference. Members reached through multiple paths, or extracted and re-nested into another structure, keep a stable identity. This makes it safe and efficient to use defensively.
Circular references are not supported. Do not pass objects with cycles.
The type of the value to be cloned
The value to make immutable
A deeply frozen clone of value
Creates an immutable deep clone, validating against a type guard.
Values are processed according to their type:
Date, Map, Set, class
instances, or objects with null prototype)Validates value against the guard before freezing:
The guard brands only the top-level clone; nested members carry the default brand, so they remain stable under guard-less immutable calls while a guarded call on a nested member revalidates it.
Circular references are not supported. Do not pass objects with cycles.
Guards must have stable identity. Use module-level named functions or const lambdas.
The validated type of the returned clone
A deeply frozen clone of value, branded with the guard
Creates an immutable deep clone, optionally validating against a type guard.