Created
April 26, 2017 01:12
-
-
Save kei0425/0b1e7b16be289ce69bfe566797afaff6 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 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