Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kelin2025/nanoclone
Tiny util to deep clone JavaScript objects
https://github.com/kelin2025/nanoclone
Last synced: 7 days ago
JSON representation
Tiny util to deep clone JavaScript objects
- Host: GitHub
- URL: https://github.com/kelin2025/nanoclone
- Owner: Kelin2025
- License: mit
- Created: 2017-11-24T00:12:09.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-11T01:22:09.000Z (over 1 year ago)
- Last Synced: 2024-04-23T19:39:13.694Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 289 KB
- Stars: 73
- Watchers: 3
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-javascript - nanoclone
- awesome-javascript - nanoclone
README
# nanoclone
[![license](https://img.shields.io/github/license/kelin2025/nanoclone.svg)](https://github.com/kelin2025/nanoclone/blob/master/LICENSE)
[![npm](https://img.shields.io/npm/v/nanoclone.svg)](https://npmjs.com/package/nanoclone)
Only **300B** to deep clone JavaScript objects## Is it small enough?
See the size of the most popular **[clone](https://www.npmjs.com/package/clone)** npm package with **250M+** downloads
![image](https://user-images.githubusercontent.com/4208480/34631395-30df289c-f281-11e7-8442-01502af2097a.png)
And nanoclone size:
![image](https://user-images.githubusercontent.com/4208480/35292759-9c839f06-0082-11e8-9196-d710d530a74b.png)## Supported
- [x] Primitives
- [x] Arrays
- [x] Plain objects
- [x] DOM Nodes
- [x] Date instances
- [x] RegExp instances
- [x] Maps
- [x] Sets
- [x] Circular structures## Installation
```
yarn add nanoclone
npm install nanoclone
```## Usage
```javascript
import clone from 'nanoclone'let a = {
num: 2,
arr: [1, 2, 3],
nested: {
obj: {
a: 0
}
}
}let b = clone(a)
```## License
MIT