(options?: NdjsonOptions)
| 176 | * @category constructors |
| 177 | */ |
| 178 | export const unpackString = <IE = never, Done = unknown>(options?: NdjsonOptions): Channel.Channel< |
| 179 | Chunk.Chunk<unknown>, |
| 180 | Chunk.Chunk<string>, |
| 181 | IE | NdjsonError, |
| 182 | IE, |
| 183 | Done, |
| 184 | Done |
| 185 | > => { |
| 186 | const lines = Channel.splitLines<IE, Done>().pipe( |
| 187 | options?.ignoreEmptyLines === true ? |
| 188 | Channel.pipeTo(filterEmptyChannel()) : |
| 189 | identity |
| 190 | ) |
| 191 | return Channel.mapOutEffect(lines, (chunk) => |
| 192 | Effect.try({ |
| 193 | try: () => Chunk.map(chunk, (_) => JSON.parse(_)), |
| 194 | catch: (cause) => new NdjsonError({ reason: "Unpack", cause }) |
| 195 | })) |
| 196 | } |
| 197 | |
| 198 | const decodeString = <IE, Done>() => { |
| 199 | const decoder = new TextDecoder() |
no test coverage detected