It really depends on what you want to achieve.

This is one potential

// returns and Observable which emits every time a file is read - emitted values are://    - the name of the file read//    - an array containing the lines of the file as stringsexport function readFilesObservable(fileList: Array<string>) {  return Observable.from(fileList)  .mergeMap(file => _readFileObservable(file))}const _readFileObservable = Observable.bindCallback(_readLines, (fileFullName: string, lines: Array<string>) => ({fileFullName, lines}));function _readLines(fileFullName: string, callback: (file: string, lines: Array<string>) => void) {  const lines = new Array<string>();  const rl = readline.createInterface({    input: fs.createReadStream(fileFullName),    crlfDelay: Infinity  });  rl.on('line', (line: string)  => {    lines.push(line);  });  rl.on('close', ()  => {    callback(fileFullName, lines);  })}

A man with passion for code and for some strange things that sometimes happen in IT organizations. Views and thoughts here are my own.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store