mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-17 17:38:10 +00:00
Better support for Uint8Array in ReadableStream
There's always going to be ambiguity between a string and a Uint8Array. We already had TypedArray(u8) as a discriminator when _returning_ values. But now the type is also used by mapping JS values to Zig. To support this efficiently when probing the union, the typed array mapping logic was extracted into its own function (so that it can be used by the probe).
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="../testing.js"></script>
|
||||
|
||||
<script id=readable_stream>
|
||||
@@ -17,6 +18,22 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<script id=readable_stream_binary>
|
||||
const input = new TextEncoder().encode('over 9000!');
|
||||
const binStream = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue(input);
|
||||
controller.enqueue("world");
|
||||
controller.close();
|
||||
}
|
||||
});
|
||||
|
||||
testing.async(binStream.getReader().read(), (data) => {
|
||||
testing.expectEqual(input, data.value);
|
||||
testing.expectEqual(false, data.done);
|
||||
});
|
||||
</script>
|
||||
|
||||
<script id=readable_stream_close>
|
||||
var closeResult;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user