@pivanov/deep-clone
v2.0.0
Published
Deep clone of objects
Downloads
150
Maintainers
Readme
@pivanov/deep-clone
A versatile and lightweight deep clone utility for JavaScript and TypeScript.
Installation
npm install @pivanov/deep-clone --save-dev
or with yarn:
yarn add @pivanov/deep-clone --dev
or with pnpm:
pnpm add @pivanov/deep-clone --dev
Usage
import { deepClone } from '@pivanov/deep-clone';
Note that one of inject or fileName must be provided.
const userProfile = {
name: "Alice",
contact: {
email: "[email protected]",
phone: { mobile: "123-456", work: "789-101" },
},
preferences: new Set(["dark-mode", "notifications"]),
};
const clonedProfile = deepClone(userProfile);
// Modifying the cloned profile won’t affect the original
clonedProfile.contact.phone.mobile = '999-999';
Author
Created by pivanov.
License
MIT