mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
Fix everything
This commit is contained in:
Vendored
+20
-3
@@ -13,11 +13,28 @@ declare namespace TextEncoding {
|
||||
(utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
|
||||
new (utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
|
||||
}
|
||||
export const TextEncoder: TextEncoder;
|
||||
export const TextDecoder: TextDecoder;
|
||||
|
||||
export var TextEncoder: {
|
||||
new (utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
|
||||
(utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
|
||||
encoding: string;
|
||||
};
|
||||
|
||||
export var TextDecoder: {
|
||||
(label?: string, options?: TextDecoderOptions): TextDecoder;
|
||||
new (label?: string, options?: TextDecoderOptions): TextDecoder;
|
||||
encoding: string;
|
||||
};
|
||||
}
|
||||
|
||||
declare var TextEncoding: TextEncoding.TextEncodingStatic;
|
||||
interface TextEncodeOptions {
|
||||
stream?: boolean;
|
||||
}
|
||||
|
||||
interface TextEncoder {
|
||||
readonly encoding: string;
|
||||
encode(input?: string, options?: TextEncodeOptions): Uint8Array;
|
||||
}
|
||||
|
||||
declare module "text-encoding" {
|
||||
export = TextEncoding;
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
|
||||
import { TextEncoder, TextDecoder } from "text-encoding";
|
||||
|
||||
function test_encoder() {
|
||||
var text = "plain text";
|
||||
var uint8array: Uint8Array;
|
||||
var uint8array = new Uint8Array([]);
|
||||
|
||||
// constructor
|
||||
uint8array = new TextEncoder().encode(text);
|
||||
uint8array = new TextEncoder('utf-8').encode(text);
|
||||
uint8array = new TextEncoder('windows-1252', { NONSTANDARD_allowLegacyEncoding: true }).encode(text);
|
||||
uint8array = new TextEncoder("utf-8").encode(text);
|
||||
uint8array = new TextEncoder("windows-1252", {
|
||||
NONSTANDARD_allowLegacyEncoding: true
|
||||
}).encode(text);
|
||||
|
||||
uint8array = TextEncoder().encode(text);
|
||||
uint8array = TextEncoder('utf-8').encode(text);
|
||||
uint8array = TextEncoder('windows-1252', { NONSTANDARD_allowLegacyEncoding: true }).encode(text);
|
||||
uint8array = TextEncoder("utf-8").encode(text);
|
||||
uint8array = TextEncoder("windows-1252", {
|
||||
NONSTANDARD_allowLegacyEncoding: true
|
||||
}).encode(text);
|
||||
|
||||
// attributes
|
||||
var encoder = new TextEncoder();
|
||||
encoder.encoding = 'utf-8';
|
||||
var encoding: string = encoder.encoding;
|
||||
|
||||
// methods
|
||||
@@ -27,31 +30,30 @@ function test_encoder() {
|
||||
function test_decoder() {
|
||||
var text = "plain text";
|
||||
var uint8array: Uint8Array = TextEncoder().encode(text);
|
||||
var arrayBuffer: ArrayBuffer = uint8array.buffer
|
||||
var arrayBuffer: ArrayBuffer = uint8array.buffer;
|
||||
|
||||
// constructor
|
||||
text = new TextDecoder().decode(uint8array);
|
||||
text = new TextDecoder('utf-8').decode(uint8array);
|
||||
text = new TextDecoder('windows-1252', {}).decode(uint8array);
|
||||
text = new TextDecoder('windows-1252', { fatal: true }).decode(uint8array);
|
||||
text = new TextDecoder('windows-1252', { ignoreBOM: true }).decode(uint8array);
|
||||
text = new TextDecoder("utf-8").decode(uint8array);
|
||||
text = new TextDecoder("windows-1252", {}).decode(uint8array);
|
||||
text = new TextDecoder("windows-1252", { fatal: true }).decode(uint8array);
|
||||
text = new TextDecoder("windows-1252", { ignoreBOM: true }).decode(
|
||||
uint8array
|
||||
);
|
||||
|
||||
text = TextDecoder().decode(uint8array);
|
||||
text = TextDecoder('utf-8').decode(uint8array);
|
||||
text = TextDecoder('windows-1252', {}).decode(uint8array);
|
||||
text = TextDecoder('windows-1252', { fatal: true }).decode(uint8array);
|
||||
text = TextDecoder('windows-1252', { ignoreBOM: true }).decode(uint8array);
|
||||
text = TextDecoder("utf-8").decode(uint8array);
|
||||
text = TextDecoder("windows-1252", {}).decode(uint8array);
|
||||
text = TextDecoder("windows-1252", { fatal: true }).decode(uint8array);
|
||||
text = TextDecoder("windows-1252", { ignoreBOM: true }).decode(uint8array);
|
||||
|
||||
// attributes
|
||||
var decoder = new TextDecoder();
|
||||
|
||||
decoder.encoding = 'utf-8';
|
||||
var encoding: string = decoder.encoding;
|
||||
|
||||
decoder.fatal = true;
|
||||
var fatal: boolean = decoder.fatal;
|
||||
|
||||
decoder.ignoreBOM = true;
|
||||
var ignoreBOM: boolean = decoder.ignoreBOM;
|
||||
|
||||
// methods
|
||||
|
||||
Reference in New Issue
Block a user