mirror of
https://github.com/morluto/rea.git
synced 2026-11-12 01:41:21 +00:00
* 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
26 lines
825 B
TypeScript
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]
|
|
: [];
|
|
});
|
|
};
|