4.6.0 • Published 4 years ago
responsetimejs v4.6.0
responsetimejs
An npm package which gets the response time for a website on different servers using puppeteer and bitcatcha website.
Addendum:
Note that this program opens a headless chrome web page to manually get the website responsetime, so depending on your connection speed this can last a few seconds. Also from the release v4.5.7 there has been a major update (fix of error returning wrong response time and two new servers) you can check it out here -> changelog.
Installation
With node.js:
npm install responsetimejs
With yarn:
yarn add responsetimejs
How to use?
Example usage:
const res = require("responsetimejs");
const myRequest = new res("https://www.google.com");
//or a more complete instantiation
const myRequest = new res({
url: "https://www.google.com",
server: "uk",
msg: false,
num: false
});
myRequest.get().then(result => {
console.log(result); //example log: ['104ms','A+']
});
Docs:
Properties:
property | type | default value | description |
---|---|---|---|
url | [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | null | url of the website to send the request to. |
server | [string](https://developer.mozilla.org/en-US/docs/) | uk | selects which server to send the request from. |
msg | [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) | false | whether to display a custom message in the console after receiving the data. |
num | [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) | false | whether to return the time as a number in milliseconds 104 or as a string 104ms . |
Available Servers (use the keywords):
- use(US east)
- usw(US west)
- uk(London)
- sg(Singapore)
- br(Sao Paulo)
- in(Bangalore)
- au(Sydney)
- jp(Japan)
- ca(Toronto)
- de(Germany)
Methods:
- Object.get()
- returns: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/)>> returns the response time aswell as the rating of the response (and a custom message if
msg
is true). Can use array indexing to get specific result:
myRequest.get().then(result => console.log(result[0]);//example: prints ['21ms'])
- returns: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/)>> returns the response time aswell as the rating of the response (and a custom message if
How does it work?
You can read more of the process behind the scenes here How it works.
Credits
Made with ❤ by AlexSimpler. 2020