@@ -8,6 +8,7 @@ export type TIngridParse = (input: string) => TIngridResponse
88
99const EOL = / \r ? \n | \r | \n /
1010const EMPTY = '-'
11+ const LL = 80
1112
1213type TLineDigest = {
1314 spaces : number [ ] ,
@@ -127,18 +128,20 @@ const gridToData = (grid: string[][][]): TIngridResponse => {
127128 return data
128129}
129130
131+ const roundUp = ( l : number ) => Math . ceil ( l / LL ) * LL
132+
130133// eslint-disable-next-line sonarjs/cognitive-complexity
131134export const parseWinGrid = ( input : string ) : TIngridResponse => {
132135 const _lines = input . split ( / \r ? \n / )
133136 const lines = _lines . filter ( Boolean )
134137 const headline = lines . shift ( ) !
135138 const headers = headline . split ( / \s + / )
136- const ll = lines [ 0 ] . length
137139 const hl = headers . length
140+ const limit = roundUp ( lines [ 0 ] . length )
138141
139- if ( lines . every ( l => l . length === ll ) ) {
142+ if ( lines . every ( l => roundUp ( l . length ) === limit ) ) {
140143 const spaces = Array
141- . from ( { length : ll } )
144+ . from ( { length : limit } )
142145 . map ( ( _ , i ) =>
143146 lines . every ( l => l [ i ] === ' ' )
144147 )
@@ -154,7 +157,7 @@ export const parseWinGrid = (input: string): TIngridResponse => {
154157 for ( const i in headers ) {
155158 const k = headers [ i ]
156159 const s = borders [ i ]
157- const e = borders [ + i + 1 ] || ll
160+ const e = borders [ + i + 1 ] || limit
158161 const v = line . slice ( s , e ) . trim ( )
159162 props . push ( [ k , [ v || EMPTY ] ] )
160163 }
0 commit comments