Cow
Cow provides a completely transparent copy on write proxy to deep, cyclic js objects.
Installation
$ npm install cow
usage
Also note that the copy correctly preserves the objects inheritance and hidden/accessor properties.
{ thischild = {}; }var obj = ; // provided a normal js object, whichobjchildobj = obj; // can contain cyclesobjchild2 = objchild // and references var cow = obj;var proxy = cowproxy; // the proxy has all the properties of obj!proxychildobj === proxy;proxychild2 === proxychild; // we can write new propertiesproxychild3 = proxy; // even create new cycles! // convert the proxy back to plain object:var finished = cow;finishedchild3 === finished;finishedchildobj === finished;finishedchild === finishedchild2; // and it has left the original object untouched:obj !== finished;objchild !== finishedchild;
License
LGPLv3