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, 6 insertions, 2 deletions
diff --git a/op_crates/web/08_text_encoding.js b/op_crates/web/08_text_encoding.js
index bf2e20049..e938eecd1 100644
--- a/op_crates/web/08_text_encoding.js
+++ b/op_crates/web/08_text_encoding.js
@@ -395,7 +395,8 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isEitherArrayBuffer(x) {
- return x instanceof SharedArrayBuffer || x instanceof ArrayBuffer;
+ return x instanceof SharedArrayBuffer || x instanceof ArrayBuffer ||
+ typeof x === "undefined";
}
class TextDecoder {
@@ -442,6 +443,7 @@
bytes = new Uint8Array(input);
} else if (
typeof input === "object" &&
+ input !== null &&
"buffer" in input &&
isEitherArrayBuffer(input.buffer)
) {
@@ -451,7 +453,9 @@
input.byteLength,
);
} else {
- bytes = new Uint8Array(0);
+ throw new TypeError(
+ "Provided input is not of type ArrayBuffer or ArrayBufferView",
+ );
}
// For simple utf-8 decoding "Deno.core.decode" can be used for performance