Skip to content

Instantly share code, notes, and snippets.

@deleteman
Created July 17, 2019 14:59
Show Gist options
  • Save deleteman/108f1174f6ba8e9b580b981554f9b6d0 to your computer and use it in GitHub Desktop.
Save deleteman/108f1174f6ba8e9b580b981554f9b6d0 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())
})
})
}
(async () => {
let files = ['file1.json', 'file2.json']
for(let i = 0; i < files.length; i++) {
let fcontent = await read(files[i])
console.log(fcontent)
console.log("-------")
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment