Skip to content

Commit dfde05a

Browse files
committed
Add documentation for the async methods
1 parent e3cbff1 commit dfde05a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
[![NPM version](https://img.shields.io/npm/v/https-timer.svg?style=flat-square)](https://www.npmjs.com/package/https-timer)
66
[![Build status](https://img.shields.io/travis/JoshCrozier/https-timer.svg?style=flat-square)](https://travis-ci.org/JoshCrozier/https-timer)
77
[![Coverage](https://img.shields.io/codecov/c/github/JoshCrozier/https-timer.svg?style=flat-square)](https://codecov.io/github/JoshCrozier/https-timer)
8-
[![Dependencies](https://img.shields.io/david/JoshCrozier/https-timer.svg?style=flat-square)](https://david-dm.org/JoshCrozier/https-timer)
9-
[![DevDependencies](https://david-dm.org/JoshCrozier/https-timer/dev-status.svg?style=flat-square)](https://david-dm.org/JoshCrozier/https-timer?type=dev)
108
[![Vulnerabilities](https://snyk.io/test/npm/https-timer/badge.svg?style=flat-square)](https://snyk.io/test/npm/https-timer)
119

1210
A lightweight, dependency-free [Node.js]((https://nodejs.org)) module for timing HTTP/HTTPS requests.
@@ -20,6 +18,8 @@ Useful for determining the duration of different HTTPS phases:
2018
- Time to First Byte
2119
- Content Transfer
2220

21+
Used on [PingMe.io](https://pingme.io/) for testing website latency.
22+
2323
## Installation
2424

2525
$ npm install https-timer --save
@@ -78,6 +78,27 @@ httpsTimer.get(options, (error, response) => {
7878
});
7979
```
8080

81+
## Promises and Async/Await
82+
83+
The `get`/`request` methods also have async equivalents: `getAsync`/`requestAsync`:
84+
85+
86+
Promise usage:
87+
88+
```js
89+
httpsTimer.getAsync('https://www.google.com').then(response => {
90+
console.log(response.timing);
91+
});
92+
```
93+
94+
Async/Await usage:
95+
96+
```js
97+
const response = await httpsTimer.getAsync('https://www.google.com');
98+
console.log(response.timing);
99+
```
100+
101+
For more detailed examples with error handling, see the [examples directory](https://github.com/JoshCrozier/https-timer/tree/master/examples).
81102

82103
## License
83104

0 commit comments

Comments
 (0)