add support for statements in asyncToGenerator and bluebirdCoroutines transformers
This commit is contained in:
3
test/fixtures/transformation/optional-async-to-generator/statement/actual.js
vendored
Normal file
3
test/fixtures/transformation/optional-async-to-generator/statement/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
async function foo() {
|
||||
var wat = await bar();
|
||||
}
|
||||
42
test/fixtures/transformation/optional-async-to-generator/statement/expected.js
vendored
Normal file
42
test/fixtures/transformation/optional-async-to-generator/statement/expected.js
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
var _asyncToGenerator = function (fn) {
|
||||
return function () {
|
||||
var gen = fn.apply(this, arguments);
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
function step(getNext) {
|
||||
var next;
|
||||
try {
|
||||
next = getNext();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
|
||||
return;
|
||||
}
|
||||
if (next.done) {
|
||||
resolve(next.value);
|
||||
|
||||
return;
|
||||
}
|
||||
Promise.resolve(next.value).then(function (v) {
|
||||
step(function () {
|
||||
return gen.next(v);
|
||||
});
|
||||
}, function (e) {
|
||||
step(function () {
|
||||
return gen["throw"](e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
step(function () {
|
||||
return gen.next();
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var foo = _asyncToGenerator(function* foo() {
|
||||
var wat = yield bar();
|
||||
});
|
||||
Reference in New Issue
Block a user