simple-url-speedtest
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "simple-url-speedtest", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -40,13 +40,22 @@ # simple-url-speedtest | ||
/** | ||
* Data arrays response will be in this format | ||
* | ||
* { | ||
* url: string | ||
* ping: number // In milliseconds | ||
* } | ||
* | ||
*/ | ||
// Data can be access using function callback method | ||
SpeedTest(urlList, (data) => { | ||
/** | ||
* Data response will be in this format | ||
* { | ||
* url: string | ||
* ping: number //in milliseconds | ||
* } | ||
*/ | ||
console.log(data) | ||
}); | ||
// or using Promise callback method | ||
SpeedTest(urlList).then(data => { | ||
console.log(data) | ||
}); | ||
``` |
@@ -19,7 +19,9 @@ const calculateSpeed = (url) => { | ||
export default (urlArr, callback) => { | ||
const testQueue = urlArr.map((url) => calculateSpeed(url)); | ||
Promise.all(testQueue).then((data) => { | ||
callback(data); | ||
}); | ||
if (callback) { | ||
Promise.all(urlArr.map(calculateSpeed)).then((data) => { | ||
callback(data); | ||
}); | ||
} else { | ||
return Promise.all(urlArr.map(calculateSpeed)); | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3208
41
61