mirror of
https://github.com/swc-project/swc.git
synced 2024-12-22 21:21:31 +03:00
7730a6ea5a
swc_ecma_transforms_compat: - `async_to_generator`: Handle await in async generators correctly. (#1752) swc_ecma_transforms_module: - Don't panic on double import from one module. (#1757)
20 lines
440 B
JavaScript
20 lines
440 B
JavaScript
async function* generate() {
|
|
const results = await Promise.all([
|
|
Promise.resolve(1),
|
|
Promise.resolve(2),
|
|
Promise.resolve(3),
|
|
])
|
|
for (const result of results) {
|
|
console.log(`yield ${result}`)
|
|
yield result
|
|
}
|
|
}
|
|
|
|
async function printValues() {
|
|
const iterator = generate()
|
|
for await (const value of iterator) {
|
|
console.log(`iterator value: ${value}`)
|
|
}
|
|
}
|
|
|
|
printValues() |