Repository URL to install this package:
|
Version:
3.3.0-rc.1 ▾
|
/**
* Maps Promise.allSettled rejections into errors
*
* @private
* @param {PromiseSettledResult<undefined>[]} results - The results of Promise.allSettledPromise
* @return {Error[]} - A collection of errors returned by PromiseAllSettled
*/
var getRejectionErrors = function getRejectionErrors(results) {
return results.filter(function (result) {
return result.status === 'rejected';
}).map(function (_ref) {
var reason = _ref.reason;
return reason;
});
};
/**
* Handles any errors in an array of Promise.allSettled results
*
* @private
* @param {PromiseSettledResult<undefined>[]} results - The results of Promise.allSettledPromise
* @param {Function} handler - A handler for errors
* @return {boolean} - Whether all dispatcher results were successful
*/
var handleDispatchErrors = function handleDispatchErrors() {
var results = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var handler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
var errors = getRejectionErrors(results);
var hasErrors = errors.length > 0;
errors.forEach(function (error) {
return handler(error);
});
return !hasErrors;
};
export { getRejectionErrors, handleDispatchErrors };
//# sourceMappingURL=errors.js.map