Read line by line from a stream, file or stdin lazily.
$ npm install --save line-read
Read all lines from a small file in one go
var readline = require('line-read');
readline.readLineFromFile('filename').join(function(xs) {
// xs is the list of lines from the file
});
To read from a very large file, it would be better to read each line one by one.
var readline = require('line-read');
readline.readLineFromFile('filename').forEach(function(line) {
console.log(line);
});
Reading from stdin is similar to reading from a large file
var readline = require('line-read');
readline.readLine(process.stdin).forEach(function(line) {
console.log('line ' + line);
});
All methods return a lazy
instance of lines. See the lazy package for more details.
Get lines from stream. Lines are separated by separator, default to \n
.
Get lines from file filename
. Lines are separated by separator, default to \n
.
MIT © Minh Ha