MCPcopy
hub / github.com/nestjs/nest / toDataString

Function toDataString

packages/core/router/sse-stream.ts:6–15  ·  view source on GitHub ↗
(data: string | object)

Source from the content-addressed store, hash-verified

4import { Transform } from 'stream';
5
6function toDataString(data: string | object): string {
7 if (isObject(data)) {
8 return toDataString(JSON.stringify(data));
9 }
10
11 return data
12 .split(/\r\n|\r|\n/)
13 .map(line => `data: ${line}\n`)
14 .join('');
15}
16
17export type AdditionalHeaders = Record<
18 string,

Callers 1

_transformMethod · 0.85

Calls 1

isObjectFunction · 0.90

Tested by

no test coverage detected