Skip to content

Instantly share code, notes, and snippets.

@CertainPerformance
Last active January 31, 2020 11:50
Show Gist options
  • Save CertainPerformance/8603914bcaf558f9c5c314ad262330e4 to your computer and use it in GitHub Desktop.
Save CertainPerformance/8603914bcaf558f9c5c314ad262330e4 to your computer and use it in GitHub Desktop.
const writeJoke = async (joke, path) => {
const filehandle = await fs.open(path, 'w');
try {
return await filehandle.write(joke);
} finally {
await filehandle.close();
}
};
(async () => {
const [j1, j2] = await gfunction();
const results = await Promise.all([
writeJoke(j1, './joke1'),
writeJoke(j2, './joke2'),
]);
console.log(results);
})()
.catch(e => console.error(`Unexpected exception ${e.message}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment