@blockstack/ui
Version:
Blockstack UI components built using React and styled-components with styled-system.
32 lines (26 loc) • 950 B
JavaScript
import { createForOfIteratorHelperLoose as _createForOfIteratorHelperLoose } from '../_virtual/_rollupPluginBabelHelpers.js';
var nativeExceptions = /*#__PURE__*/[EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError].filter(function (except) {
return typeof except === 'function';
});
function throwNative(error) {
for (var _iterator = _createForOfIteratorHelperLoose(nativeExceptions), _step; !(_step = _iterator()).done;) {
var Exception = _step.value;
if (error instanceof Exception) throw error;
}
}
function safeAwait(promise, finallyFn) {
return promise.then(function (data) {
if (data instanceof Error) {
throwNative(data);
return [data];
}
return [undefined, data];
})["catch"](function (error) {
throwNative(error);
return [error];
})["finally"](function () {
if (finallyFn) finallyFn();
});
}
export { safeAwait };
//# sourceMappingURL=safe-await.esm.js.map