MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / formatValueForVarName

Function formatValueForVarName

lib/prompts/dataAnalysis.ts:120–137  ·  view source on GitHub ↗
(key: string, value: any)

Source from the content-addressed store, hash-verified

118}
119
120function formatValueForVarName(key: string, value: any): string {
121 if (Array.isArray(value)) {
122 return formatValueForVarName(key, value[0]);
123 } else if (typeof value === "object") {
124 return formatValueForVarName(key, Object.values(value)[0]);
125 } else if (typeof value === "string") {
126 // Remove all non-alphanumeric characters
127 const noAlnumChars = value.replace(/[^a-zA-Z0-9]/g, "");
128 return noAlnumChars[0].toUpperCase() + noAlnumChars.slice(1);
129 } else if (["number", "boolean"].includes(typeof value)) {
130 const noAlnumChars = key.replace(/[^a-zA-Z0-9]/g, "");
131 return (
132 noAlnumChars[0].toUpperCase() + noAlnumChars.slice(1) + value.toString()
133 );
134 } else {
135 return key.replace(/[^a-zA-Z0-9]/g, "") + value.toString();
136 }
137}
138
139export function getVarNames(calledActions: CalledAction[]): string[] {
140 const varNames: string[] = [];

Callers 1

getVarNamesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected