Created
April 26, 2017 01:13
-
-
Save kei0425/182cab9bbc634255a0f3e8b70d991f19 to your computer and use it in GitHub Desktop.
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
const fs = require('fs'); | |
const filelist = [ | |
'data/all1.txt', | |
'data/all2.txt', | |
'data/all3.txt', | |
'data/all4.txt', | |
]; | |
const filelength = async filename => new Promise((resolve, reject) => { | |
fs.readFile(filename, (err, data) => { | |
if (err) { | |
reject(err); | |
} | |
else { | |
resolve({filename, length:data.length}); | |
} | |
}); | |
}); | |
const main = async function () { | |
let contains = await Promise.all(filelist.map(filelength)); | |
console.log(contains); | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment