mirror of
https://github.com/denoland/deno.git
synced 2025-10-02 15:14:33 +00:00
refactor(web): use encoding_rs for text encoding (#10844)
This commit removes all JS based text encoding / text decoding. Instead encoding now happens in Rust via encoding_rs (already in tree). This implementation retains stream support, but adds the last missing encodings. We are incredibly close to 100% WPT on text encoding now. This should reduce our baseline heap by quite a bit.
This commit is contained in:
parent
bb0c90cadb
commit
c73ef5fa14
27 changed files with 641 additions and 4705 deletions
30
extensions/web/lib.deno_web.d.ts
vendored
30
extensions/web/lib.deno_web.d.ts
vendored
|
@ -177,20 +177,32 @@ declare function atob(s: string): string;
|
|||
*/
|
||||
declare function btoa(s: string): string;
|
||||
|
||||
declare interface TextDecoderOptions {
|
||||
fatal?: boolean;
|
||||
ignoreBOM?: boolean;
|
||||
}
|
||||
|
||||
declare interface TextDecodeOptions {
|
||||
stream?: boolean;
|
||||
}
|
||||
|
||||
declare class TextDecoder {
|
||||
constructor(label?: string, options?: TextDecoderOptions);
|
||||
|
||||
/** Returns encoding's name, lowercased. */
|
||||
readonly encoding: string;
|
||||
/** Returns `true` if error mode is "fatal", and `false` otherwise. */
|
||||
readonly fatal: boolean;
|
||||
/** Returns `true` if ignore BOM flag is set, and `false` otherwise. */
|
||||
readonly ignoreBOM = false;
|
||||
constructor(
|
||||
label?: string,
|
||||
options?: { fatal?: boolean; ignoreBOM?: boolean },
|
||||
);
|
||||
/** Returns the result of running encoding's decoder. */
|
||||
decode(input?: BufferSource, options?: { stream?: boolean }): string;
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
|
||||
decode(input?: BufferSource, options?: TextDecodeOptions): string;
|
||||
}
|
||||
|
||||
declare interface TextEncoderEncodeIntoResult {
|
||||
read: number;
|
||||
written: number;
|
||||
}
|
||||
|
||||
declare class TextEncoder {
|
||||
|
@ -198,11 +210,7 @@ declare class TextEncoder {
|
|||
readonly encoding = "utf-8";
|
||||
/** Returns the result of running UTF-8's encoder. */
|
||||
encode(input?: string): Uint8Array;
|
||||
encodeInto(
|
||||
input: string,
|
||||
dest: Uint8Array,
|
||||
): { read: number; written: number };
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
encodeInto(input: string, dest: Uint8Array): TextEncoderEncodeIntoResult;
|
||||
}
|
||||
|
||||
/** A controller object that allows you to abort one or more DOM requests as and
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue