aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@babel/runtime/helpers/asyncToGenerator.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@babel/runtime/helpers/asyncToGenerator.js')
-rw-r--r--node_modules/@babel/runtime/helpers/asyncToGenerator.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/node_modules/@babel/runtime/helpers/asyncToGenerator.js b/node_modules/@babel/runtime/helpers/asyncToGenerator.js
new file mode 100644
index 00000000..81d6d1d2
--- /dev/null
+++ b/node_modules/@babel/runtime/helpers/asyncToGenerator.js
@@ -0,0 +1,39 @@
+var _Promise = require("../core-js/promise");
+
+function _asyncToGenerator(fn) {
+ return function () {
+ var self = this,
+ args = arguments;
+ return new _Promise(function (resolve, reject) {
+ var gen = fn.apply(self, args);
+
+ function step(key, arg) {
+ try {
+ var info = gen[key](arg);
+ var value = info.value;
+ } catch (error) {
+ reject(error);
+ return;
+ }
+
+ if (info.done) {
+ resolve(value);
+ } else {
+ _Promise.resolve(value).then(_next, _throw);
+ }
+ }
+
+ function _next(value) {
+ step("next", value);
+ }
+
+ function _throw(err) {
+ step("throw", err);
+ }
+
+ _next();
+ });
+ };
+}
+
+module.exports = _asyncToGenerator; \ No newline at end of file