Fixed #707 Replaced var with const and let and added strict mode (#712)

* Fixed #707 Replaced var with const and let and added strict mode

* Fixed src/fs-watcher.js and changed remaining var to let

* Changed src/fs-watcher.js file to use const instead of let at line 52 and 57
This commit is contained in:
Harsh Patel 2019-01-31 20:20:56 -05:00 committed by David Humphrey
parent 87513997a2
commit 701849eb5a
1 changed files with 11 additions and 9 deletions

View File

@ -1,6 +1,8 @@
var EventEmitter = require('../lib/eventemitter.js'); 'using strict';
var Path = require('./path.js');
var Intercom = require('../lib/intercom.js'); const EventEmitter = require('../lib/eventemitter.js');
const Path = require('./path.js');
const Intercom = require('../lib/intercom.js');
/** /**
* FSWatcher based on node.js' FSWatcher * FSWatcher based on node.js' FSWatcher
@ -8,10 +10,10 @@ var Intercom = require('../lib/intercom.js');
*/ */
function FSWatcher() { function FSWatcher() {
EventEmitter.call(this); EventEmitter.call(this);
var self = this; const self = this;
var recursive = false; let recursive = false;
var recursivePathPrefix; let recursivePathPrefix;
var filename; let filename;
function onchange(path) { function onchange(path) {
// Watch for exact filename, or parent path when recursive is true. // Watch for exact filename, or parent path when recursive is true.
@ -46,12 +48,12 @@ function FSWatcher() {
recursivePathPrefix = filename === '/' ? '/' : filename + '/'; recursivePathPrefix = filename === '/' ? '/' : filename + '/';
} }
var intercom = Intercom.getInstance(); const intercom = Intercom.getInstance();
intercom.on('change', onchange); intercom.on('change', onchange);
}; };
self.close = function() { self.close = function() {
var intercom = Intercom.getInstance(); const intercom = Intercom.getInstance();
intercom.off('change', onchange); intercom.off('change', onchange);
self.removeAllListeners('change'); self.removeAllListeners('change');
}; };