https://github.com/pivanov/deepclone
https://github.com/pivanov/deepclone
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pivanov/deepclone
- Owner: pivanov
- Created: 2024-09-29T15:24:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-05T11:44:20.000Z (over 1 year ago)
- Last Synced: 2025-04-12T08:04:09.900Z (9 months ago)
- Language: TypeScript
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @pivanov/deep-clone
A versatile and lightweight deep clone utility for JavaScript and TypeScript.
## Installation
```bash
npm install @pivanov/deep-clone --save-dev
```
or with yarn:
```bash
yarn add @pivanov/deep-clone --dev
```
or with pnpm:
```bash
pnpm add @pivanov/deep-clone --dev
```
## Usage
```typescript
import { deepClone } from '@pivanov/deep-clone';
```
> Note that one of inject or fileName must be provided.
```typescript
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](https://github.com/pivanov).
## License
MIT