MCPcopy Index your code
hub / github.com/aiscript-dev/aiscript / NODE

Function NODE

src/parser/utils.ts:6–21  ·  view source on GitHub ↗
(
	type: T,
	params: Omit<Extract<Ast.Node, { type: T }>, 'type' | 'loc'>,
	start: Ast.Pos,
	end: Ast.Pos,
)

Source from the content-addressed store, hash-verified

4import type * as Ast from '../node.js';
5
6export function NODE<T extends Ast.Node['type']>(
7 type: T,
8 params: Omit<Extract<Ast.Node, { type: T }>, 'type' | 'loc'>,
9 start: Ast.Pos,
10 end: Ast.Pos,
11): Extract<Ast.Node, { type: T }> {
12 const node: Record<string, unknown> = { type };
13 for (const key of Object.keys(params)) {
14 type Key = keyof typeof params;
15 if (params[key as Key] !== undefined) {
16 node[key] = params[key as Key];
17 }
18 }
19 node.loc = { start, end };
20 return node as Extract<Ast.Node, { type: T }>;
21}
22
23export function CALL_NODE(
24 name: string,

Callers 15

CALL_NODEFunction · 0.85
parseDestFunction · 0.85
parseNamespaceFunction · 0.85
parseMetaFunction · 0.85
parseBlockOrStatementFunction · 0.85
parseVarDefFunction · 0.85
parseFnDefFunction · 0.85
parseEachFunction · 0.85
parseForFunction · 0.85
parseReturnFunction · 0.85
parseAttrFunction · 0.85
parseLoopFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected