MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / recursiveRender

Function recursiveRender

Extension/src/Utility/Text/taggedLiteral.ts:240–254  ·  view source on GitHub ↗
(obj: T, context: Record<string, any>, customResolver = (_prefix: string, _expression: string) => '')

Source from the content-addressed store, hash-verified

238}
239
240export function recursiveRender<T extends Record<string, any>>(obj: T, context: Record<string, any>, customResolver = (_prefix: string, _expression: string) => ''): T {
241 const result = (is.array(obj) ? [] : {}) as Record<string, any>;
242 for (const [key, value] of Object.entries(obj)) {
243 const newKey = is.string(key) && key.includes('${') ? render(key, context, customResolver) : key;
244
245 if (is.string(value)) {
246 result[newKey] = evaluateExpression(value, context, customResolver);
247 } else if (typeof value === 'object') {
248 result[newKey] = recursiveRender(value, context, customResolver);
249 } else {
250 result[newKey] = value;
251 }
252 }
253 return result as T;
254}

Callers

nothing calls this directly

Calls 5

renderFunction · 0.85
evaluateExpressionFunction · 0.85
arrayMethod · 0.80
entriesMethod · 0.80
stringMethod · 0.45

Tested by

no test coverage detected