read-each-line-async

1.0.9 • Public • Published

Read each line asynchronously with JS promises

Read file line by line asynchronously in Promise style.

Install

npm install read-each-line-async

Example

var readEachLineSync = require('read-each-line-async')

readEachLineSync('test.txt', 'utf8', async function (line) {
  
  console.log(line)
  
  if(await LongOperation) 
    return false; // Stop reading
  else
    return true; // Continue reading
  
}).then(()=> {
    ...
})

Encoding can optionally be omitted, in which case it will default to utf8:

readEachLineSync('test.txt', function(line) {
  console.log(line)
})

End-Of-Line can be specified along with encoding if necessary, otherwise it defaults to your operating system EOF:

readEachLineSync('test.txt', 'utf-8', '\n', function(line) {
  console.log(line)
})

Credits

Author: FlameArt

Based on read-each-line-sync by Geza Kovacs

Based on readLineSync

License

MIT

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i read-each-line-async

      Weekly Downloads

      0

      Version

      1.0.9

      License

      MIT

      Unpacked Size

      5.69 kB

      Total Files

      3

      Last publish

      Collaborators

      • flameart