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

Function wrap

packages/core/sdk/src/connections.test.ts:73–93  ·  view source on GitHub ↗
(inner: FumaDb)

Source from the content-addressed store, hash-verified

71 hooks: { readonly enter: () => void; readonly exit: () => void },
72): FumaDb => {
73 const wrap = (inner: FumaDb): FumaDb =>
74 new Proxy(inner, {
75 get(target, prop) {
76 if (prop === "withContext") {
77 return (context: unknown) =>
78 wrap((target.withContext as (c: unknown) => FumaDb)(context));
79 }
80 if (prop === "transaction") {
81 return async (run: Parameters<FumaDb["transaction"]>[0]) => {
82 hooks.enter();
83 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: test instrument must unwind on both outcomes
84 try {
85 return await target.transaction(run);
86 } finally {
87 hooks.exit();
88 }
89 };
90 }
91 return Reflect.get(target, prop);
92 },
93 });
94 return wrap(db);
95};
96

Callers 7

getFunction · 0.70
instrumentTransactionsFunction · 0.70
blindfoldConnectionReadsFunction · 0.70
staleCompensationReadFunction · 0.70
failableConfirmationReadFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected