2.0.0 • Published 1 year ago
@pivanov/deep-clone v2.0.0
@pivanov/deep-clone
A versatile and lightweight deep clone utility for JavaScript and TypeScript.
Installation
npm install @pivanov/deep-clone --save-devor with yarn:
yarn add @pivanov/deep-clone --devor with pnpm:
pnpm add @pivanov/deep-clone --devUsage
import { deepClone } from '@pivanov/deep-clone';Note that one of inject or fileName must be provided.
const userProfile = {
name: "Alice",
contact: {
email: "alice@example.com",
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