Skip to content

Commit

Permalink
fs: Removing inStatWatchers function
Browse files Browse the repository at this point in the history
  • Loading branch information
thefourtheye committed Jun 2, 2015
1 parent 706ec9b commit d449b8e
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,12 +1296,7 @@ StatWatcher.prototype.stop = function() {
};


var statWatchers = {};
function inStatWatchers(filename) {
return Object.prototype.hasOwnProperty.call(statWatchers, filename) &&
statWatchers[filename];
}

var statWatchers = Object.create(null);

fs.watchFile = function(filename) {
nullCheck(filename);
Expand All @@ -1328,7 +1323,7 @@ fs.watchFile = function(filename) {
throw new Error('watchFile requires a listener function');
}

if (inStatWatchers(filename)) {
if (filename in statWatchers) {
stat = statWatchers[filename];
} else {
stat = statWatchers[filename] = new StatWatcher();
Expand All @@ -1341,7 +1336,7 @@ fs.watchFile = function(filename) {
fs.unwatchFile = function(filename, listener) {
nullCheck(filename);
filename = pathModule.resolve(filename);
if (!inStatWatchers(filename)) return;
if (!(filename in statWatchers)) return;

var stat = statWatchers[filename];

Expand All @@ -1353,7 +1348,7 @@ fs.unwatchFile = function(filename, listener) {

if (EventEmitter.listenerCount(stat, 'change') === 0) {
stat.stop();
statWatchers[filename] = undefined;
delete statWatchers[filename];
}
};

Expand Down

0 comments on commit d449b8e

Please sign in to comment.