Skip to content

read a file or stdin line by line in promise style.

Notifications You must be signed in to change notification settings

magnuslim/readline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

read a file or stdin line by line in promise style.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published