https://github.com/ritik97/clonify
A lightweight and reliable deep cloning utility for objects, arrays, maps, sets, and more โ with full TypeScript support.
https://github.com/ritik97/clonify
deep-clone javascript npm-package object-clone open-source typescript utility
Last synced: 14 days ago
JSON representation
A lightweight and reliable deep cloning utility for objects, arrays, maps, sets, and more โ with full TypeScript support.
- Host: GitHub
- URL: https://github.com/ritik97/clonify
- Owner: Ritik97
- License: mit
- Created: 2025-04-10T10:55:34.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-10T12:13:28.000Z (about 1 year ago)
- Last Synced: 2025-04-11T07:07:18.069Z (about 1 year ago)
- Topics: deep-clone, javascript, npm-package, object-clone, open-source, typescript, utility
- Language: TypeScript
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


# Clonify
> A lightweight and reliable deep cloning utility for JavaScript and TypeScript.
**Clonify** is a zero-dependency deep cloning function that handles objects, arrays, maps, sets, dates, regex, symbols, and custom class instances. It also supports circular references.
---
## โจ Features
- ๐ Deep clones complex nested structures
- ๐ Handles circular references safely
- ๐ง Clones Maps, Sets, Dates, Regex, Symbols
- ๐ Preserves prototypes of custom class instances
- ๐งพ Full TypeScript support
---
## ๐ฆ Installation
```bash
npm install clonify
```
---
## ๐ Usage
```ts
import { clonify } from 'clonify'
class User {
constructor(public name: string) {}
}
const original = {
user: new User("Ritik"),
numbers: [1, 2, 3],
meta: new Map([["key", "value"]]),
}
original.self = original // circular reference
const copy = clonify(original)
console.log(copy)
```
---
## ๐ API
### `clonify(value: any): any`
Performs a deep clone of the provided value, supporting all standard JavaScript data structures.
---
## ๐งช Supported Types
- Objects (POJOs and class instances)
- Arrays
- Maps
- Sets
- Dates
- RegExps
- Symbols (as keys and values)
- Circular references
---
## ๐ License
MIT ยฉ [Ritik](https://github.com/Ritik97)