File system
module
PW SKILLS
List of content:
1. What is a file system
2. Opening a file
3. Reading a file
4. Writing to a file
5. Appending to a file
6. Closing a file
7. Deleting a file
PW SKILLS
File System
● [Link] is a platform that uses Chrome's V8 JavaScript engine, allowing
developers to use JavaScript to create server-side applications that generate
dynamic content for web clients. What sets [Link] apart are its event-driven
and non-blocking I/O features.
● [Link] includes a built-in module called FS (File System) that allows users to
manage files by creating, reading, deleting, and performing other file operations.
● To use this module, developers can call the "require()" method, which provides
access to POSIX functions wrapped by [Link] to enable both synchronous and
asynchronous file system operations, depending on the user's requirements.
var fs = require('fs');
PW SKILLS
Synchronous vs Asynchronous approach :
● The Synchronous approach involves blocking functions that wait for each
operation to complete before executing the next one. This means that a
command won't execute until the query has finished executing and all the
results from previous commands have been obtained.
● On the other hand, the Asynchronous approach involves non-blocking
functions that execute all operations at once, without waiting for each
operation to complete. The results of each operation are handled when
they become available, and each command is executed after the
previous one. If the operations involve querying large amounts of data
from a database, the Asynchronous approach is recommended.
PW SKILLS
Common use for File System module:
● Read Files
● Write Files
● Append Files
● Close Files
● Delete Files
PW SKILLS
Opening a file
PW SKILLS
Reading a file
PW SKILLS
Writing to a file
PW SKILLS
Appending to a file
PW SKILLS
Closing a file
PW SKILLS
Deleting a file
PW SKILLS
THANK YOU
PW SKILLS