Drain an object-mode Readable into an array of line strings. event-buffer * yields each JSONEachRow row as its own string chunk; the @clickhouse/client * adds the trailing '\n' itself via encodeJSON. So in production each `\n` is * added by the client, but here we just collect chunks 1:1.
(stream: Readable)
| 14 | * adds the trailing '\n' itself via encodeJSON. So in production each `\n` is |
| 15 | * added by the client, but here we just collect chunks 1:1. */ |
| 16 | async function streamToLines(stream: Readable): Promise<string[]> { |
| 17 | const lines: string[] = []; |
| 18 | for await (const chunk of stream) { |
| 19 | lines.push(typeof chunk === 'string' ? chunk : chunk.toString('utf8')); |
| 20 | } |
| 21 | return lines; |
| 22 | } |
| 23 | |
| 24 | const redis = getRedisCache(); |
| 25 |
no test coverage detected