![]() The below examples illustrate the trigger event that is fired when any changes or modification is done upon the file in Node.js:Įxample 1: This example shows any changes to the file with the help of fs. filename: As the name suggests, this takes a string or buffer input for the filename.eventType: This is a string value that specifies the different types of modification on the file.listener: This is a string value that specifies the character encoding that uses the filename which is passed to the listener.encoding: This is a string value that specifies the character encoding that needs to be used for passing the filename to the user.recursive: This is a boolean value that specifies whether the subdirectories of the given directory should be watched or not.persistent: This is a boolean value that specifies whether the process should continue or not while the file is being watched.options: This is a string or an object that is used for modifying the behavior of the method.filename: This is a string, buffer, or a URL that represents the name of the file (Directory in fs.watch()) that is to be watched.Parameters: The above method accepts 3 parameters which are explained below: Start up the REPL, and get the Monitor class. It contains a callback listener that always listens to the file and informs of any changes.įs.watchFile() fs.watchFile(filename, listener) Ad-hoc monitoring can be done from a REPL console. The fs.watchFile() method continuously watches for any changes in the given file. This method returns a Watcher object that is basically used for tracking any changes in the file.įs.watch() fs.watch( filename ) This regularly watches for any changes to the file in the given directory. The fs.watch() is an inbuilt application programming interface method provided by the fs module. Whats more, its filter function offers users access to customizing what will be showed in the log. The difference between the two is fs.watch() method can watch both files and the directories whereas the fs.watchFile is only designed for watching any changes in the file. So amazing 'Free Folder Monitor manages to monitor the actions of any disk, folder, file or EXE in the computer. ![]() When a directory is monitored, events are returned for the directory itself and its files. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |