Created
July 17, 2019 15:53
-
-
Save deleteman/b631624583d6a0e0453a8031aea889d3 to your computer and use it in GitHub Desktop.
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
const fs = require("fs") | |
async function read(fname) { | |
return new Promise( (resolve, reject) => { | |
fs.readFile(fname, (err, content) => { | |
if(err) return reject(err) | |
resolve(content.toString()) | |
}) | |
}) | |
} | |
let files = ['file1.json', 'file2.json'] | |
files.forEach( async fname => { | |
let fcontent = await read(fname) | |
console.log(fcontent) | |
console.log("-------") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment