import * as cheerio from "cheerio" ; export abstract class BoxrecParseBoutsParseBouts { protected $ : CheerioStatic ; constructor ( boxrecBodyString ) { this . $ = cheerio . load ( boxrecBodyString ) ; } protected returnBouts ( ) { const bouts = [ ] ; this . $ ( "tbody tr" ) . each ( ( i , elem ) => { const boutId = this . $ ( elem ) . attr ( "id" ) ; if ( ! boutId || boutId . includes ( "second" ) ) { return ; } let isNextRowAssociated = false ; let nextRow = this . $ ( elem ) . next ( ) ; let nextRowId = nextRow . attr ( "id" ) ; if ( nextRowId ) { nextRowId = nextRowId . replace ( /[a-zA-Z]/g , "" ) ; isNextRowAssociated = nextRowId === boutId ; if ( ! isNextRowAssociated ) { nextRow = null ; } } const html = this . $ ( elem ) . html ( ) || "" ; const next = nextRow ? nextRow . html ( ) : null ; bouts . push ( [ html , next ] ) ; } ) ; return bouts ; } }