mirror of
https://github.com/zhaolihang/fast-deep-copy.git
synced 2026-03-06 00:00:03 +08:00
23 lines
483 B
Markdown
23 lines
483 B
Markdown
# fast-deep-copy
|
|
Only 20 lines code! no deps!
|
|
It can correctly handle circular references!
|
|
|
|
## Useage:
|
|
```
|
|
npm install -S fast-deep-copy
|
|
```
|
|
|
|
```js
|
|
|
|
import { deepCopy } from 'fast-deep-copy'
|
|
|
|
let a = { dataA: 10, b: null };
|
|
let b = { dataB: 20, a: null };
|
|
a.b = b;
|
|
b.a = a;
|
|
|
|
let newA = deepCopy(a);
|
|
console.log(newA.dataA === 10); //true
|
|
console.log(newA.b.dataB === 20); //true
|
|
console.log(newA.b.a === newA); //true
|
|
``` |