No Description

core.js 747B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. var arrayFindIndex = require('array-find-index');
  3. module.exports = function () {
  4. var unhandledRejections = [];
  5. function onUnhandledRejection(reason, promise) {
  6. unhandledRejections.push({reason: reason, promise: promise});
  7. }
  8. function onRejectionHandled(promise) {
  9. var index = arrayFindIndex(unhandledRejections, function (x) {
  10. return x.promise === promise;
  11. });
  12. unhandledRejections.splice(index, 1);
  13. }
  14. function currentlyUnhandled() {
  15. return unhandledRejections.map(function (entry) {
  16. return {
  17. reason: entry.reason,
  18. promise: entry.promise
  19. };
  20. });
  21. }
  22. return {
  23. onUnhandledRejection: onUnhandledRejection,
  24. onRejectionHandled: onRejectionHandled,
  25. currentlyUnhandled: currentlyUnhandled
  26. };
  27. };