Skip to content

Instantly share code, notes, and snippets.

@debonx
Last active January 19, 2020 18:26
Show Gist options
  • Save debonx/070076fbb04fcf92a2ec7b921649ecfd to your computer and use it in GitHub Desktop.
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.
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