this project has the code doing following:
- It's node.js code with no express library use to handle routes.
- It does CRUD operation with in text file all while using native node methods.
- It also handles streams of data in chunks.
- Set up a templating engine so you can write your pages in a templating language. If you don't know which one to pick some great ones are
Take a look at the file created for you in streams/streams.js
. This can be run using npm run streams
.
- Readable streams
- Create a readable stream to import the file
on-joy-and-sorrow-emoji.txt
- On the 'data' event, console.log the data received (what do you notice?)
- How can we decode this data so it shows up in the console?
- Update our console logs so ':)' is replaced with 'joy' and ':(' is replaced with 'sorrow'
- Create a readable stream to import the file
- Writable streams
- Create a writable stream exporting to
on-joy-and-sorrow-fixed.txt
- Pipe the readable stream to the writable stream
- Create a writable stream exporting to
- Transform streams implement a readable and writable interface for modifying input from readable streams
- Create a transform stream to modify incoming data, replacing ':)' with 'joy' and ':(' with 'sorrow'. NOTE: The through2 library is a useful abstraction for this (it's already been imported for you)
- Pipe the readable stream to the transform stream you just created, and then pipe the result to the writable stream