asyncGeneratorDelegate.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var _Promise = require("@babel/runtime-corejs3/core-js/promise");
  2. var _Symbol = require("@babel/runtime-corejs3/core-js/symbol");
  3. var _Symbol$iterator = require("@babel/runtime-corejs3/core-js/symbol/iterator");
  4. function _asyncGeneratorDelegate(inner, awaitWrap) {
  5. var iter = {},
  6. waiting = false;
  7. function pump(key, value) {
  8. waiting = true;
  9. value = new _Promise(function (resolve) {
  10. resolve(inner[key](value));
  11. });
  12. return {
  13. done: false,
  14. value: awaitWrap(value)
  15. };
  16. }
  17. ;
  18. iter[typeof _Symbol !== "undefined" && _Symbol$iterator || "@@iterator"] = function () {
  19. return this;
  20. };
  21. iter.next = function (value) {
  22. if (waiting) {
  23. waiting = false;
  24. return value;
  25. }
  26. return pump("next", value);
  27. };
  28. if (typeof inner["throw"] === "function") {
  29. iter["throw"] = function (value) {
  30. if (waiting) {
  31. waiting = false;
  32. throw value;
  33. }
  34. return pump("throw", value);
  35. };
  36. }
  37. if (typeof inner["return"] === "function") {
  38. iter["return"] = function (value) {
  39. if (waiting) {
  40. waiting = false;
  41. return value;
  42. }
  43. return pump("return", value);
  44. };
  45. }
  46. return iter;
  47. }
  48. module.exports = _asyncGeneratorDelegate;
  49. module.exports["default"] = module.exports, module.exports.__esModule = true;