MCPcopy Create free account
hub / github.com/Noumena-Network/code / mapValuesDeep

Function mapValuesDeep

src/services/vcr.ts:222–237  ·  view source on GitHub ↗
(
  obj: {
    [x: string]: unknown
  },
  f: (val: unknown, key: string, obj: Record<string, unknown>) => unknown,
)

Source from the content-addressed store, hash-verified

220}
221
222function mapValuesDeep(
223 obj: {
224 [x: string]: unknown
225 },
226 f: (val: unknown, key: string, obj: Record<string, unknown>) => unknown,
227): Record<string, unknown> {
228 return mapValues(obj, (val, key) => {
229 if (Array.isArray(val)) {
230 return val.map(_ => mapValuesDeep(_, f))
231 }
232 if (isPlainObject(val)) {
233 return mapValuesDeep(val as Record<string, unknown>, f)
234 }
235 return f(val, key, obj)
236 })
237}
238
239function mapAssistantMessage(
240 message: AssistantMessage,

Callers 2

mapMessagesFunction · 0.85
mapAssistantMessageFunction · 0.85

Calls 1

fFunction · 0.85

Tested by

no test coverage detected