Skip to content

Commit 897e538

Browse files
Merge pull request #20823 from Snuffleupagus/Response-bytes-more
Use `Response.prototype.bytes()` more in the code-base (PR 20651 follow-up)
2 parents aaf9b3b + 0c514b0 commit 897e538

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

examples/image_decoders/jpeg_viewer.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const response = await fetch(JPEG_IMAGE);
2929
if (!response.ok) {
3030
throw new Error(response.statusText);
3131
}
32-
const typedArrayImage = new Uint8Array(await response.arrayBuffer());
32+
const typedArrayImage = await response.bytes();
3333

3434
// Parse the image data using `JpegImage`.
3535
//

src/core/writer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ async function writeStream(stream, buffer, transform) {
8585
.catch(() => {});
8686

8787
// Response::text doesn't return the correct data.
88-
const buf = await new Response(cs.readable).arrayBuffer();
89-
bytes = new Uint8Array(buf);
88+
bytes = await new Response(cs.readable).bytes();
9089

9190
let newFilter, newParams;
9291
if (!filter) {

src/display/editor/drawers/signaturedraw.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,9 +746,7 @@ class SignatureExtractor {
746746

747747
writer.close();
748748

749-
const buf = await new Response(cs.readable).arrayBuffer();
750-
const bytes = new Uint8Array(buf);
751-
749+
const bytes = await new Response(cs.readable).bytes();
752750
return bytes.toBase64();
753751
}
754752

0 commit comments

Comments
 (0)