(options?: {
readonly ignoreEmptyLines?: boolean | undefined
})
| 271 | * @since 4.0.0 |
| 272 | */ |
| 273 | export const decodeString = <IE = never, Done = unknown>(options?: { |
| 274 | readonly ignoreEmptyLines?: boolean | undefined |
| 275 | }): Channel.Channel< |
| 276 | Arr.NonEmptyReadonlyArray<unknown>, |
| 277 | IE | NdjsonError, |
| 278 | Done, |
| 279 | Arr.NonEmptyReadonlyArray<string>, |
| 280 | IE, |
| 281 | Done |
| 282 | > => |
| 283 | Channel.fromTransform((upstream, scope) => { |
| 284 | const ignoreEmptyLines = options?.ignoreEmptyLines === true |
| 285 | // splitLines only emits a line after its input has ended when that line |
| 286 | // has no terminator |
| 287 | let ended = false |
| 288 | const input = Pull.matchEffect(upstream, { |
| 289 | onSuccess: Effect.succeed, |
| 290 | onFailure: Effect.failCause, |
| 291 | onDone: (leftover) => { |
| 292 | ended = true |
| 293 | return Cause.done(leftover) |
| 294 | } |
| 295 | }) |
| 296 | return Effect.map( |
| 297 | Channel.toTransform(Channel.splitLines<IE, Done>())(input, scope), |
| 298 | (lines) => |
| 299 | makeDecodePull(lines, (chunk, out) => { |
| 300 | for (const line of chunk) { |
| 301 | const error = parseLine(line, out, ignoreEmptyLines, ended) |
| 302 | if (error !== undefined) return error |
| 303 | } |
| 304 | }, flushNothing) |
| 305 | ) |
| 306 | }) |
| 307 | |
| 308 | const LF = 0x0a |
| 309 | const CR = 0x0d |
no test coverage detected