summaryrefslogtreecommitdiff
path: root/op_crates/web/08_text_encoding.js
diff options
context:
space:
mode:
Diffstat (limited to 'op_crates/web/08_text_encoding.js')
-rw-r--r--op_crates/web/08_text_encoding.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/op_crates/web/08_text_encoding.js b/op_crates/web/08_text_encoding.js
index 6a6b23f71..d1b14b98b 100644
--- a/op_crates/web/08_text_encoding.js
+++ b/op_crates/web/08_text_encoding.js
@@ -1134,14 +1134,16 @@
return new Uint8Array(output);
}
encodeInto(input, dest) {
- const encoder = new UTF8Encoder();
- const inputStream = new Stream(stringToCodePoints(input));
-
if (!(dest instanceof Uint8Array)) {
throw new TypeError(
"2nd argument to TextEncoder.encodeInto must be Uint8Array",
);
}
+ if (dest.byteLength === 0) {
+ return { read: 0, written: 0 };
+ }
+ const encoder = new UTF8Encoder();
+ const inputStream = new Stream(stringToCodePoints(input));
let written = 0;
let read = 0;