Prefer const over let
This commit is contained in:
@@ -35,7 +35,7 @@ files.forEach(function (file) {
|
||||
}
|
||||
|
||||
if (error) {
|
||||
let name = path.basename(file)
|
||||
const name = path.basename(file)
|
||||
console.log('%s:%d - %s:\n%s', name, i + 1, error, line)
|
||||
hasErrors = true
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ function sliceArgv (argv) {
|
||||
}
|
||||
|
||||
function processArgv (argv) {
|
||||
let torrentIds = []
|
||||
const torrentIds = []
|
||||
argv.forEach(function (arg) {
|
||||
if (arg === '-n' || arg === '-o' || arg === '-u') {
|
||||
// Critical path: Only load the 'dialog' package if it is needed
|
||||
|
||||
@@ -318,7 +318,7 @@ module.exports = class TorrentListController {
|
||||
function findFilesRecursive (paths, cb_) {
|
||||
if (paths.length > 1) {
|
||||
let numComplete = 0
|
||||
let ret = []
|
||||
const ret = []
|
||||
paths.forEach(function (path) {
|
||||
findFilesRecursive([path], function (fileObjs) {
|
||||
ret.push(...fileObjs)
|
||||
|
||||
@@ -236,7 +236,7 @@ function saveImmediate (state, cb) {
|
||||
.filter((x) => x.infoHash)
|
||||
.map(function (x) {
|
||||
const torrent = {}
|
||||
for (let key in x) {
|
||||
for (const key in x) {
|
||||
if (key === 'progress' || key === 'torrentKey') {
|
||||
continue // Don't save progress info or key for the webtorrent process
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ function getSystemInfo () {
|
||||
function getTorrentStats (state) {
|
||||
const count = state.saved.torrents.length
|
||||
let sizeMB = 0
|
||||
let byStatus = {
|
||||
const byStatus = {
|
||||
new: { count: 0, sizeMB: 0 },
|
||||
downloading: { count: 0, sizeMB: 0 },
|
||||
seeding: { count: 0, sizeMB: 0 },
|
||||
|
||||
@@ -98,7 +98,7 @@ function scoreAudioCoverFile (imgFile) {
|
||||
spectrogram: -80
|
||||
}
|
||||
|
||||
for (let keyword in relevanceScore) {
|
||||
for (const keyword in relevanceScore) {
|
||||
if (fileName === keyword) {
|
||||
return relevanceScore[keyword]
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* actually used because auto-prefixing is disabled with
|
||||
* `darkBaseTheme.userAgent = false`. Return a fake object.
|
||||
*/
|
||||
let Module = require('module')
|
||||
const Module = require('module')
|
||||
const _require = Module.prototype.require
|
||||
Module.prototype.require = function (id) {
|
||||
if (id === 'inline-style-prefixer') return {}
|
||||
|
||||
@@ -734,14 +734,14 @@ function formatTime (time, total) {
|
||||
return '0:00'
|
||||
}
|
||||
|
||||
let totalHours = Math.floor(total / 3600)
|
||||
let totalMinutes = Math.floor(total % 3600 / 60)
|
||||
let hours = Math.floor(time / 3600)
|
||||
const totalHours = Math.floor(total / 3600)
|
||||
const totalMinutes = Math.floor(total % 3600 / 60)
|
||||
const hours = Math.floor(time / 3600)
|
||||
let minutes = Math.floor(time % 3600 / 60)
|
||||
if (totalMinutes > 9) {
|
||||
minutes = zeroFill(2, minutes)
|
||||
}
|
||||
let seconds = zeroFill(2, Math.floor(time % 60))
|
||||
const seconds = zeroFill(2, Math.floor(time % 60))
|
||||
|
||||
return (totalHours > 0 ? hours + ':' : '') + minutes + ':' + seconds
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user