Files
reverse-engineering-anything/src/domain/javascript/javascriptSemanticCallLiterals.ts
T
morluto f9e7571a3d feat(javascript): discover semantic call literals in feature traces (#7840)
* feat(javascript): discover semantic call literals in feature traces

* fix(javascript): bound retained call literals by transfer capacity

* test(javascript): align feature no-match diagnostic
2026-10-29 01:25:23 +08:00

26 lines
825 B
TypeScript

import type { JavaScriptSemanticGraphNode } from "./javascriptSemanticGraphSchemas.js";
/** Read retained direct call literals without interpreting other node properties. */
export const semanticCallLiteralValues = (
node: JavaScriptSemanticGraphNode,
): (string | number | boolean | null)[] => {
if (node.kind !== "call-site" || !Array.isArray(node.properties.arguments))
return [];
return node.properties.arguments.flatMap((argument) => {
if (
argument === null ||
typeof argument !== "object" ||
Array.isArray(argument) ||
!Object.hasOwn(argument, "value")
)
return [];
const value = argument.value;
return value === null ||
typeof value === "string" ||
typeof value === "number" ||
typeof value === "boolean"
? [value]
: [];
});
};