mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
Improve new TextDecoder().toString() (#2032)
This commit is contained in:
parent
ada5ffa610
commit
659acadf77
2 changed files with 14 additions and 0 deletions
|
@ -442,6 +442,9 @@ export class TextDecoder {
|
|||
|
||||
return codePointsToString(output);
|
||||
}
|
||||
get [Symbol.toStringTag]() {
|
||||
return "TextDecoder";
|
||||
}
|
||||
}
|
||||
|
||||
export class TextEncoder {
|
||||
|
@ -467,4 +470,7 @@ export class TextEncoder {
|
|||
|
||||
return new Uint8Array(output);
|
||||
}
|
||||
get [Symbol.toStringTag]() {
|
||||
return "TextEncoder";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,3 +91,11 @@ test(function textDecoderSharedInt32Array() {
|
|||
const actual = decoder.decode(i32);
|
||||
assertEquals(actual, "ABCDEFGH");
|
||||
});
|
||||
|
||||
test(function toStringShouldBeWebCompatibility() {
|
||||
const encoder = new TextEncoder();
|
||||
assertEquals(encoder.toString(), "[object TextEncoder]");
|
||||
|
||||
const decoder = new TextDecoder();
|
||||
assertEquals(decoder.toString(), "[object TextDecoder]");
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue