Skip to content

Commit

Permalink
feat(experimental) async generators
Browse files Browse the repository at this point in the history
  • Loading branch information
h13i32maru committed Nov 20, 2016
1 parent fe8a265 commit e6dc2f2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Parser/ESParser.js
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Publisher/Builder/template/details.html
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/Publisher/Builder/template/summary.html
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions src/Typedef/typedef.js
Expand Up @@ -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
*/

Expand Down
10 changes: 10 additions & 0 deletions test/fixture/syntax/AsyncGenerators.js
@@ -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;
}
}
}
5 changes: 5 additions & 0 deletions test/src/ParserTest/ESParserTest.js
Expand Up @@ -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.