Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/tracking / dist / esm / src / helpers / errors.js
Size: Mime:
/**
 * 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