Nutritious Pumpkin Masses

    @dmail/object-clone

    0.0.1 • Public • Published

    clone

    Deeply clone an object, support circular references & property descriptors

    var clone = require('@dmail/object-clone');
    
    var a = {name: 'a'};
    var b = clone(a);
    b.name; // 'a'
    
    // of course b != a

    It clone deeply

    var a = {
    	list: [
    		{name: 'first'}
    	]
    };
    var b = clone(a);
    
    b.list[0].name; // 'first'
    b.list != a.list; // true

    It support property descriptors

    var a = {
    	get name(){
    		return 'a';
    	}
    };
    var b = clone(a);
    b.name; // 'a'

    It support circular references

    var a = {};
    a.self = a;
    var b = clone(a);
    
    a.self; // a
    b.self; // b

    Keywords

    none

    Install

    npm i @dmail/object-clone

    DownloadsWeekly Downloads

    3

    Version

    0.0.1

    License

    none

    Last publish

    Collaborators

    • dmail