mirrorprop
v1.0.1
Published
Forwards property get/sets to another object
Downloads
4
Readme
mirrorprop
Forwards property get/sets from one object to another
Installation
$ npm install mirrorprop
Usage
const mirrorprop = require("copyprop");
var x = {_testValue: 1};
Object.defineProperty(x, "test", {
get() {return this._testValue}
set(value) {console.log("tried to set `test` to", value)}
});
x.test; // 1
x.test = 5; // tried to set `test` to 5
x.test; // 1
var y = {};
mirror(y, "test2", x, "test");
y.test; // undefined
y.test2; // 1
y.test2 = 5; // tried to set `test` to 5
y.test2; // 1
x._testValue = 100;
y.test2; // 100
License
MIT