Created
April 8, 2023 00:12
-
-
Save danbri/7a50745e141b6c4a40e1581b4f5f5e1e to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>async generator tests</title> | |
</head> | |
<body onload="main()"> | |
<h1>async generator tests</h1> | |
<div id="output">hello world.</div> | |
<script> | |
async function* asyncGenerator() { | |
let i = 0; | |
while (i < 1000) { | |
yield i++; | |
} | |
} | |
const main = () => { | |
console.log("Everything loaded, let's go."); | |
const output = document.getElementById("output"); | |
(async () => { | |
for await (const num of asyncGenerator()) { | |
output.innerHTML += `count ${num} <br/>` | |
console.log(num); | |
} | |
})(); | |
console.log("Done."); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment