diff --git a/escodegen.js b/escodegen.js index 41b3850f..26e75385 100644 --- a/escodegen.js +++ b/escodegen.js @@ -953,7 +953,7 @@ }; CodeGenerator.prototype.generateIterationForStatement = function (operator, stmt, flags) { - var result = ['for' + space + (stmt.await ? 'await' + space : '') + '('], that = this; + var result = ['for' + (stmt.await ? noEmptySpace() + 'await' : '') + space + '('], that = this; withIndent(function () { if (stmt.left.type === Syntax.VariableDeclaration) { withIndent(function () { diff --git a/package.json b/package.json index 5e649dde..eea60d44 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "escodegen.js", "package.json" ], - "version": "1.12.0", + "version": "1.12.1", "engines": { "node": ">=4.0" }, @@ -32,7 +32,7 @@ "dependencies": { "estraverse": "^4.2.0", "esutils": "^2.0.2", - "esprima": "^3.1.3", + "esprima": "^4.0.1", "optionator": "^0.8.1" }, "optionalDependencies": { diff --git a/test/harmony.js b/test/harmony.js index 249bf34e..45e9d67a 100644 --- a/test/harmony.js +++ b/test/harmony.js @@ -6322,6 +6322,83 @@ data = { }, + 'ES2018 for-await-of with `compact: true`': { + 'async function f(){for await(const x of ait){console.log(x);}}': { + options: { + format: { + compact: true + } + }, + generateFrom: { + "type": "FunctionDeclaration", + "id": { + "type": "Identifier", + "name": "f" + }, + "params": [], + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ForOfStatement", + "left": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x" + }, + "init": null + } + ], + "kind": "const" + }, + "right": { + "type": "Identifier", + "name": "ait" + }, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console" + }, + "property": { + "type": "Identifier", + "name": "log" + }, + "computed": false + }, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } + ] + }, + "await": true + } + ] + }, + "generator": false, + "async": true + } + } + + }, + 'ES2018 async generator method': { 'class C {\n async *readLines(file) {\n while (!file.EOF) {\n yield await file.readLine();\n }\n }\n}': { generateFrom: {