I'm late for this party, but I also tried to use arguments.caller after a lot of trial and error, perhaps if you use a prototype.
This does not work:
class MyClass { watchProperties() { Object.defineProperty(this, 'myproperty', { get: function f(value) { }, set: function f(value) { console.log(arguments.caller.name); } }); } } var foo = new MyClass; foo.watchProperties(); foo.myproperty = 'bar';
But using the prototype, he does the following:
class MyClass {
}
MyClass.prototype.watchProperties = function() { Object.defineProperty(this, 'myproperty', { get: function f(value) { }, set: function f(value) { console.log(arguments.caller.name); } }); }; var foo = new MyClass; foo.watchProperties(); foo.myproperty = 'bar';
It is functionally identical. I donβt know why one of them is prevented by node and the other is not, but this is a workaround in node 6.0.
Tom b source share