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

Function wrap

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

Source from the content-addressed store, hash-verified

848 record: <A>(key: string, run: () => Promise<A>) => Promise<A>,
849): FumaDb => {
850 const wrap = (inner: FumaDb): FumaDb =>
851 new Proxy(inner, {
852 get(target, prop) {
853 if (prop === "withContext") {
854 return (context: unknown) =>
855 wrap((target.withContext as (c: unknown) => FumaDb)(context));
856 }
857 if (prop === "findFirst" || prop === "findMany") {
858 return (table: unknown, query: unknown) =>
859 record(`${String(table)}.${prop}`, () =>
860 (Reflect.get(target, prop) as (t: unknown, q: unknown) => Promise<unknown>).call(
861 target,
862 table,
863 query,
864 ),
865 );
866 }
867 return Reflect.get(target, prop);
868 },
869 });
870 return wrap(db);
871};
872

Callers 3

getFunction · 0.70
withRecordedReadsFunction · 0.70
withFaultedReadsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected