Created
June 11, 2020 16:41
-
-
Save chriskacerguis/6c0293068e17c1fefb411f419a65e4a0 to your computer and use it in GitHub Desktop.
Context Manager for Justin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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