Cloning options with all properties required
A function to recursively clone objects, arrays etc. with cloning options
References Functions & Symbols by default
Example:
import { clone } from "@thalesrc/js-utils/object";
const object = {a: 1, b: {c: true, d: ["x", "y"]}};
// Clone all
const clonedObject = clone(object);
// {a: 1, b: {c: true, d: ["x", "y"]}}
// object.b.d === clonedObject.b.d // false
// Clone all but reference "d"
const clonedObject = clone(object, {propsToRefer: ["d"]});
// {a: 1, b: {c: true, d: ["x", "y"]}}
// object.b.d === clonedObject.b.d // true
Static usage example:
import "@thalesrc/js-utils/object/static/clone";
const object = {a: 1, b: 2};
const clonedObject = Object.clone(object); // {a: 1, b: 2}
Object to clone
Generated using TypeDoc
Custom Cloner Function