Skip to content

Instantly share code, notes, and snippets.

@orleika
Created August 24, 2017 04:08
Show Gist options
  • Save orleika/b57bed15cebeb22196f466626be50609 to your computer and use it in GitHub Desktop.
Save orleika/b57bed15cebeb22196f466626be50609 to your computer and use it in GitHub Desktop.
wrap nodejs fs#readFile to be a promise
const readFile = (...args) => {
return new Promise((resolve, reject) => {
fs.readFile(...args, (err, data) => {
if (err) reject(err)
resolve(data)
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment