File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ export type Item = {
3535 text : string ;
3636} ;
3737
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+
3846export class TableParser {
3947 private rows : { [ key : string ] : Item [ ] } ;
4048 constructor ( ) ;
@@ -47,3 +55,27 @@ export class TableParser {
4755 getCleanMatrix ( options ?: { collisionSeparator : string } ) : string [ ] [ ] ;
4856 renderMatrix ( ) : string ;
4957}
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