UI for Zipcoin Blue

core.js 747B

12345678910111213141516171819202122232425262728293031323334
  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. };