error-cause
Version:
An ES-spec-compliant shim/polyfill/replacement for the `.cause` property on all Error types that works as far down as ES3
17 lines (15 loc) • 384 B
JavaScript
module.exports = function polyfillHelper(C, implementation) {
return function polyfill() {
var options = { cause: { sentinel: true } };
var e = new C('a', options);
if (
'cause' in e
&& !('cause' in C.prototype) // https://bugs.chromium.org/p/v8/issues/detail?id=12006
&& e.cause === options.cause
) {
return C;
}
return implementation;
};
};
;