DEV Community

Ankan Saha
Ankan Saha

Posted on

All methods and their use of fs module in nodejs

fs.readFileSync: This method synchronously reads the entire contents of a file.

fs.readFile: This method asynchronously reads the entire contents of a file.

fs.writeFileSync: This method synchronously writes data to a file, replacing the file if it already exists.

fs.writeFile: This method asynchronously writes data to a file, replacing the file if it already exists.

fs.appendFileSync: This method synchronously appends data to a file, creating the file if it does not already exist.

fs.appendFile: This method asynchronously appends data to a file, creating the file if it does not already exist.

fs.watchFile: This method watches for changes to a file, and invokes a callback each time the file is modified.

fs.unwatchFile: This method stops watching for changes to a file that was previously being watched.

Top comments (0)