Skip to content
Permalink
Browse files
buffer: initialize TextDecoder once on blob.text()
PR-URL: #44787
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
anonrig authored and danielleadams committed Oct 11, 2022
1 parent 281fd7a commit 725be0ea50f2ab4988d65cbc0d6c0cbf1272b6b8
Showing 1 changed file with 3 additions and 1 deletion.
@@ -78,6 +78,7 @@ let ReadableStream;
let URL;

const enc = new TextEncoder();
let dec;

// Yes, lazy loading is annoying but because of circular
// references between the url, internal/blob, and buffer
@@ -311,7 +312,8 @@ class Blob {
if (!isBlob(this))
throw new ERR_INVALID_THIS('Blob');

const dec = new TextDecoder();
dec ??= new TextDecoder();

return dec.decode(await this.arrayBuffer());
}

0 comments on commit 725be0e

Please sign in to comment.