MCPcopy Create free account
hub / github.com/hey-api/hey-api / outputHeaderToPrefix

Function outputHeaderToPrefix

packages/shared/src/utils/header.ts:8–21  ·  view source on GitHub ↗
(ctx: {
  defaultValue: ReadonlyArray<string>;
  header: OutputHeader;
  project: IProject;
})

Source from the content-addressed store, hash-verified

6 * Converts an {@link OutputHeader} value to a string prefix for file content.
7 */
8export function outputHeaderToPrefix(ctx: {
9 defaultValue: ReadonlyArray<string>;
10 header: OutputHeader;
11 project: IProject;
12}): string {
13 const { defaultValue, header, project } = ctx;
14 let lines = typeof header === 'function' ? header({ defaultValue, project }) : header;
15 if (lines === undefined) lines = defaultValue;
16 if (lines === null) return '';
17 lines =
18 typeof lines === 'string' ? lines.split(/\r?\n/) : lines.flatMap((line) => line.split(/\r?\n/));
19 const content = lines.join('\n');
20 return content ? `${content}\n\n` : '';
21}

Callers 2

generateClientBundleFunction · 0.90
generateClientBundleFunction · 0.90

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected