Answer the question
In order to leave comments, you need to log in
How to return an array from require readline?
Good afternoon everyone, I want to return the temp array from line-by-line reading, what are the ways?
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream(tempCatalog+fileDEF)
});
lineReader.on('line', function (line) {
var list = line.split(';'), operator = list[4].replace(/['"«»]/g, '');
if( array.indexOf( operator ) == -1 && temp.indexOf( operator ) == -1 )
{
temp.push( operator );
}
});
Answer the question
In order to leave comments, you need to log in
Thanks to all! I figured it out! It turned out better than I wanted!
async function processLineByLine() {
var array = await unloadExistOperator(), temp = Array();
const lineReader = require('readline').createInterface({
input: require('fs').createReadStream(tempCatalog+fileDEF)
});
for await (const line of lineReader) {
var list = line.split(';'), operator = list[4].replace(/['"«»]/g, '');
if( array.indexOf( operator ) == -1 && temp.indexOf( operator ) == -1 )
{
temp.push( operator );
console.log(list[4])
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question