fast-deep-copy/readme.md
zhaolihang-com 7b8a85e788 add types
2024-10-19 17:36:14 +08:00

483 B

fast-deep-copy

Only 20 lines code! no deps!
It can correctly handle circular references!

Useage:

    npm install -S fast-deep-copy

    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