Hi,
Is there any way to decorate a method on a strong class in V8 4.6? I have a
lot of code that does `A.prototype.m = Promise.coroutine(A.prototype.m);`
as in this example, sometimes on many methods.
"use strong";
const Promise = require('bluebird');
class A {
*m() {
yield new Promise();
}
}
// TypeError: Cannot assign to read only property 'm' of #<A>
//A.prototype.m = Promise.coroutine(A.prototype.m);
// TypeError: Can't add property mAsync, object is not extensible
//A.prototype.mAsync = Promise.coroutine(A.prototype.m);
In an unfortunate turn of events, the `this` limitations prevent me from
doing it in the constructor as well:
class B {
constructor() {
// SyntaxError: In strong mode, 'this' can only be used to
// initialize properties, and cannot be nested inside another
// statement or expression
this.m = Promise.coroutine(this._m);
}
*_m() {
yield new Promise();
}
}
Of course, I could move *_m() outside of the class to avoid that problem,
but that's getting into silly territory. m() could have an inner function that
decorates every time, or I could write my own little method cache, but
neither of those seem appealing either.
Thanks,
Ivan