|
| 1 | +// Adapted from file://./node_modules/typescript/lib/lib.dom.d.ts so we don't have to include the entire DOM lib |
| 2 | +// Ref: https://github.com/microsoft/TypeScript/issues/31535, https://github.com/microsoft/TypeScript/issues/41727, https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1685 |
| 3 | + |
| 4 | +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */ |
| 5 | +declare function atob(data: string): string; |
| 6 | +/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */ |
| 7 | +declare function btoa(data: string): string; |
| 8 | + |
| 9 | +type AllowSharedBufferSource = |
| 10 | + | ArrayBufferLike |
| 11 | + | ArrayBufferView<ArrayBufferLike>; |
| 12 | + |
| 13 | +interface TextDecodeOptions { |
| 14 | + stream?: boolean; |
| 15 | +} |
| 16 | + |
| 17 | +interface TextDecoderOptions { |
| 18 | + fatal?: boolean; |
| 19 | + ignoreBOM?: boolean; |
| 20 | +} |
| 21 | + |
| 22 | +/** |
| 23 | + * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc. |
| 24 | + * |
| 25 | + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder) |
| 26 | + */ |
| 27 | +interface TextDecoder extends TextDecoderCommon { |
| 28 | + /** |
| 29 | + * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter. |
| 30 | + * |
| 31 | + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode) |
| 32 | + */ |
| 33 | + decode(input?: AllowSharedBufferSource, options?: TextDecodeOptions): string; |
| 34 | +} |
| 35 | + |
| 36 | +// eslint-disable-next-line no-var |
| 37 | +declare var TextDecoder: { |
| 38 | + prototype: TextDecoder; |
| 39 | + new (label?: string, options?: TextDecoderOptions): TextDecoder; |
| 40 | +}; |
| 41 | + |
| 42 | +interface TextDecoderCommon { |
| 43 | + /** |
| 44 | + * Returns encoding's name, lowercased. |
| 45 | + * |
| 46 | + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/encoding) |
| 47 | + */ |
| 48 | + readonly encoding: string; |
| 49 | + /** |
| 50 | + * Returns true if error mode is "fatal", otherwise false. |
| 51 | + * |
| 52 | + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/fatal) |
| 53 | + */ |
| 54 | + readonly fatal: boolean; |
| 55 | + /** |
| 56 | + * Returns the value of ignore BOM. |
| 57 | + * |
| 58 | + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/ignoreBOM) |
| 59 | + */ |
| 60 | + readonly ignoreBOM: boolean; |
| 61 | +} |
0 commit comments