MCPcopy Index your code
hub / github.com/microsoft/TypeChat / evaluateObject

Function evaluateObject

typescript/src/ts/program.ts:160–181  ·  view source on GitHub ↗
(obj: Record<string, unknown>)

Source from the content-addressed store, hash-verified

158 }
159
160 async function evaluateObject(obj: Record<string, unknown>) {
161 if (obj.hasOwnProperty("@ref")) {
162 const index = obj["@ref"];
163 if (typeof index === "number" && index < results.length) {
164 return results[index];
165 }
166 }
167 else if (obj.hasOwnProperty("@func")) {
168 const func = obj["@func"];
169 const args = obj.hasOwnProperty("@args") ? obj["@args"] : [];
170 if (typeof func === "string" && Array.isArray(args)) {
171 return await onCall(func, await evaluateArray(args));
172 }
173 }
174 else if (Array.isArray(obj)) {
175 return evaluateArray(obj);
176 }
177 else {
178 const values = await Promise.all(Object.values(obj).map(evaluate));
179 return Object.fromEntries(Object.keys(obj).map((k, i) => [k, values[i]]));
180 }
181 }
182
183 function evaluateArray(array: unknown[]) {
184 return Promise.all(array.map(evaluate));

Callers 1

evaluateFunction · 0.85

Calls 1

evaluateArrayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…