SHARE

Hey gang, in this tutorial I’ll show you how we can create a readable stream and use it to read data / files. Using a readable stream means we don’t have to wait for the full file to be stored in memory before we start to do something with the data.

—– COURSE LINKS:
+ Repo – https://github.com/iamshaunjp/node-js-playlist
+ Atom editor – https://atom.io/

———————————————————————————————
You can find more front-end development tutorials on CSS, HTML, JavaScript, jQuery, WordPress & more on the channel homepage…

SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1

========== JavaScript for Beginners Playlist ==========

https://www.youtube.com/playlist?list=PL4cUxeGkcC9i9Ae2D9Ee1RvylH38dKuET

============ CSS for Beginners Playlist =============

https://www.youtube.com/playlist?list=PL4cUxeGkcC9gQeDH6xYhmO-db2mhoTSrT

============== The Net Ninja =====================

For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk

================== Social Links ==================

Twitter – @TheNetNinja – https://twitter.com/thenetninjauk

39 COMMENTS

  1. Excellent tutorial, thanks. Just one small correction (as of Oct 2017), in fs.createReadStream() instead of 'utf8' parameter, it should be {encoding: 'utf8'}

    Thanks

  2. If you want to read a .json file could you use .createReadStream or should you use readFile/Sync? What's the real difference between the two?

  3. Can anyone please tell me why he didnt use
    my ReadStream.emit(data , chunk); ???
    becuase in 8th tutorial he kinda use all three
    the event emitter,the binder (.on) and the .emit.

  4. why does Node.js force us to stream data rather than buffer it ?
    what are the difference b/w these two ?
    why performance is good in streams as compared to buffer ?

  5. how to remove particular line from file ?

    file.text

    1 abc def
    2 abc def
    3 abc def
    4 abc def

    after deleting(3rd line removed)

    1 abc def
    2 abc def
    4 abc def

  6. i am a mobile dev, the first time i come with NodeJS, i saw many tut on the internet, but this series video is the best fot beginer :D, many thanks ^^

  7. On mine, it only shows one new chunk on both of them, but yet I am reading a package.json file. I am trying SO HARD to install Express and I keep screwing up somehow. I just hope this series will fix my problem. I anyone would like to help me, it would be appreciated .

  8. i am new to node.js and want to ask, why need to require http as first line of code 'cos in this example, i am not seeing it being use. is there depecencies over at the fs ?

  9. For those of you who wonder why the buffer is not presenting as the file text after adding utf8 as 3rd parameter:
    pass an object as 3rd parameter {encoding: 'utf8'} like this:
    var myReadStream = fs.createReadStream(__dirname + '/readme.txt', {encoding: 'utf8'});

LEAVE A REPLY

Please enter your comment!
Please enter your name here