Skip to content

Instantly share code, notes, and snippets.

@deleteman
Created July 17, 2019 15:53
Show Gist options
  • Save deleteman/b631624583d6a0e0453a8031aea889d3 to your computer and use it in GitHub Desktop.
Save deleteman/b631624583d6a0e0453a8031aea889d3 to your computer and use it in GitHub Desktop.
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