summaryrefslogtreecommitdiff
path: root/extensions/web/lib.deno_web.d.ts
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2021-06-05 23:10:07 +0200
committerGitHub <noreply@github.com>2021-06-05 23:10:07 +0200
commitc73ef5fa143b473677d4cab069241ff018e0c971 (patch)
treef13f3ddb1741a81138240c36846e2a23fd562a02 /extensions/web/lib.deno_web.d.ts
parentbb0c90cadbb99784681a2acac1fd65ac7f802297 (diff)
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.
Diffstat (limited to 'extensions/web/lib.deno_web.d.ts')
-rw-r--r--extensions/web/lib.deno_web.d.ts30
1 files changed, 19 insertions, 11 deletions
diff --git a/extensions/web/lib.deno_web.d.ts b/extensions/web/lib.deno_web.d.ts
index 9ede84994..e91534567 100644
--- a/extensions/web/lib.deno_web.d.ts
+++ b/extensions/web/lib.deno_web.d.ts
@@ -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