forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Add static method ReadableStream.from(any asyncIterable)
- Loading branch information
1 parent
3da05f4
commit 337fc95
Showing
5 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
Tests/LibWeb/Text/expected/Streams/ReadableStream-from-asyncIterator.txt
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,5 @@ | ||
Well | ||
Hello | ||
Friends | ||
! | ||
🦬 |
30 changes: 30 additions & 0 deletions
30
Tests/LibWeb/Text/input/Streams/ReadableStream-from-asyncIterator.html
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,30 @@ | ||
<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> |
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