Monday, September 10, 2018

fs.watch(filename[, options][,listener]) blog


In this tutorial we will be going over the watch() function

fs.watch(filename[, options][,listener])

This functions has three arguments first is the file name
 Ex
fs.watch("text.txt"[, options][,listener])

The second argument is the optional, provide a string to specifiy encoding otherwise the option should be an object
Ex
fs.watch("text.txt",  obj, [listener])

Lastly the listener argument represents a callback with two arguments. the eventType, and the filename. The eventType is either rename or change depending on the event, and the filename represents the file that triggered the event.



No comments:

Post a Comment