Updated the provider parser

This commit is contained in:
Mathias Wagner
2024-05-21 14:31:44 +02:00
parent 078c3be2dd
commit e18961eb6c
+8 -7
View File
@@ -1,19 +1,20 @@
const roundSpeed = (bytes, elapsed) => {
return Math.round((bytes * 8 / elapsed) / 10) / 100;
const roundSpeed = (bandwidth) => {
return Math.round(bandwidth / 1250) / 100;
}
module.exports.parseOokla = (test) => {
let ping = Math.round(test.ping.latency);
let download = roundSpeed(test.download.bytes, test.download.elapsed);
let upload = roundSpeed(test.upload.bytes, test.upload.elapsed);
let download = roundSpeed(test.download.bandwidth);
let upload = roundSpeed(test.upload.bandwidth);
let time = Math.round((test.download.elapsed + test.upload.elapsed) / 1000);
return {ping, download, upload, time};
return {ping, download, upload, time, resultId: test.result.id};
}
module.exports.parseLibre = (test) => ({...test, time: Math.round(test.elapsed / 1000)});
module.exports.parseLibre = (test) => ({...test, ping: Math.round(test.ping), time: Math.round(test.elapsed / 1000),
resultId: null});
module.exports.parseCloudflare = (test) => ({...test, time: Math.round(test.elapsed)});
module.exports.parseCloudflare = (test) => ({...test, time: Math.round(test.elapsed), resultId: null});
module.exports.parseData = (provider, data) => {
switch (provider) {