File tree 2 files changed +79
-1
lines changed
2 files changed +79
-1
lines changed Original file line number Diff line number Diff line change
1
+ type HorizontalTableRow = string [ ] ;
2
+ type VerticalTableRow = Record < string , string > ;
3
+ type CrossTableRow = Record < string , string [ ] > ;
4
+ type TableRow = HorizontalTableRow | VerticalTableRow | CrossTableRow ;
5
+
6
+ interface TableOptions < T extends TableRow = TableRow > {
7
+ rows ?: T [ ] ;
8
+ chars ?: {
9
+ [ k in
10
+ | 'top'
11
+ | 'top-mid'
12
+ | 'top-left'
13
+ | 'top-right'
14
+ | 'bottom'
15
+ | 'bottom-mid'
16
+ | 'bottom-left'
17
+ | 'bottom-right'
18
+ | 'left'
19
+ | 'left-mid'
20
+ | 'mid'
21
+ | 'mid-mid'
22
+ | 'right'
23
+ | 'right-mid'
24
+ | 'middle' ] ?: string ;
25
+ } ;
26
+ truncate ?: string ;
27
+ colors ?: boolean ;
28
+ colWidths ?: number [ ] ;
29
+ colAligns ?: Array < 'left' | 'middle' | 'right' > ;
30
+ style ?: {
31
+ 'padding-left' ?: number ;
32
+ 'padding-right' ?: number ;
33
+ head ?: string [ ] ;
34
+ border ?: string [ ] ;
35
+ compact ?: boolean ;
36
+ } ;
37
+ head ?: string [ ] ;
38
+ }
39
+
40
+ declare class Table < T extends TableRow = TableRow > extends Array < T > {
41
+ /**
42
+ * Table constructor
43
+ *
44
+ * @param options
45
+ * @api public
46
+ */
47
+ constructor ( options ?: T extends CrossTableRow ? never : TableOptions < T > ) ;
48
+ constructor ( options : T extends CrossTableRow ? TableOptions < T > & { head : [ '' , ...string [ ] ] } : never ) ;
49
+
50
+ /**
51
+ * Width getter
52
+ *
53
+ * @return width
54
+ * @api public
55
+ */
56
+ get width ( ) : number ;
57
+
58
+ /**
59
+ * Render to a string.
60
+ *
61
+ * @return table representation
62
+ * @api public
63
+ */
64
+ render ( ) : string ;
65
+
66
+ /**
67
+ * Render to a string.
68
+ *
69
+ * @return table representation
70
+ * @api public
71
+ */
72
+ toString ( ) : string ;
73
+
74
+ static readonly version : string ;
75
+ }
76
+
77
+ export = Table ;
Original file line number Diff line number Diff line change 17
17
"expresso" : " ~0.9" ,
18
18
"should" : " ~0.6"
19
19
},
20
- "main" : " lib" ,
20
+ "main" : " ./lib/index.js" ,
21
+ "types" : " ./lib/main.d.ts" ,
21
22
"files" : [" lib" ],
22
23
"scripts" : {
23
24
"test" : " make test"
You can’t perform that action at this time.
0 commit comments