mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
This reverts commit f8aff8edcd
.
This commit is contained in:
parent
6048ce5a34
commit
f50385b2a5
1 changed files with 20 additions and 72 deletions
92
op_crates/web/lib.deno_web.d.ts
vendored
92
op_crates/web/lib.deno_web.d.ts
vendored
|
@ -178,84 +178,32 @@ declare function atob(s: string): string;
|
||||||
*/
|
*/
|
||||||
declare function btoa(s: string): string;
|
declare function btoa(s: string): string;
|
||||||
|
|
||||||
/** A decoder for a specific method, that is a specific character encoding, like utf-8, iso-8859-2, koi8, cp1261, gbk, etc. A decoder takes a stream of bytes as input and emits a stream of code points. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. */
|
declare class TextDecoder {
|
||||||
interface TextDecoder extends TextDecoderCommon {
|
/** Returns encoding's name, lowercased. */
|
||||||
/**
|
|
||||||
* Returns the result of running encoding's decoder. The method can be invoked zero or more times with options's stream set to true, and then once without options's stream (or set to false), to process a fragmented input. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments.
|
|
||||||
*
|
|
||||||
* ```
|
|
||||||
* var string = "", decoder = new TextDecoder(encoding), buffer;
|
|
||||||
* while(buffer = next_chunk()) {
|
|
||||||
* string += decoder.decode(buffer, {stream:true});
|
|
||||||
* }
|
|
||||||
* string += decoder.decode(); // end-of-queue
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError.
|
|
||||||
*/
|
|
||||||
decode(input?: BufferSource, options?: TextDecodeOptions): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var TextDecoder: {
|
|
||||||
prototype: TextDecoder;
|
|
||||||
new (label?: string, options?: TextDecoderOptions): TextDecoder;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface TextDecoderCommon {
|
|
||||||
/**
|
|
||||||
* Returns encoding's name, lowercased.
|
|
||||||
*/
|
|
||||||
readonly encoding: string;
|
readonly encoding: string;
|
||||||
/**
|
/** Returns `true` if error mode is "fatal", and `false` otherwise. */
|
||||||
* Returns true if error mode is "fatal", otherwise false.
|
|
||||||
*/
|
|
||||||
readonly fatal: boolean;
|
readonly fatal: boolean;
|
||||||
/**
|
/** Returns `true` if ignore BOM flag is set, and `false` otherwise. */
|
||||||
* Returns the value of ignore BOM.
|
readonly ignoreBOM = false;
|
||||||
*/
|
constructor(
|
||||||
readonly ignoreBOM: boolean;
|
label?: string,
|
||||||
|
options?: { fatal?: boolean; ignoreBOM?: boolean },
|
||||||
|
);
|
||||||
|
/** Returns the result of running encoding's decoder. */
|
||||||
|
decode(input?: BufferSource, options?: { stream?: false }): string;
|
||||||
|
readonly [Symbol.toStringTag]: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TextDecodeOptions {
|
declare class TextEncoder {
|
||||||
// TODO(caspervonb) support streaming.
|
/** Returns "utf-8". */
|
||||||
stream?: false;
|
readonly encoding = "utf-8";
|
||||||
}
|
/** Returns the result of running UTF-8's encoder. */
|
||||||
|
|
||||||
interface TextDecoderOptions {
|
|
||||||
fatal?: boolean;
|
|
||||||
ignoreBOM?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TextEncoderEncodeIntoResult {
|
|
||||||
read?: number;
|
|
||||||
written?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. */
|
|
||||||
interface TextEncoder extends TextEncoderCommon {
|
|
||||||
/**
|
|
||||||
* Returns the result of running UTF-8's encoder.
|
|
||||||
*/
|
|
||||||
encode(input?: string): Uint8Array;
|
encode(input?: string): Uint8Array;
|
||||||
/**
|
|
||||||
* Runs the UTF-8 encoder on source, stores the result of that operation into destination, and returns the progress made as an object wherein read is the number of converted code units of source and written is the number of bytes modified in destination.
|
|
||||||
*/
|
|
||||||
encodeInto(
|
encodeInto(
|
||||||
source: string,
|
input: string,
|
||||||
destination: Uint8Array,
|
dest: Uint8Array,
|
||||||
): TextEncoderEncodeIntoResult;
|
): { read: number; written: number };
|
||||||
}
|
readonly [Symbol.toStringTag]: string;
|
||||||
|
|
||||||
declare var TextEncoder: {
|
|
||||||
prototype: TextEncoder;
|
|
||||||
new (): TextEncoder;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface TextEncoderCommon {
|
|
||||||
/**
|
|
||||||
* Returns "utf-8".
|
|
||||||
*/
|
|
||||||
readonly encoding: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A controller object that allows you to abort one or more DOM requests as and
|
/** A controller object that allows you to abort one or more DOM requests as and
|
||||||
|
|
Loading…
Reference in a new issue