diff options
author | crowlKats <13135287+crowlKats@users.noreply.github.com> | 2020-08-17 23:46:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-17 17:46:08 -0400 |
commit | b44b7a9a603477d3d0f9fa6cdafe18d387a36d25 (patch) | |
tree | 09e32a99b695868629ad5708525ec74b44268ef2 | |
parent | 974215afdd70cf39bedf34940fc47d6a60a1625e (diff) |
Blob.arrayBuffer returns uint8array (#7086)
-rw-r--r-- | cli/rt/20_blob.js | 2 | ||||
-rw-r--r-- | cli/tests/unit/blob_test.ts | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/cli/rt/20_blob.js b/cli/rt/20_blob.js index 5b0ef349e..f7309dafb 100644 --- a/cli/rt/20_blob.js +++ b/cli/rt/20_blob.js @@ -151,7 +151,7 @@ bytes.set(chunk, offs); offs += chunk.byteLength; } - return bytes; + return bytes.buffer; } else { throw new TypeError("Invalid reader result."); } diff --git a/cli/tests/unit/blob_test.ts b/cli/tests/unit/blob_test.ts index 79e6f1f8f..494c2ac75 100644 --- a/cli/tests/unit/blob_test.ts +++ b/cli/tests/unit/blob_test.ts @@ -91,6 +91,12 @@ unitTest(async function blobStream(): Promise<void> { assertEquals(decode(bytes), "Hello World"); }); +unitTest(async function blobArrayBuffer(): Promise<void> { + const uint = new Uint8Array([102, 111, 111]); + const blob = new Blob([uint]); + assertEquals(await blob.arrayBuffer(), uint.buffer); +}); + unitTest(function blobConstructorNameIsBlob(): void { const blob = new Blob(); assertEquals(blob.constructor.name, "Blob"); |