MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / streamToLines

Function streamToLines

packages/db/src/buffers/event-buffer.test.ts:16–22  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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. */
16async 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
24const redis = getRedisCache();
25

Callers 1

Calls 2

pushMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected