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

Function wrap

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

Source from the content-addressed store, hash-verified

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

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