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

Function wrap

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

Source from the content-addressed store, hash-verified

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

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