Skip to content

Instantly share code, notes, and snippets.

@MelodicCrypter
Created August 19, 2019 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MelodicCrypter/1c67e3fe9c6d9e5c71bc4680b7124494 to your computer and use it in GitHub Desktop.
Save MelodicCrypter/1c67e3fe9c6d9e5c71bc4680b7124494 to your computer and use it in GitHub Desktop.
A NodeJS sample of using Util's promisify to write a file.
const fs = require('fs');
const { promisify } = require('util');
const writeFile = promisify(fs.writeFile);
writeFile('sample.txt', 'this is a sample phrase')
.then(() => console.log('done!'))
.catch(e => console.log(e));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment