diff --git a/tslib.es6.js b/tslib.es6.js index e92a088..c2ce0be 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -139,17 +139,17 @@ export function __asyncGenerator(thisArg, _arguments, generator) { function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } - function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } - function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === "yield" ? send : fulfill, reject); } + function send(value) { settle(c[2], { value: value, done: false }); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { c = void 0, f(v), next(); } }; export function __asyncDelegator(o) { - var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }, p; return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } + function verb(n, f) { return function (v) { return v = p && n === "throw" ? f(v) : p && v.done ? v : { value: p ? ["yield", v.value] : ["await", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; } }; export function __asyncValues(o) { diff --git a/tslib.js b/tslib.js index 6503b8b..4e4fbcc 100644 --- a/tslib.js +++ b/tslib.js @@ -169,17 +169,17 @@ var __asyncValues; function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } - function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); } - function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); } + function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === "yield" ? send : fulfill, reject); } + function send(value) { settle(c[2], { value: value, done: false }); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { c = void 0, f(v), next(); } }; __asyncDelegator = function (o) { - var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }; + var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }, p; return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; } + function verb(n, f) { return function (v) { return v = p && n === "throw" ? f(v) : p && v.done ? v : { value: p ? ["yield", v.value] : ["await", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; } }; __asyncValues = function (o) {