0.0.1 • Published 9 years ago

@dmail/object-clone v0.0.1

Weekly downloads
1
License
-
Repository
github
Last release
9 years ago

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