asyncToGenerator.js 956 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var _Promise = require("@babel/runtime-corejs3/core-js/promise");
  2. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  3. try {
  4. var info = gen[key](arg);
  5. var value = info.value;
  6. } catch (error) {
  7. reject(error);
  8. return;
  9. }
  10. if (info.done) {
  11. resolve(value);
  12. } else {
  13. _Promise.resolve(value).then(_next, _throw);
  14. }
  15. }
  16. function _asyncToGenerator(fn) {
  17. return function () {
  18. var self = this,
  19. args = arguments;
  20. return new _Promise(function (resolve, reject) {
  21. var gen = fn.apply(self, args);
  22. function _next(value) {
  23. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  24. }
  25. function _throw(err) {
  26. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  27. }
  28. _next(undefined);
  29. });
  30. };
  31. }
  32. module.exports = _asyncToGenerator;
  33. module.exports["default"] = module.exports, module.exports.__esModule = true;