node-deepcopy
v0.1.1
Published
deep copy for any JavaScript object
Downloads
929
Maintainers
Readme
node-deepcopy
deep copy for any JavaScript object.
Installation
$ npm install node-deepcopy
Example
var deepcopy = require('node-deepcopy').deepcopy;
var toValue = function(obj){
return isFunction(obj) || isRegExp(obj) ? obj.toString() : JSON.stringify(obj);
};
var foo = function () {
this.c = 3;
this.a = [
{e: 2, f: 'good', g: [1, 2, 3]}
];
this.b = 'b';
this.d = function () {
console.log("I'm foo.d.")
};
};
var source = new foo();
var cloned = deepcopy(source);
cloned2.a[0].f = '666';
console.log(cloned === source));
License
MIT