partially made some requested changes, but other changes still need to be discussed
This commit is contained in:
parent
8a8e4219d2
commit
1c7c00142e
|
@ -210,7 +210,7 @@ function FileSystem(options, callback) {
|
|||
const statWatchers = new Map();
|
||||
|
||||
this.watchFile = function(filename, options, listener) {
|
||||
const prevStat, currStat;
|
||||
let prevStat, currStat;
|
||||
|
||||
if (Path.isNull(filename)) {
|
||||
throw new Error('Path must be a string without null bytes.');
|
||||
|
@ -225,9 +225,10 @@ function FileSystem(options, callback) {
|
|||
listener = listener || nop;
|
||||
|
||||
// Stores initial prev value to compare
|
||||
fs.stat(filename, function(err, stats) { prevStat = stats});
|
||||
fs.stat(filename, function(err, stats) {
|
||||
prevStat = stats;
|
||||
|
||||
//stores interval return values
|
||||
// Stores interval return values
|
||||
statWatchers.set(filename, value);
|
||||
|
||||
var value = setInterval(function() {
|
||||
|
@ -237,7 +238,7 @@ function FileSystem(options, callback) {
|
|||
}
|
||||
// Store the current stat
|
||||
currStat = stats;
|
||||
if(prevStat != currStat) {
|
||||
if(Object.toJSON(prevStat) !== Object.toJSON(currStat)) {
|
||||
listener(prevStat, currStat);
|
||||
}
|
||||
// Set a new prevStat based on previous
|
||||
|
@ -246,6 +247,7 @@ function FileSystem(options, callback) {
|
|||
},
|
||||
interval
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
// Deal with various approaches to node ID creation
|
||||
|
|
Loading…
Reference in New Issue