Skip to content

Commit

Permalink
[CodeFactor] Apply fixes to commit 0f09c3a
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
code-factor authored and JiPaix committed Jun 16, 2024
1 parent 719eb5d commit 5c64881
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions tests/lib.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import 'dotenv/config';
import XDCC from '../src'
import { env } from 'process'
import { env } from 'process';
import XDCC from '../src';

const xdccJS = new XDCC({
host: env.SERVER,
})

});

function msToReadableTime(ms: number) {
const seconds = Math.floor(ms / 1000);
Expand All @@ -28,15 +27,14 @@ function msToReadableTime(ms: number) {
return readableString;
}


xdccJS.on('ready', ()=> {
xdccJS.download(env.BOT, env.PACK)
xdccJS.on('ready', () => {
xdccJS.download(env.BOT, env.PACK);
let lastTime = Date.now();
xdccJS.on('downloading', (fileinfo, received, percentage, eta) => {
if(lastTime + 500 < Date.now()) {
lastTime = Date.now()
console.log(`Downloading ${fileinfo.file} - ${received}/${fileinfo.length} - (${percentage}%) @ETA (${msToReadableTime(eta)})`)
if (lastTime + 500 < Date.now()) {
lastTime = Date.now();
console.log(`Downloading ${fileinfo.file} - ${received}/${fileinfo.length} - (${percentage}%) @ETA (${msToReadableTime(eta)})`);
}
})
});
xdccJS.on('done', () => console.log('done'));
})
});

0 comments on commit 5c64881

Please sign in to comment.