Permalink
Browse files

feat(experimental) async generators

  • Loading branch information...
h13i32maru committed Nov 20, 2016
1 parent fe8a265 commit e6dc2f2cd00bff0e24f71a7485baedb79949ee94
View
@@ -65,6 +65,7 @@ export default class ESParser {
if (experimental.doExpressions) option.plugins.push('doExpressions');
if (experimental.functionBind) option.plugins.push('functionBind');
if (experimental.functionSent) option.plugins.push('functionSent');
+ if (experimental.asyncGenerators) option.plugins.push('asyncGenerators');
}
return option;
@@ -5,8 +5,8 @@ <h3 data-ice="anchor">
<span data-ice="static"></span>
<span class="kind" data-ice="kind"></span>
<span class="abstract" data-ice="abstract"></span>
- <span data-ice="generator"></span>
<span data-ice="async"></span>
+ <span data-ice="generator"></span>
<span data-ice="name"></span><span data-ice="signature"></span>
<span class="right-info">
<span class="version" data-ice="version">version </span>
@@ -12,8 +12,8 @@
<td>
<div>
<p>
- <span data-ice="generator"></span>
<span data-ice="async"></span>
+ <span data-ice="generator"></span>
<span data-ice="name"></span><span data-ice="signature"></span>
</p>
</div>
View
@@ -34,6 +34,7 @@
* @property {boolean} experimentalProposal.doExpressions
* @property {boolean} experimentalProposal.functionBind
* @property {boolean} experimentalProposal.functionSent
+ * @property {boolean} experimentalProposal.asyncGenerators
* @see https://esdoc.org/config.html
*/
@@ -0,0 +1,10 @@
+export default class Foo {
+ async *method() {
+ const stream = [ Promise.resolve(4), Promise.resolve(9), Promise.resolve(12) ];
+ let total = 0;
+ for await (const val of stream) {
+ total += await val;
+ yield total;
+ }
+ }
+}
@@ -17,4 +17,9 @@ describe('ESParser', ()=>{
const ast = ESParser.parse({experimentalProposal: {functionSent: true}}, './test/fixture/syntax/FunctionSent.js');
assert(ast.program.sourceType === 'module');
});
+
+ it('can parse "async generators"', ()=>{
+ const ast = ESParser.parse({experimentalProposal: {asyncGenerators: false}}, './test/fixture/syntax/AsyncGenerators.js');
+ assert(ast.program.sourceType === 'module');
+ });
});

0 comments on commit e6dc2f2

Please sign in to comment.