summaryrefslogtreecommitdiff
path: root/text-encoding.d.ts
blob: 014c95effe538bc016c822e61fed06735518a7f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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 {
  interface TextDecoderOptions {
    fatal?: boolean;
    ignoreBOM?: boolean;
  }

  interface TextDecodeOptions {
    stream?: boolean;
  }

  interface TextEncoderOptions {
    NONSTANDARD_allowLegacyEncoding?: boolean;
  }

  interface TextDecoder {
    encoding: string;
    fatal: boolean;
    ignoreBOM: boolean;
    decode(
      input?: ArrayBuffer | ArrayBufferView,
      options?: TextDecodeOptions
    ): string;
  }

  interface TextEncoder {
    encoding: string;
    encode(input?: string, options?: TextEncodeOptions): Uint8Array;
  }

  interface TextEncodeOptions {
    stream?: boolean;
  }

  interface TextEncoderStatic {
    (utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
    new (utfLabel?: string, options?: TextEncoderOptions): TextEncoder;
  }

  interface TextDecoderStatic {
    (label?: string, options?: TextDecoderOptions): TextDecoder;
    new (label?: string, options?: TextDecoderOptions): TextDecoder;
  }

  interface TextEncodingStatic {
    TextEncoder: TextEncoderStatic;
    TextDecoder: TextDecoderStatic;
  }
}

/* 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'.

  52 declare var TextDecoder: TextEncoding.TextDecoderStatic;
 */
// declare var TextDecoder: TextEncoding.TextDecoderStatic;
// declare var TextEncoder: TextEncoding.TextEncoderStatic;
declare var TextEncoding: TextEncoding.TextEncodingStatic;

declare module "text-encoding" {
  export = TextEncoding;
}