diff options
Diffstat (limited to 'extensions/file')
-rw-r--r-- | extensions/file/01_file.js | 8 | ||||
-rw-r--r-- | extensions/file/02_filereader.js | 6 |
2 files changed, 6 insertions, 8 deletions
diff --git a/extensions/file/01_file.js b/extensions/file/01_file.js index c34561b5e..c9c66127f 100644 --- a/extensions/file/01_file.js +++ b/extensions/file/01_file.js @@ -12,6 +12,7 @@ "use strict"; ((window) => { + const core = window.Deno.core; const webidl = window.__bootstrap.webidl; // TODO(lucacasonato): this needs to not be hardcoded and instead depend on @@ -85,9 +86,6 @@ return finalBytes; } - const utf8Encoder = new TextEncoder(); - const utf8Decoder = new TextDecoder(); - /** @typedef {BufferSource | Blob | string} BlobPart */ /** @@ -116,7 +114,7 @@ if (endings == "native") { s = convertLineEndingsToNative(s); } - bytesArrays.push(utf8Encoder.encode(s)); + bytesArrays.push(core.encode(s)); } else { throw new TypeError("Unreachable code (invalild element type)"); } @@ -276,7 +274,7 @@ async text() { webidl.assertBranded(this, Blob); const buffer = await this.arrayBuffer(); - return utf8Decoder.decode(buffer); + return core.decode(new Uint8Array(buffer)); } /** diff --git a/extensions/file/02_filereader.js b/extensions/file/02_filereader.js index 428d8fd54..c7ca3d980 100644 --- a/extensions/file/02_filereader.js +++ b/extensions/file/02_filereader.js @@ -14,9 +14,9 @@ ((window) => { const webidl = window.__bootstrap.webidl; - const { decode } = window.__bootstrap.encoding; + const { forgivingBase64Encode } = window.__bootstrap.infra; + const { decode, TextDecoder } = window.__bootstrap.encoding; const { parseMimeType } = window.__bootstrap.mimesniff; - const base64 = window.__bootstrap.base64; const state = Symbol("[[state]]"); const result = Symbol("[[result]]"); @@ -168,7 +168,7 @@ case "DataUrl": { const mediaType = blob.type || "application/octet-stream"; this[result] = `data:${mediaType};base64,${ - base64.fromByteArray(bytes) + forgivingBase64Encode(bytes) }`; break; } |