-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/compat): Fix async generator (#8881)
**Related issue:** - Closes #8805
- Loading branch information
Showing
5 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
crates/swc_ecma_transforms_compat/tests/async-to-generator/issue-8805/1/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
async function* foo() { | ||
yield 1 | ||
} | ||
|
||
async function* bar(inputs, returnValues) { | ||
for await (const input of inputs) { | ||
if (!returnValues) { | ||
return | ||
} | ||
yield input | ||
} | ||
} | ||
|
||
async function run() { | ||
for await (const number of bar(foo(), true)) { | ||
console.log(number) | ||
} | ||
} | ||
|
||
run() |
20 changes: 20 additions & 0 deletions
20
crates/swc_ecma_transforms_compat/tests/async-to-generator/issue-8805/2/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
async function* foo() { | ||
yield 1 | ||
} | ||
|
||
async function* bar(inputs, returnValues) { | ||
for await (const input of inputs) { | ||
if (!returnValues) { | ||
return | ||
} | ||
yield input | ||
} | ||
} | ||
|
||
async function run() { | ||
for await (const value of bar(foo(), false)) { | ||
console.log(value) | ||
} | ||
} | ||
|
||
run() |