mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-27 19:59:17 +00:00
31 lines
704 B
HTML
31 lines
704 B
HTML
<script src="../include.js"></script>
|
|
<script>
|
|
async function* asyncGenerator() {
|
|
yield "Well";
|
|
yield "Hello";
|
|
yield "Friends";
|
|
yield "!";
|
|
yield "🦬";
|
|
}
|
|
|
|
async function readStream(stream) {
|
|
const reader = stream.getReader();
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done)
|
|
break;
|
|
println(value);
|
|
}
|
|
}
|
|
|
|
test(async () => {
|
|
const asyncIterable = {
|
|
[Symbol.asyncIterator]: asyncGenerator,
|
|
};
|
|
|
|
const readableStream = ReadableStream.from(asyncIterable);
|
|
|
|
await readStream(readableStream);
|
|
});
|
|
</script>
|