Skip to content

Instantly share code, notes, and snippets.

@chriskacerguis
Created June 11, 2020 16:41
Show Gist options
  • Select an option

  • Save chriskacerguis/6c0293068e17c1fefb411f419a65e4a0 to your computer and use it in GitHub Desktop.

Select an option

Save chriskacerguis/6c0293068e17c1fefb411f419a65e4a0 to your computer and use it in GitHub Desktop.
Context Manager for Justin
function using(res, fn) {
var pRes = Promise.cast(res);
return pRes.then(fn).finally(() => {
return pRes.then((res) => {
return res.close();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment