Closed bergus closed 7 years ago
User-space brand detection should check .constructor.name. This is not foolproof, but user-space branding code is in general not good, and something the proposal intentionally does not support.
OK, if you intentionally don't want to limit functionality then fine (though I don't necessarily get your reasoning).
I'll reopen this for committee discussion. Although I don't like to support such branding, it's true this is a primitive currently only granted to the language, and we should see what the committee thinks.
Ah, actually we can extract it from the language primitives:
function isCancel(e) {
try {
throw e;
} else {
return true;
} finally {
return false;
}
}
but that's horrible code and I'd much rather see a builtin function for this. Thanks for reopening.
If custom promise libraries (that don't just subclass the builtin
Promise
) want to support the new cancellation approach, they'll need a way to detect objects with a [[CancelBrand]] so that they can avoid to fire their rejection tracking. I suggest we include aCancel.isCancel
function for that, analogous toArray.isArray
.