cloneDeepWith es-toolkit
Deeply clones the given value with a custom cloning function.
Usage
cloneDeepWith(obj, cloneValue)
Use cloneDeepWith when you want to deeply copy an object or array with custom logic for specific values. If the custom function cloneValue returns a value, that value is used; if it returns undefined, the default deep copying method is used.
The custom function receives the current value, key, original object, and internal stack information as parameters.
Using a custom function allows you to freely configure how objects are cloned. For example, you can copy Date objects to be one year in the future.
Parameters
The value to deeply copy.
A custom cloning function. Return the value to clone, or return undefined to use the default method.
value: The current value being cloned.key: The property name of the current value.obj: The original object to clone.stack: An internal stack to handle circular references.
Returns
A deep copy processed through the custom function.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.