1.

Mention types of streams?

Answer»

The following are the types of streams in Node.Js:

1) Readable Streams: A stream where you can recieve data but cannot send it.  When you push data into a readable stream , it is buffered, until customer starts to read the data

    Example: HTTP REQUESTS to the server. Based on the HTTP request, server sends HTTP response to the client which is a readable stream. Another example is RSS FEED posted by remote SERVERS on the HTTP clients are readonly streams.

Module used: fs.createReadStream

2) Writable Streams: A stream where you can send the data but not recieve  from it.

    Example: user entered data on HTTP clients go as HTTP Responses to the server where data is written.

Module used: fs.createWriteStream()

3) Duplex Streams: Streams that are both readable and writable.

Example: TCP sockets

Module used: net.socket

4) Transform Streams: A type of duplex streams where output is in someway related to the input. LIKE duplex streams, Transform streams also implement both Readable and Writable interfaces.



Discussion

No Comment Found