4

Is there a way to prevent Readline module from removing a whitespace that comes before the line break in the file itself? I'm parsing a non text file and those spaces are important.

And why a Reader modifies the file it reads?

I've tried using a terminal mode, no success there...

const readline = require('readline');
const fs = require('fs');
...
// Init reader interface
this.lineReader = readline.createInterface({
    input: fs.createReadStream(this.inputFile),
    terminal: true
});

this.lineReader.on('line', (line) => {
    return callback(null, line);
});
Scillen
  • 41
  • 3

1 Answers1

0

For the nodejs of today (2018), the package n-readlines does the trick of preserving the entire contents of the line, including the EOL characters. This is very handy for counting the number of bytes seen; as in when one is building an index to a file's contents.

starlocke
  • 3,407
  • 2
  • 25
  • 38