Please enable JavaScript.
Coggle requires JavaScript to display documents.
NodeJs - Understand Node Built in Modules (Streams module (Implements some…
NodeJs - Understand Node Built in Modules
fs
=> File system module
able to read or write file content
a wrapper that contains the standard file operations for manipulating files and dealing with the computing platform's file system
var fs = require('fs');
Operations
onto a file
Writing
fs.writeFile(file_name, data, callback)
fs.appendFile(file_name, data, callback);
text
Reading
fs.readFile(file_path, encoding, callback);
Updating
Streams
module
speeds up the file operations
read data from a source and pipe it to a destination faster
EventEmitter
Implements some special methods to make it
...
Readable
Methods
read()
setEncoding(encoding)
resume()
pause()
pipe()
Events
data/readable
end
close
error
Writable
Methods
write()
setDefaultEncoding(encoding)
end()
Events
drain
finish
pipe
error
Duplex
Used
When...
To implement a web application which contains lot of I/O operations
To perform Live streaming of video
To upload files in real time
Transform streams
Zlib
transform stream
compress or decompress the data before writing it to the destination
Crypto
transform stream
encrypt or decrypt the data before writing it to the destination
net
module
create
TCP servers
and
TCP client
TCP Server
listens for connections from clients and also sends data to the client
an asynchronous wrapper
TCP client
connects to the server and exchange data with it.
Do
Socket programming