Skip to content

Commit 94e6fad

Browse files
committed
buffer: initialize TextDecoder once on blob for performance
1 parent dc4398c commit 94e6fad

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/internal/blob.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ let ReadableStream;
7878
let URL;
7979

8080
const enc = new TextEncoder();
81+
const dec = new TextDecoder();
8182

8283
// Yes, lazy loading is annoying but because of circular
8384
// references between the url, internal/blob, and buffer
@@ -310,8 +311,6 @@ class Blob {
310311
async text() {
311312
if (!isBlob(this))
312313
throw new ERR_INVALID_THIS('Blob');
313-
314-
const dec = new TextDecoder();
315314
return dec.decode(await this.arrayBuffer());
316315
}
317316

0 commit comments

Comments
 (0)