promise-readline
v1.0.8
Published
promise-style line reader.
Downloads
31
Maintainers
Readme
promise-readline
read a file or stdin line by line in promise style.
Install
npm install promise-readline --save
Usage
// JFK.txt
We choose to go to the moon in this decade and do the other things,
not because they are easy,
but because they are hard.
const lineReader = require('promise-readline');
const fs = require('fs');
(async () => {
//for stdin use: let lr = LineReader(process.stdin);
let lr = lineReader(fs.createReadStream('JFK.txt'));
await lr.readLine(); // We choose to go to the moon in this decade and do the other things,
await lr.readLine(); // not because they are easy,
await lr.readLine(); // but because they are hard.
await lr.readLine(); // undefined
lr.close();
})()
.catch(console.error);