MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / wrap

Function wrap

packages/core/sdk/src/executor.test.ts:960–979  ·  view source on GitHub ↗
(inner: FumaDb)

Source from the content-addressed store, hash-verified

958 record: <A>(key: string, run: () => Promise<A>) => Promise<A>,
959): FumaDb => {
960 const wrap = (inner: FumaDb): FumaDb =>
961 new Proxy(inner, {
962 get(target, prop) {
963 if (prop === "withContext") {
964 return (context: unknown) =>
965 wrap((target.withContext as (c: unknown) => FumaDb)(context));
966 }
967 if (prop === "findFirst" || prop === "findMany") {
968 return (table: unknown, query: unknown) =>
969 record(`${String(table)}.${prop}`, () =>
970 (Reflect.get(target, prop) as (t: unknown, q: unknown) => Promise<unknown>).call(
971 target,
972 table,
973 query,
974 ),
975 );
976 }
977 return Reflect.get(target, prop);
978 },
979 });
980 return wrap(db);
981};
982

Callers 3

getFunction · 0.70
withRecordedReadsFunction · 0.70
withFaultedReadsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected