Last active
January 19, 2020 18:26
-
-
Save debonx/070076fbb04fcf92a2ec7b921649ecfd to your computer and use it in GitHub Desktop.
Node: Readable stream, to execute code sequentially using readline and fs core modules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require('readline'); | |
const fs = require('fs'); | |
const myInterface = readline.createInterface({ | |
input: fs.createReadStream('shoppingList.txt') | |
}); | |
const printData = (data) => { | |
console.log(`Item: ${data}`); | |
} | |
myInterface.on('line', printData); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment