Skip to content

Commit

Permalink
🪲 Bug: Fixed displayspeed classes
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrtnx committed Jan 15, 2024
1 parent f30b21c commit caadb03
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 51 deletions.
6 changes: 3 additions & 3 deletions dist/cjs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ declare class InternetSpeedChecker {
private convertSpeed;
private measureDownloadSpeed;
private measureUploadSpeed;
startSpeedCheck(): void;
private displaySpeeds;
getFormattedDownloadSpeed(): string;
getFormattedUploadSpeed(): string;
startSpeedCheck(): void;
}
export default InternetSpeedChecker;
declare const speedChecker: InternetSpeedChecker;
export default speedChecker;
23 changes: 9 additions & 14 deletions dist/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,21 @@ class InternetSpeedChecker {
}
}
}
startSpeedCheck() {
setInterval(() => {
this.measureDownloadSpeed();
this.measureUploadSpeed();
this.displaySpeeds();
}, 1000);
}
displaySpeeds() {
const formattedDownloadSpeed = `${this.convertSpeed(this.downloadSpeed).value.toFixed(2)} ${this.convertSpeed(this.downloadSpeed).unit}`;
const formattedUploadSpeed = `${this.convertSpeed(this.uploadSpeed).value.toFixed(2)} ${this.convertSpeed(this.uploadSpeed).unit}`;
console.log(`Download Speed: ${formattedDownloadSpeed}`);
console.log(`Upload Speed: ${formattedUploadSpeed}`);
}
getFormattedDownloadSpeed() {
return `${this.convertSpeed(this.downloadSpeed).value.toFixed(2)} ${this.convertSpeed(this.downloadSpeed).unit}`;
}
getFormattedUploadSpeed() {
return `${this.convertSpeed(this.uploadSpeed).value.toFixed(2)} ${this.convertSpeed(this.uploadSpeed).unit}`;
}
startSpeedCheck() {
setInterval(() => {
this.measureDownloadSpeed();
this.measureUploadSpeed();
this.getFormattedDownloadSpeed();
this.getFormattedUploadSpeed();
}, 1000);
}
}
const speedChecker = new InternetSpeedChecker();
speedChecker.startSpeedCheck();
exports.default = InternetSpeedChecker;
exports.default = speedChecker;
6 changes: 3 additions & 3 deletions dist/esm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ declare class InternetSpeedChecker {
private convertSpeed;
private measureDownloadSpeed;
private measureUploadSpeed;
startSpeedCheck(): void;
private displaySpeeds;
getFormattedDownloadSpeed(): string;
getFormattedUploadSpeed(): string;
startSpeedCheck(): void;
}
export default InternetSpeedChecker;
declare const speedChecker: InternetSpeedChecker;
export default speedChecker;
23 changes: 9 additions & 14 deletions dist/esm/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,21 @@ class InternetSpeedChecker {
}
}
}
startSpeedCheck() {
setInterval(() => {
this.measureDownloadSpeed();
this.measureUploadSpeed();
this.displaySpeeds();
}, 1000);
}
displaySpeeds() {
const formattedDownloadSpeed = `${this.convertSpeed(this.downloadSpeed).value.toFixed(2)} ${this.convertSpeed(this.downloadSpeed).unit}`;
const formattedUploadSpeed = `${this.convertSpeed(this.uploadSpeed).value.toFixed(2)} ${this.convertSpeed(this.uploadSpeed).unit}`;
console.log(`Download Speed: ${formattedDownloadSpeed}`);
console.log(`Upload Speed: ${formattedUploadSpeed}`);
}
getFormattedDownloadSpeed() {
return `${this.convertSpeed(this.downloadSpeed).value.toFixed(2)} ${this.convertSpeed(this.downloadSpeed).unit}`;
}
getFormattedUploadSpeed() {
return `${this.convertSpeed(this.uploadSpeed).value.toFixed(2)} ${this.convertSpeed(this.uploadSpeed).unit}`;
}
startSpeedCheck() {
setInterval(() => {
this.measureDownloadSpeed();
this.measureUploadSpeed();
this.getFormattedDownloadSpeed();
this.getFormattedUploadSpeed();
}, 1000);
}
}
const speedChecker = new InternetSpeedChecker();
speedChecker.startSpeedCheck();
export default InternetSpeedChecker;
export default speedChecker;
Binary file removed dist/internetSpeedCheckerCjs.zip
Binary file not shown.
Binary file removed dist/internetSpeedCheckerEsm.zip
Binary file not shown.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
"version": "0.1.0",
"description": "Check internet upload and download speed in real-time",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/esm/index.mjs",
"exports": {
".": {
"import": "./dist/esm/index.mjs",
"require": "./dist/cjs/index.js"
}
},
"scripts": {
"start": "npm run prompt:module",
"prompt:module": "node -e \"require('./scripts/module-prompt')\"",
Expand Down
27 changes: 10 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,25 @@ class InternetSpeedChecker {
}
}

public startSpeedCheck(): void {
setInterval(() => {
this.measureDownloadSpeed();
this.measureUploadSpeed();
this.displaySpeeds();
}, 1000);
}

private displaySpeeds(): void {
const formattedDownloadSpeed = `${this.convertSpeed(this.downloadSpeed).value.toFixed(2)} ${this.convertSpeed(this.downloadSpeed).unit}`;
const formattedUploadSpeed = `${this.convertSpeed(this.uploadSpeed).value.toFixed(2)} ${this.convertSpeed(this.uploadSpeed).unit}`;

console.log(`Download Speed: ${formattedDownloadSpeed}`);
console.log(`Upload Speed: ${formattedUploadSpeed}`);
}

public getFormattedDownloadSpeed(): string {
return `${this.convertSpeed(this.downloadSpeed).value.toFixed(2)} ${this.convertSpeed(this.downloadSpeed).unit}`;
}

public getFormattedUploadSpeed(): string {
return `${this.convertSpeed(this.uploadSpeed).value.toFixed(2)} ${this.convertSpeed(this.uploadSpeed).unit}`;
}

public startSpeedCheck(): void {
setInterval(() => {
this.measureDownloadSpeed();
this.measureUploadSpeed();
this.getFormattedDownloadSpeed();
this.getFormattedUploadSpeed();
}, 1000);
}
}

const speedChecker = new InternetSpeedChecker();
speedChecker.startSpeedCheck();

export default InternetSpeedChecker;
export default speedChecker;

0 comments on commit caadb03

Please sign in to comment.