Computer scienceBackendNode.jsCore ConceptsInternal modulesStreams

What are streams?

We need strings

Report a typo

You are given the following code snippet. At the moment, the code outputs a buffer to the console. Change the code so that it outputs the string data types written in the data.txt file to the console.

Sample Input 1:

Sample Output 1:

true
Write a program in JavaScript
const fs = require("fs");

function main() {
const readerStream = fs.createReadStream('./data.txt');

readerStream.on('data', (chunk) => {
console.log(chunk)
})
};
___

Create a free account to access the full topic