|
1 | 1 | /* codepage.js (C) 2013-present SheetJS -- http://sheetjs.com */ |
2 | 2 | // TypeScript Version: 2.2 |
3 | 3 |
|
4 | | -/** Codepage index type (integer or string representation) */ |
5 | | -export type CP$Index = number | string; |
| 4 | +declare namespace cptable { |
| 5 | + /** Codepage index type (integer or string representation) */ |
| 6 | + export type CP$Index = number | string; |
| 7 | + |
| 8 | + /* Individual codepage converter */ |
| 9 | + export interface CP$Conv { |
| 10 | + enc: {[n: string]: number; }; |
| 11 | + dec: {[n: number]: string; }; |
| 12 | + } |
| 13 | + |
| 14 | + /** Encode input type (string, array of characters, Buffer) */ |
| 15 | + export type CP$String = string | string[] | Uint8Array; |
| 16 | + |
| 17 | + /** Encode output / decode input type */ |
| 18 | + export type CP$Data = string | number[] | Uint8Array; |
| 19 | + |
| 20 | + /** General utilities */ |
| 21 | + export interface CP$Utils { |
| 22 | + decode(cp: CP$Index, data: CP$Data): string; |
| 23 | + encode(cp: CP$Index, data: CP$String, opts?: any): CP$Data; |
| 24 | + hascp(n: number): boolean; |
| 25 | + magic: {[cp: string]: string}; |
| 26 | + } |
6 | 27 |
|
7 | | -/* Individual codepage converter */ |
8 | | -export interface CP$Conv { |
9 | | - enc: {[n: string]: number; }; |
10 | | - dec: {[n: number]: string; }; |
11 | 28 | } |
12 | 29 |
|
13 | | -/** Encode input type (string, array of characters, Buffer) */ |
14 | | -export type CP$String = string | string[] | Uint8Array; |
15 | | - |
16 | | -/** Encode output / decode input type */ |
17 | | -export type CP$Data = string | number[] | Uint8Array; |
18 | | - |
19 | | -/** General utilities */ |
20 | | -export interface CP$Utils { |
21 | | - decode(cp: CP$Index, data: CP$Data): string; |
22 | | - encode(cp: CP$Index, data: CP$String, opts?: any): CP$Data; |
23 | | - hascp(n: number): boolean; |
24 | | - magic: {[cp: string]: string}; |
25 | | -} |
26 | | - |
27 | | -/* note: TS cannot export top-level indexer, hence default workaround */ |
28 | | -export interface CP$Module { |
| 30 | +interface CP$Module { |
29 | 31 | /** Version string */ |
30 | 32 | version: string; |
31 | 33 |
|
32 | 34 | /** Utility Functions */ |
33 | | - utils: CP$Utils; |
| 35 | + utils: cptable.CP$Utils; |
34 | 36 |
|
35 | 37 | /** Codepage Converters */ |
36 | | - [cp: number]: CP$Conv; |
| 38 | + [cp: number]: cptable.CP$Conv; |
37 | 39 | } |
38 | | -export const cptable: CP$Module; |
39 | | -export default cptable; |
| 40 | + |
| 41 | +declare const cptable:CP$Module; |
| 42 | + |
| 43 | +export = cptable; |
0 commit comments