Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02f13ab

Browse filesBrowse files
codebyteretargos
authored andcommitted
repl: support top-level for-await-of
PR-URL: #23841 Fixes: #23836 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent dcaf723 commit 02f13ab
Copy full SHA for 02f13ab

File tree

Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/repl/await.js‎

Copy file name to clipboardExpand all lines: lib/internal/repl/await.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const visitorsWithoutAncestors = {
1111
}
1212
walk.base.ClassDeclaration(node, state, c);
1313
},
14+
ForOfStatement(node, state, c) {
15+
if (node.await === true) {
16+
state.containsAwait = true;
17+
}
18+
walk.base.ForOfStatement(node, state, c);
19+
},
1420
FunctionDeclaration(node, state, c) {
1521
state.prepend(node, `${node.id.name}=`);
1622
},
Collapse file

‎test/parallel/test-repl-top-level-await.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-top-level-await.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ async function ordinaryTests() {
130130
[ 'let o = await 1, p', 'undefined' ],
131131
[ 'p', 'undefined' ],
132132
[ 'let q = 1, s = await 2', 'undefined' ],
133-
[ 's', '2' ]
133+
[ 's', '2' ],
134+
[ 'for await (let i of [1,2,3]) console.log(i)', 'undefined', { line: 3 } ]
134135
];
135136

136137
for (const [input, expected, options = {}] of testCases) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.