swc/tests/fixture/issue-1918/case1/index.js
강동윤 72c9f4373a
fix(es): Fix bugs (#2055)
swc_ecma_parser:
 - Fix panic from span assertion. (#2040)

swc_ecma_transforms_compat:
 - Fix handling of `await for`. (#1918)

swc_ecma_transforms_base:
 - Allow using decorator metadata even if `reflect-metadata` is not imported. (#1362)
2021-08-12 12:28:58 +00:00

28 lines
582 B
JavaScript

let resolve;
let promise = new Promise((r) => (resolve = r));
let iterable = {
[Symbol.asyncIterator]() {
return {
next() {
return promise;
},
};
},
};
(async () => {
for await (let value of iterable) {
console.log(value);
}
})();
(async function () {
resolve({ value: 0, done: false });
promise = new Promise((r) => (resolve = r));
await null;
resolve({ value: 1, done: false });
promise = new Promise((r) => (resolve = r));
resolve({ value: undefined, done: true });
})();