Created
March 20, 2016 00:22
-
-
Save subfuzion/35bf6061595eb141bd38 to your computer and use it in GitHub Desktop.
promisified fs.readFile
This file contains 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
'use strict'; | |
var promisify = require('promisify-lite'); | |
var fs = require('fs'); | |
fs = promisify(fs); | |
let f = require('path').join(__dirname, './file.txt'); | |
fs.readFileAsync(f, 'utf8') | |
.then(data => { | |
console.log(data); | |
}) | |
.catch(err => { | |
console.error(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment