From 236068453c2e3fe90df5f2e2594e2f9bca8670f1 Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Fri, 3 Jan 2020 03:29:08 +0300 Subject: [PATCH 1/3] Fixed missing space between `for await` with `compact: true` --- escodegen.js | 2 +- test/harmony.js | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) 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/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: { From a30ea92a3111837372648e0ab166becb442adf10 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Thu, 2 Jan 2020 17:45:08 -0800 Subject: [PATCH 2/3] Version 1.12.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e649dde..8831f71a 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" }, From 819a63b8d73dc830b84dc2e140628c26e3e52909 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Tue, 24 Sep 2019 14:14:53 +0100 Subject: [PATCH 3/3] Update esprima to 4.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8831f71a..eea60d44 100644 --- a/package.json +++ b/package.json @@ -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": {