summaryrefslogtreecommitdiff
path: root/ext/web/10_filereader.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/web/10_filereader.js')
-rw-r--r--ext/web/10_filereader.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/web/10_filereader.js b/ext/web/10_filereader.js
index 5dd2d5c3a..524a3fe51 100644
--- a/ext/web/10_filereader.js
+++ b/ext/web/10_filereader.js
@@ -27,14 +27,15 @@ const {
MapPrototypeGet,
MapPrototypeSet,
ObjectDefineProperty,
- ObjectPrototypeIsPrototypeOf,
queueMicrotask,
SafeArrayIterator,
Symbol,
TypedArrayPrototypeSet,
+ TypedArrayPrototypeGetBuffer,
+ TypedArrayPrototypeGetByteLength,
+ TypedArrayPrototypeGetSymbolToStringTag,
TypeError,
Uint8Array,
- Uint8ArrayPrototype,
} = primordials;
const state = Symbol("[[state]]");
@@ -119,7 +120,8 @@ class FileReader extends EventTarget {
// and whose value property is a Uint8Array object, run these steps:
if (
!chunk.done &&
- ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, chunk.value)
+ TypedArrayPrototypeGetSymbolToStringTag(chunk.value) ===
+ "Uint8Array"
) {
ArrayPrototypePush(chunks, chunk.value);
@@ -127,7 +129,7 @@ class FileReader extends EventTarget {
{
const size = ArrayPrototypeReduce(
chunks,
- (p, i) => p + i.byteLength,
+ (p, i) => p + TypedArrayPrototypeGetByteLength(i),
0,
);
const ev = new ProgressEvent("progress", {
@@ -151,7 +153,7 @@ class FileReader extends EventTarget {
// 2. Let result be the result of package data given bytes, type, blob's type, and encodingName.
const size = ArrayPrototypeReduce(
chunks,
- (p, i) => p + i.byteLength,
+ (p, i) => p + TypedArrayPrototypeGetByteLength(i),
0,
);
const bytes = new Uint8Array(size);
@@ -159,11 +161,11 @@ class FileReader extends EventTarget {
for (let i = 0; i < chunks.length; ++i) {
const chunk = chunks[i];
TypedArrayPrototypeSet(bytes, chunk, offs);
- offs += chunk.byteLength;
+ offs += TypedArrayPrototypeGetByteLength(chunk);
}
switch (readtype.kind) {
case "ArrayBuffer": {
- this[result] = bytes.buffer;
+ this[result] = TypedArrayPrototypeGetBuffer(bytes);
break;
}
case "BinaryString":