2017-09-23 15:31:37 +08:00
|
|
|
# fast-deep-copy
|
|
|
|
Only 20 lines code! no deps!
|
|
|
|
|
2017-09-23 15:34:41 +08:00
|
|
|
## Useage:
|
2017-09-23 15:31:37 +08:00
|
|
|
```
|
|
|
|
npm install -S fast-deep-copy
|
|
|
|
```
|
|
|
|
|
2017-09-23 15:09:50 +08:00
|
|
|
```js
|
2017-09-23 15:31:37 +08:00
|
|
|
|
2017-09-23 15:09:50 +08:00
|
|
|
import { deepCopy } from 'fast-deep-copy'
|
2017-09-23 15:31:37 +08:00
|
|
|
|
|
|
|
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
|
2017-09-23 15:09:50 +08:00
|
|
|
```
|