MCPcopy Index your code
hub / github.com/nodejs/llhttp / build

Function build

test/fixtures/index.ts:83–121  ·  view source on GitHub ↗
(
  llparse: LLParse, node: Node, outFile: string,
  options: IFixtureBuildOptions = {},
  ty: TestType = 'none')

Source from the content-addressed store, hash-verified

81const cache = new Map<Node, ICompilerResult>();
82
83export async function build(
84 llparse: LLParse, node: Node, outFile: string,
85 options: IFixtureBuildOptions = {},
86 ty: TestType = 'none'): Promise<FixtureResult> {
87 const dot = new Dot();
88 fs.writeFileSync(path.join(BUILD_DIR, outFile + '.dot'),
89 dot.build(node));
90
91 let artifacts: ICompilerResult;
92 if (cache.has(node)) {
93 artifacts = cache.get(node)!;
94 } else {
95 artifacts = llparse.build(node, {
96 c: { header: outFile },
97 debug: process.env.LLPARSE_DEBUG ? 'llparse__debug' : undefined,
98 });
99 cache.set(node, artifacts);
100 }
101
102 const extra = options.extra === undefined ? [] : options.extra.slice();
103
104 if (allowedTypes.includes(ty)) {
105 extra.push(
106 `-DLLPARSE__TEST_INIT=llhttp__test_init_${ty.replace(/-/g, '_')}`);
107 }
108
109 if (ty === 'request-finish' || ty === 'response-finish') {
110 if (ty === 'request-finish') {
111 extra.push('-DLLPARSE__TEST_INIT=llhttp__test_init_request');
112 } else {
113 extra.push('-DLLPARSE__TEST_INIT=llhttp__test_init_response');
114 }
115 extra.push('-DLLPARSE__TEST_FINISH=llhttp__test_finish');
116 }
117
118 return await fixtures.build(artifacts, outFile, Object.assign(options, {
119 extra,
120 }));
121}

Callers 1

buildModeFunction · 0.90

Calls 1

buildMethod · 0.45

Tested by

no test coverage detected