let fs = require('fs');
let readline = require('readline');
function readFileToArr(fReadName, callback) {
let fRead = fs.createReadStream(fReadName);
let objReadline = readline.createInterface({
input: fRead
});
let arr = new Array();
objReadline.on('line', line => {
arr.push(line);
});
objReadline.on('close', () => {
callback(arr);
});
}
readFileToArr('a.txt', arr => console.log(arr));
网友评论