File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ export type Item = {
35
35
text : string ;
36
36
} ;
37
37
38
+ export type RuleAccumulator = ( item : Item ) => boolean | void ;
39
+ export type RuleHandler < T = any > = ( value : T ) => void ;
40
+
41
+ export interface TableResult {
42
+ matrix : string [ ] [ ] ;
43
+ items : Item [ ] ;
44
+ }
45
+
38
46
export class TableParser {
39
47
private rows : { [ key : string ] : Item [ ] } ;
40
48
constructor ( ) ;
@@ -47,3 +55,27 @@ export class TableParser {
47
55
getCleanMatrix ( options ?: { collisionSeparator : string } ) : string [ ] [ ] ;
48
56
renderMatrix ( ) : string ;
49
57
}
58
+
59
+ export class Rule {
60
+ static on ( regexp : RegExp ) : Rule ;
61
+ static after ( regexp : RegExp ) : Rule ;
62
+ static makeItemProcessor ( rules : Rule [ ] ) : ( item : DataEntry ) => void ;
63
+ static addAccumulator ( methodName : string , methodBuilder : Function ) : void ;
64
+
65
+ constructor ( regexp : RegExp ) ;
66
+
67
+ // Accumulator methods
68
+ extractRegexpValues ( ) : Rule ;
69
+ parseNextItemValue ( ) : Rule ;
70
+ accumulateAfterHeading ( ) : Rule ;
71
+ accumulateFromSameX ( ) : Rule ;
72
+ parseColumns ( ...args : any [ ] ) : Rule ;
73
+ parseTable ( columnCount : number ) : Rule & {
74
+ then ( handler : ( result : TableResult ) => void ) : Rule ;
75
+ } ;
76
+
77
+ then < T > ( handler : RuleHandler < T > ) : Rule ;
78
+
79
+ private test ( item : Item ) : RuleAccumulator | undefined ;
80
+ private whenDone ( callback : ( ) => void ) : void ;
81
+ }
You can’t perform that action at this time.
0 commit comments