@@ -8,7 +8,6 @@ export type TIngridParse = (input: string) => TIngridResponse
88
99const EOL = / \r ? \n | \r | \n /
1010const EMPTY = '-'
11- const LL = 80
1211
1312type TLineDigest = {
1413 spaces : number [ ] ,
@@ -128,20 +127,18 @@ const gridToData = (grid: string[][][]): TIngridResponse => {
128127 return data
129128}
130129
131- const roundUp = ( l : number ) => Math . ceil ( l / LL ) * LL
132-
133130// eslint-disable-next-line sonarjs/cognitive-complexity
134131export const parseWinGrid = ( input : string ) : TIngridResponse => {
135132 const _lines = input . split ( / \r ? \n / )
136133 const lines = _lines . filter ( Boolean )
137134 const headline = lines . shift ( ) !
138135 const headers = headline . split ( / \s + / )
139136 const hl = headers . length
140- const limit = roundUp ( lines [ 0 ] . length )
137+ const ll = headline . length
141138
142- if ( lines . every ( l => roundUp ( l . length ) === limit ) ) {
139+ if ( lines . every ( l => ll / l . length < 2 ) ) {
143140 const spaces = Array
144- . from ( { length : limit } )
141+ . from ( { length : ll } )
145142 . map ( ( _ , i ) =>
146143 lines . every ( l => l [ i ] === ' ' )
147144 )
@@ -157,7 +154,7 @@ export const parseWinGrid = (input: string): TIngridResponse => {
157154 for ( const i in headers ) {
158155 const k = headers [ i ]
159156 const s = borders [ i ]
160- const e = borders [ + i + 1 ] || limit
157+ const e = borders [ + i + 1 ] || ll
161158 const v = line . slice ( s , e ) . trim ( )
162159 props . push ( [ k , [ v || EMPTY ] ] )
163160 }
0 commit comments