MCPcopy Create free account
hub / github.com/Thanas-R/Virdis / flatten

Function flatten

supabase/functions/gee-analytics/index.ts:102–120  ·  view source on GitHub ↗
(node: any)

Source from the content-addressed store, hash-verified

100 const values: Record<string, any> = {};
101 let counter = 0;
102 function flatten(node: any): string {
103 if (node === null || node === undefined) {
104 const k = `_${counter++}`; values[k] = { constantValue: null }; return k;
105 }
106 if (node.functionInvocationValue) {
107 const fiv = node.functionInvocationValue;
108 const flatArgs: Record<string, any> = {};
109 for (const [argName, argVal] of Object.entries(fiv.arguments || {})) {
110 flatArgs[argName] = { valueReference: flatten(argVal as any) };
111 }
112 const k = `_${counter++}`;
113 values[k] = { functionInvocationValue: { functionName: fiv.functionName, arguments: flatArgs } };
114 return k;
115 }
116 if ("constantValue" in node) {
117 const k = `_${counter++}`; values[k] = { constantValue: node.constantValue }; return k;
118 }
119 const k = `_${counter++}`; values[k] = { constantValue: node }; return k;
120 }
121 return { values, result: flatten(nested) };
122}
123

Callers 1

flattenExpressionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected