diff options
author | Thiago de Arruda Padilha <thiago@padilha.cc> | 2021-04-11 08:47:06 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-11 20:47:06 +0900 |
commit | c0b6e09172f242e98a5bc82bd6f5dc20f705c8a2 (patch) | |
tree | e2d85887cbb25659e775b958266a127a3e2eef8b /op_crates/web/08_text_encoding.js | |
parent | 29eca72fea4f1e160a8d76d2ebda26e2c48b9658 (diff) |
refactor(op_crates/web): remove unused code path in TextEncoder (#10104)
According to
https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder,
TextEncoder should ignore the "encoding" parameter and always use
"utf-8".
Diffstat (limited to 'op_crates/web/08_text_encoding.js')
-rw-r--r-- | op_crates/web/08_text_encoding.js | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/op_crates/web/08_text_encoding.js b/op_crates/web/08_text_encoding.js index 1fda1a816..980de339c 100644 --- a/op_crates/web/08_text_encoding.js +++ b/op_crates/web/08_text_encoding.js @@ -4212,25 +4212,8 @@ class TextEncoder { encoding = "utf-8"; encode(input = "") { - input = String(input); // Deno.core.encode() provides very efficient utf-8 encoding - if (this.encoding === "utf-8") { - return core.encode(input); - } - - const encoder = new UTF8Encoder(); - const inputStream = new Stream(stringToCodePoints(input)); - const output = []; - - while (true) { - const result = encoder.handler(inputStream.read()); - if (result === "finished") { - break; - } - output.push(...result); - } - - return new Uint8Array(output); + return core.encode(String(input)); } encodeInto(input, dest) { if (!(dest instanceof Uint8Array)) { |