(hasNewline = false)
| 155 | }; |
| 156 | |
| 157 | const finishLine = (hasNewline = false) => { |
| 158 | const totalLineBytes = lineBytes + (hasNewline ? 1 : 0); |
| 159 | if (dropping) { |
| 160 | stats.overlong += 1; |
| 161 | resetLine(); |
| 162 | return; |
| 163 | } |
| 164 | if (totalLineBytes > maxLineBytes) { |
| 165 | stats.overlong += 1; |
| 166 | resetLine(); |
| 167 | return; |
| 168 | } |
| 169 | if (lineBytes === 0) { |
| 170 | resetLine(); |
| 171 | return; |
| 172 | } |
| 173 | const trimmed = Buffer.concat(parts, lineBytes).toString('utf8').trim(); |
| 174 | resetLine(); |
| 175 | if (!trimmed) return; |
| 176 | try { |
| 177 | onRow(JSON.parse(trimmed)); |
| 178 | stats.parsed += 1; |
| 179 | } catch { |
| 180 | stats.corrupt += 1; |
| 181 | } |
| 182 | }; |
| 183 | |
| 184 | try { |
| 185 | fd = fs.openSync(filePath, 'r'); |
no test coverage detected