node-deepcopy

    0.1.1 • Public • Published

    node-deepcopy

    Build Status Coverage Status npm version Dependency Status

    https://www.npmjs.org/package/request-gb

    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

    Install

    npm i node-deepcopy

    DownloadsWeekly Downloads

    3

    Version

    0.1.1

    License

    MIT

    Last publish

    Collaborators

    • moyerock