Hi Scott, I think your approach is on the right track. How about the
following?
Anyone see a way to attack it?
const goodPromises = new WeakSet();
class DefensivePromise {
constructor(x) {
super(x);
if (new.target === DefensivePromise) {
Object.freeze(this);
goodPromises.add(this);
}
}
static resolve(x) {
if (goodPromises.has(x)) {
return x; // should be equiv to super.resolve(x);
}
return new DefensivePromise(r => {r(x)});
}
}
Note a few typos fixed and a few simplifications, all of which you should
double check. Thanks!
--
Cheers,
--MarkM
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss