add support for statements in asyncToGenerator and bluebirdCoroutines transformers

This commit is contained in:
Sebastian McKenzie
2015-01-02 04:58:59 +11:00
parent a813341433
commit a18177026c
11 changed files with 86 additions and 12 deletions

View File

@@ -0,0 +1,3 @@
async function foo() {
var wat = await bar();
}

View 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();
});