Posts

Showing posts from July, 2019

File System in Node.js

File System                     The fs  module provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions. To use this module:                                                      const fs = require(' fs ') All file system operations have synchronous and asynchronous forms. The asynchronous form always takes a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be null  or undefined .                   const fs = require('fs');                   fs.unlink('/tmp/hello',(err)  =>{                   if(err) throw err;                   console.log ('Successfully deleted /tmp/hello'); Exceptions that occur using synchronous operations are thrown immediately and may be handled usi