mirror of
https://github.com/denoland/deno.git
synced 2025-01-10 16:11:13 -05:00
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".
This commit is contained in:
parent
29eca72fea
commit
c0b6e09172
1 changed files with 1 additions and 18 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue