Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boennemann/http-request-timings
https://github.com/boennemann/http-request-timings
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/boennemann/http-request-timings
- Owner: boennemann
- Created: 2015-07-20T16:13:52.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-26T02:38:57.000Z (about 8 years ago)
- Last Synced: 2024-11-18T16:24:30.399Z (about 1 month ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# http-request-timings
[![Build Status](https://travis-ci.org/boennemann/http-request-timings.svg?branch=master)](https://travis-ci.org/boennemann/http-request-timings)
[![Coverage Status](https://coveralls.io/repos/boennemann/http-request-timings/badge.svg?branch=master&service=github)](https://coveralls.io/github/boennemann/http-request-timings?branch=master)
[![Dependency Status](https://david-dm.org/boennemann/http-request-timings/master.svg)](https://david-dm.org/boennemann/http-request-timings/master)
[![devDependency Status](https://david-dm.org/boennemann/http-request-timings/master/dev-status.svg)](https://david-dm.org/boennemann/http-request-timings/master#info=devDependencies)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)[![NPM](https://nodei.co/npm/http-request-timings.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/http-request-timings/)
This module monkey-patches the `http.request` method – which is used internally by `http.get`, `https.request`, `https.get` and therefor any library like `request` – to record timings.
_Note:_ The core `https` module isn't patched on node <=0.10. This will be addressed in a future version.
```bash
npm install -S http-request-timings
``````js
var http = require('http')var timings = require('http-request-timings')
// monkey-patch http.request
timings.start()timings.on('timing', function (timing, options, res) {
timing.start // Date
timing.firstByte // Date
timing.end // Datetiming.timeToFirstByte // duration in ms
timing.timeToEnd // duration in ms// options passed to http.request
// if it was originally a string then it's `url.parse`d
options// the response
res
})http.get('http://example.com/', function (res) {
// …
res.on('data', doStuff)// go back to default http.request
timings.stop()
})
```