readlines

0.2.0 • Public • Published

Readlines

Build Status Coverage Status

Read file line as array.

Install

npm install readlines

or

npm install -g readlines

Example:

  var rl = require('readlines');
  var lines = rl.readlinesSync('example.txt');
  for(var line in lines){
    console.log(lines[line]);
  };

API

readlinesSync(filename, [options])

Sync read file by line return an array.

  var lines = rl.readlinesSync(filePath);

readlines(filename, [options], callback)

Async read file by line return an array.

  rl.readlines(filePath, function(err, lines){
      console.log(lines);
  });

readlineSync(filename, [options], lineNum)

Sync read file by line return specific line.

  var line = rl.readlineSync(filePath, 3);

readline(filename, [options], lineNum, callback)

Async read file by line return specific line.

  rl.readline(filePath, 3, function(err, line){
      console.log(line);
  });

readlinesStream()

Read by line as stream.

  var liner = rl.readlinesStream();
 
  fs.createReadStream(filePath)
      .pipe(liner)
      .on('readable', function() {
          var line;
          while (line = liner.read()) {
              console.log(line);
          }
      });

License

The MIT License

Package Sidebar

Install

npm i readlines

Weekly Downloads

212

Version

0.2.0

License

MIT

Last publish

Collaborators

  • booxood