function withRead(store, fn) {
  return using(store.read(), fn);
}
function withWriteNoImplicitCommit(store, fn) {
  return using(store.write(), fn);
}
function withWrite(store, fn) {
  return using(store.write(), async (write) => {
    const result = await fn(write);
    await write.commit();
    return result;
  });
}
async function using(x, fn) {
  const write = await x;
  try {
    return await fn(write);
  } finally {
    write.release();
  }
}
export {
  using,
  withRead,
  withWrite,
  withWriteNoImplicitCommit
};
//# sourceMappingURL=with-transactions.js.map
