Installations
npm install @szmarczak/http-timer
Developer
szmarczak
Developer Guide
Module System
ESM
Min. Node Version
>=14.16
Typescript Support
Yes
Node Version
16.6.2
NPM Version
7.20.3
Statistics
192 Stars
49 Commits
18 Forks
4 Watching
1 Branches
4 Contributors
Updated on 09 Oct 2024
Languages
TypeScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
2,890,877,597
Last day
0.1%
3,289,129
Compared to previous day
Last week
4.9%
17,816,802
Compared to previous week
Last month
11.8%
71,693,823
Compared to previous month
Last year
9.4%
755,333,065
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
http-timer
Timings for HTTP requests
Inspired by the request
package.
Installation
NPM:
npm install @szmarczak/http-timer
Yarn:
yarn add @szmarczak/http-timer
Usage
Note:
- The measured events resemble Node.js events, not the kernel ones.
- Sending a chunk greater than
highWaterMark
will result in invalidupload
andresponse
timings. You can avoid this by splitting the payload into smaller chunks.
1import https from 'https'; 2import timer from '@szmarczak/http-timer'; 3 4const request = https.get('https://httpbin.org/anything'); 5timer(request); 6 7request.once('response', response => { 8 response.resume(); 9 response.once('end', () => { 10 console.log(response.timings); // You can use `request.timings` as well 11 }); 12}); 13 14// { 15// start: 1572712180361, 16// socket: 1572712180362, 17// lookup: 1572712180415, 18// connect: 1572712180571, 19// upload: 1572712180884, 20// response: 1572712181037, 21// end: 1572712181039, 22// error: undefined, 23// abort: undefined, 24// phases: { 25// wait: 1, 26// dns: 53, 27// tcp: 156, 28// request: 313, 29// firstByte: 153, 30// download: 2, 31// total: 678 32// } 33// }
API
timer(request)
Returns: Object
Note: The time is a number
representing the milliseconds elapsed since the UNIX epoch.
start
- Time when the request started.socket
- Time when a socket was assigned to the request.lookup
- Time when the DNS lookup finished.connect
- Time when the socket successfully connected.secureConnect
- Time when the socket securely connected.upload
- Time when the request finished uploading.response
- Time when the request firedresponse
event.end
- Time when the response firedend
event.error
- Time when the request firederror
event.abort
- Time when the request firedabort
event.phases
wait
-timings.socket - timings.start
dns
-timings.lookup - timings.socket
tcp
-timings.connect - timings.lookup
tls
-timings.secureConnect - timings.connect
request
-timings.upload - (timings.secureConnect || timings.connect)
firstByte
-timings.response - timings.upload
download
-timings.end - timings.response
total
-(timings.end || timings.error || timings.abort) - timings.start
If something has not been measured yet, it will be undefined
.
License
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Score
3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More