2018-05-27 14:13:33 -04:00
|
|
|
// Type definitions for text-encoding
|
|
|
|
// Project: https://github.com/inexorabletash/text-encoding
|
|
|
|
// Definitions by: MIZUNE Pine <https://github.com/pine613>
|
|
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
|
|
|
|
declare namespace TextEncoding {
|
2018-05-27 14:21:18 -04:00
|
|
|
interface TextDecoderOptions {
|
|
|
|
fatal?: boolean;
|
|
|
|
ignoreBOM?: boolean;
|
|
|
|
}
|
2018-05-27 14:13:33 -04:00
|
|
|
|
2018-05-27 14:21:18 -04:00
|
|
|
interface TextDecodeOptions {
|
|
|
|
stream?: boolean;
|
|
|
|
}
|
2018-05-27 14:13:33 -04:00
|
|
|
|
2018-05-27 14:21:18 -04:00
|
|
|
interface TextEncoderOptions {
|
|
|
|
NONSTANDARD_allowLegacyEncoding?: boolean;
|
|
|
|
}
|
2018-05-27 14:13:33 -04:00
|
|
|
|
2018-05-27 14:21:18 -04:00
|
|
|
interface TextDecoder {
|
|
|
|
encoding: string;
|
|
|
|
fatal: boolean;
|
|
|
|
ignoreBOM: boolean;
|
|
|
|
decode(
|
|
|
|
input?: ArrayBuffer | ArrayBufferView,
|
|
|
|
options?: TextDecodeOptions
|
|
|
|
): string;
|
|
|
|
}
|
2018-05-27 14:13:33 -04:00
|
|
|
|
2018-05-27 14:21:18 -04:00
|
|
|
interface TextEncoder {
|
|
|
|
encoding: string;
|
|
|
|
encode(input?: string, options?: TextEncodeOptions): Uint8Array;
|
|
|
|
}
|
2018-05-27 14:13:33 -04:00
|
|
|
|
2018-05-27 14:21:18 -04:00
|
|
|
interface TextEncodeOptions {
|
|
|
|
stream?: boolean;
|
|
|
|
}
|
2018-05-27 14:13:33 -04:00
|
|
|
|
2018-05-27 14:21:18 -04:00
|
|
|
interface TextEncoderStatic {
|
|
|
|
(utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
|
|
|
|
new (utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
|
|
|
|
}
|
2018-05-27 14:13:33 -04:00
|
|
|
|
2018-05-27 14:21:18 -04:00
|
|
|
interface TextDecoderStatic {
|
|
|
|
(label?: string, options?: TextDecoderOptions): TextDecoder;
|
|
|
|
new (label?: string, options?: TextDecoderOptions): TextDecoder;
|
|
|
|
}
|
2018-05-27 14:13:33 -04:00
|
|
|
|
2018-05-27 14:21:18 -04:00
|
|
|
interface TextEncodingStatic {
|
|
|
|
TextEncoder: TextEncoderStatic;
|
|
|
|
TextDecoder: TextDecoderStatic;
|
|
|
|
}
|
2018-05-27 14:13:33 -04:00
|
|
|
}
|
|
|
|
|
2018-05-27 14:15:22 -04:00
|
|
|
/* Removed following lines to workaround this bug:
|
|
|
|
text-encoding.d.ts:52:13 - error TS2403: Subsequent variable declarations
|
|
|
|
must have the same type. Variable 'TextDecoder' must be of type '{ new
|
|
|
|
(label?: string, options?: TextDecoderOptions): TextDecoder; prototype:
|
|
|
|
TextDecoder; }', but here has type 'TextDecoderStatic'.
|
2018-05-27 14:13:33 -04:00
|
|
|
|
2018-05-27 14:15:22 -04:00
|
|
|
52 declare var TextDecoder: TextEncoding.TextDecoderStatic;
|
|
|
|
*/
|
|
|
|
// declare var TextDecoder: TextEncoding.TextDecoderStatic;
|
|
|
|
// declare var TextEncoder: TextEncoding.TextEncoderStatic;
|
2018-05-27 14:13:33 -04:00
|
|
|
declare var TextEncoding: TextEncoding.TextEncodingStatic;
|
|
|
|
|
|
|
|
declare module "text-encoding" {
|
2018-05-27 14:21:18 -04:00
|
|
|
export = TextEncoding;
|
2018-05-27 14:13:33 -04:00
|
|
|
}
|