From 8b5772b6ddeabcee3ebc5a517609441927d9242e Mon Sep 17 00:00:00 2001 From: sapics Date: Tue, 27 Aug 2024 22:21:27 +0900 Subject: [PATCH] remove semicolon --- lib/fsWatcher.js | 34 ++++++++++++++-------------- lib/utils.js | 54 ++++++++++++++++++++++----------------------- scripts/updatedb.js | 1 - 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/lib/fsWatcher.js b/lib/fsWatcher.js index 44e6180..ecd9a65 100644 --- a/lib/fsWatcher.js +++ b/lib/fsWatcher.js @@ -1,6 +1,6 @@ var fs = require('fs'), path = require('path'), - FSWatcher = {}; + FSWatcher = {} /** * Takes a directory/file and watch for change. Upon change, call the @@ -14,44 +14,44 @@ var fs = require('fs'), * @param {Function} callback: function () : called when changes are detected **/ function makeFsWatchFilter(name, directory, filename, cooldownDelay, callback) { - var cooldownId = null; + var cooldownId = null //Delete the cooldownId and callback the outer function function timeoutCallback() { - cooldownId = null; - callback(); + cooldownId = null + callback() } //This function is called when there is a change in the data directory //It sets a timer to wait for the change to be completed function onWatchEvent(event, changedFile) { - var filePath = path.join(directory, changedFile); + var filePath = path.join(directory, changedFile) if (!filename || filename === changedFile) { - if(!fs.existsSync(filePath)) return; + if(!fs.existsSync(filePath)) return //If a cooldownId already exists, we delete it if (cooldownId !== null) { - clearTimeout(cooldownId); - cooldownId = null; + clearTimeout(cooldownId) + cooldownId = null } //Once the cooldownDelay has passed, the timeoutCallback function will be called - cooldownId = setTimeout(timeoutCallback, cooldownDelay); + cooldownId = setTimeout(timeoutCallback, cooldownDelay) } } //Manage the case where filename is missing (because it's optionnal) if (typeof cooldownDelay === 'function') { - callback = cooldownDelay; - cooldownDelay = filename; - filename = null; + callback = cooldownDelay + cooldownDelay = filename + filename = null } if (FSWatcher[name]) { - stopWatching(name); + stopWatching(name) } - FSWatcher[name] = fs.watch(directory, onWatchEvent); + FSWatcher[name] = fs.watch(directory, onWatchEvent) } /** @@ -61,8 +61,8 @@ function makeFsWatchFilter(name, directory, filename, cooldownDelay, callback) { * **/ function stopWatching(name) { - FSWatcher[name].close(); + FSWatcher[name].close() } -module.exports.makeFsWatchFilter = makeFsWatchFilter; -module.exports.stopWatching = stopWatching; +module.exports.makeFsWatchFilter = makeFsWatchFilter +module.exports.stopWatching = stopWatching diff --git a/lib/utils.js b/lib/utils.js index 56d3aae..ae19aaa 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,63 +1,63 @@ -var utils = module.exports = {}; +var utils = module.exports = {} utils.fieldsSize = function(types){ - var size = 0; + var size = 0 for(var type of types){ switch(type){ case 'postcode': size += 5 - break; + break case 'area': - size += 2; - break; + size += 2 + break default: - size += 4; - break; + size += 4 + break } } return size } utils.aton4 = function(a) { - a = a.split(/\./); - return ((parseInt(a[0], 10)<<24)>>>0) + ((parseInt(a[1], 10)<<16)>>>0) + ((parseInt(a[2], 10)<<8)>>>0) + (parseInt(a[3], 10)>>>0); -}; + a = a.split(/\./) + return ((parseInt(a[0], 10)<<24)>>>0) + ((parseInt(a[1], 10)<<16)>>>0) + ((parseInt(a[2], 10)<<8)>>>0) + (parseInt(a[3], 10)>>>0) +} utils.aton6 = function(a) { - a = a.replace(/"/g, '').split(/:/); + a = a.replace(/"/g, '').split(/:/) - var l = a.length - 1; - var i; + var l = a.length - 1 + var i - if (a[l] === '') a[l] = 0; + if (a[l] === '') a[l] = 0 if (l < 7) { - var omitted = 8 - a.length, omitStart = a.indexOf(''), omitEnd = omitStart + omitted; + var omitted = 8 - a.length, omitStart = a.indexOf(''), omitEnd = omitStart + omitted for(i = 7; i >= omitStart; i--){ - a[i] = i > omitEnd ? a[i - omitted] : 0; + a[i] = i > omitEnd ? a[i - omitted] : 0 } } - var r = 0n; + var r = 0n for (i = 0; i < 4; i++) { if(a[i]) { - r += BigInt(parseInt(a[i], 16)) << BigInt(16 * (3 - i)); + r += BigInt(parseInt(a[i], 16)) << BigInt(16 * (3 - i)) } } - return r; -}; + return r +} utils.isPrivateIP = function(addr) { - addr = addr.toString(); + addr = addr.toString() return addr.match(/^10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/) != null || addr.match(/^192\.168\.([0-9]{1,3})\.([0-9]{1,3})/) != null || addr.match(/^172\.16\.([0-9]{1,3})\.([0-9]{1,3})/) != null || addr.match(/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/) != null || addr.match(/^169\.254\.([0-9]{1,3})\.([0-9]{1,3})/) != null || - addr.match(/^fc00:/) != null || addr.match(/^fe80:/) != null; -}; + addr.match(/^fc00:/) != null || addr.match(/^fe80:/) != null +} utils.ntoa4 = function(n) { - n = n.toString(); - n = '' + (n>>>24&0xff) + '.' + (n>>>16&0xff) + '.' + (n>>>8&0xff) + '.' + (n&0xff); - return n; -}; + n = n.toString() + n = '' + (n>>>24&0xff) + '.' + (n>>>16&0xff) + '.' + (n>>>8&0xff) + '.' + (n&0xff) + return n +} diff --git a/scripts/updatedb.js b/scripts/updatedb.js index 8c291a2..f511bbc 100644 --- a/scripts/updatedb.js +++ b/scripts/updatedb.js @@ -483,7 +483,6 @@ function processCountryDataIpLocationDb(src, fileName, srcUrl, cb) { if(!datFile.write(b)){ rl.pause() } - preCC = cc } }