1.0.0 • Published 9 years ago
shadow-copy v1.0.0
shadow-copy
Creates a shadow copy of an object by using prototype.
Install
$ npm install shadow-copy --save
Usage
var copy = require('shadow-copy');
var obj = {
a: 1
};
var copied = copy(obj);
copied.a; // 1
copied.a = 2;
obj.a; // still 1
copy.deep(obj)
Deeply clone a object by using prototype
var obj = {
a: {
a: 1
}
};
copy.deep(obj).a.a = 2;
obj.a.a; // still 1
copy(obj).a.a = 2;
obj.a.a; // 1
// `copy()` only copy the first level of an object
License
MIT
1.0.0
9 years ago