Nine Parsecs from Milwaukee
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    cowpublic

    Cow

    Cow provides a completely transparent copy on write proxy to deep, cyclic js objects.

    Build Status Coverage Status Dependency Status

    Installation

    $ npm install cow
    

    usage

    Also note that the copy correctly preserves the objects inheritance and hidden/accessor properties.

    function Test() { this.child = {}; }
    var obj = new Test(); // provided a normal js object, which
    obj.child.obj = obj; // can contain cycles
    obj.child2 = obj.child // and references
     
    var cow = new Cow(obj);
    var proxy = cow.proxy;
     
    // the proxy has all the properties of obj!
    proxy.child.obj === proxy;
    proxy.child2 === proxy.child;
     
    // we can write new properties
    proxy.child3 = proxy; // even create new cycles!
     
    // convert the proxy back to plain object:
    var finished = cow.finish();
    finished.child3 === finished;
    finished.child.obj === finished;
    finished.child === finished.child2;
     
    // and it has left the original object untouched:
    obj !== finished;
    obj.child !== finished.child;

    License

    LGPLv3

    install

    npm i cow

    Downloadsweekly downloads

    14

    version

    0.2.3

    license

    LGPLv3

    repository

    githubgithub

    last publish

    collaborators

    • avatar