Skip to content

rockdragon/node-deepcopy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-deepcopy

Build Status Coverage Status npm version Dependency Status

https://www.npmjs.org/package/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

About

deep copy for any JavaScript object

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published