{"name":"@szmarczak/http-timer","version":"5.0.1","description":"Timings for HTTP requests","type":"module","exports":"./dist/source/index.js","engines":{"node":">=14.16"},"scripts":{"test":"xo && ava","build":"del-cli dist && tsc","prepare":"npm run build","coveralls":"exit 0 && nyc report --reporter=text-lcov | coveralls"},"keywords":["http","https","http2","timer","timings","performance","measure"],"repository":{"type":"git","url":"git+https://github.com/szmarczak/http-timer.git"},"author":{"name":"Szymon Marczak"},"license":"MIT","bugs":{"url":"https://github.com/szmarczak/http-timer/issues"},"homepage":"https://github.com/szmarczak/http-timer#readme","dependencies":{"defer-to-connect":"^2.0.1"},"devDependencies":{"@ava/typescript":"^2.0.0","@sindresorhus/tsconfig":"^1.0.2","@types/node":"^16.7.0","ava":"^3.15.0","coveralls":"^3.1.1","del-cli":"^4.0.1","http2-wrapper":"^2.1.4","nyc":"^15.1.0","p-event":"^4.2.0","ts-node":"^10.2.1","typescript":"^4.3.5","xo":"^0.44.0"},"types":"dist/source","nyc":{"extension":[".ts"],"exclude":["**/tests/**"]},"xo":{"rules":{"@typescript-eslint/no-non-null-assertion":"off","@typescript-eslint/no-unsafe-assignment":"off","@typescript-eslint/no-unsafe-member-access":"off","@typescript-eslint/no-unsafe-call":"off","unicorn/prefer-node-protocol":"off"}},"ava":{"files":["tests/*"],"timeout":"1m","nonSemVerExperiments":{"nextGenConfig":true,"configurableModuleFormat":true},"extensions":{"ts":"module"},"nodeArguments":["--loader=ts-node/esm"]},"gitHead":"b8dabf9bbd64c71ed702064bb78123a70e7c069c","_id":"@szmarczak/http-timer@5.0.1","_nodeVersion":"16.6.2","_npmVersion":"7.20.3","dist":{"integrity":"sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==","shasum":"c7c1bf1141cdd4751b0399c8fc7b8b664cd5be3a","tarball":"http://registry-npm.ywwl.com/@szmarczak/http-timer/download/@szmarczak/http-timer-5.0.1.tgz","fileCount":5,"unpackedSize":10201,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhIDoTCRA9TVsSAnZWagAAU/cP/0QBOlcsqItX4c6nHGYU\nze3dEQQ8h8Ba7gACmLCaG3v7bPiOI6juOpTQW//XbD/DeS4/cS13a3c79nmm\n93C51pTqv/p/oD415wprzQgvz21df8JjzbecMFJUsubLtRLfgBrmxVfKM9gZ\nLs+RLQgErGkOu6mQr06bm1xLgcA0YZehXh/eyy+Y6i8xutAhWLwySecn7sQd\ndD82IamzYUtyFiSV3N8IslOu7GPzlP5GD7VPGL0Wi5MD/jXqMZ8Px8FVOGvQ\nAU0QGECmdpy74qjxjH2mLNJTzi7KDHOc9PJLRg3srY3zbb+OBp7tVbsEX4xx\nk4z6G8I8MkwtFsTpnO4BOIQQ/gatG5gO89/RlSj3dvuSvQn1cy5Us95ysCQw\n17ikf1k/hH1fYFHuYJ5FeKiILXbz93jFw04Q5WIFi0hqVpE86StfPBtM2+TV\nWSP7BSluURnrIfvsr3w8Sz5bhMRRjPRT5HO6Sic+jOIdjvKqBwiznfWxoYug\nOCbCsmOydsdLMX2HuVCE+ZK17boFumQ5SUkZxDhfweqsxD0AAAUM7nTvdqVV\n7VfBKR8Uu7w1Kt2xb1YWrk55j2ymyHbCfZSQuRHnUt8N/tNgOfOmkXOQs3pR\nM+YBPVcBBuBg4nnmCXI6RIqzMcrj6C3Ul8SeFXGnyjYrXUdrZOkS4S/nqMLM\n7y2w\r\n=yOTC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDFDGBWP+OMcGhqusm8h0a3macaIZYYYX6LhEBaT3PjtAiEA4zKtJCOig0UzeZrw4q2RshtM6Gh65tuiJE/V/5lpAwU="}],"size":3663,"noattachment":false,"key":"/@szmarczak/http-timer/-/@szmarczak/http-timer-5.0.1.tgz"},"_npmUser":{"name":"szmarczak","email":"sz.marczak@gmail.com"},"directories":{},"maintainers":[{"name":"szmarczak","email":"sz.marczak@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-timer_5.0.1_1629501971094_0.9473692551089752"},"_hasShrinkwrap":false,"readme":"# http-timer\n> Timings for HTTP requests\n\n[![Build Status](https://travis-ci.org/szmarczak/http-timer.svg?branch=master)](https://travis-ci.org/szmarczak/http-timer)\n[![Coverage Status](https://coveralls.io/repos/github/szmarczak/http-timer/badge.svg?branch=master)](https://coveralls.io/github/szmarczak/http-timer?branch=master)\n[![install size](https://packagephobia.now.sh/badge?p=@szmarczak/http-timer)](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)\n\nInspired by the [`request` package](https://github.com/request/request).\n\n## Installation\n\nNPM:\n\n> `npm install @szmarczak/http-timer`\n\nYarn:\n\n> `yarn add @szmarczak/http-timer`\n\n## Usage\n**Note:**\n> - The measured events resemble Node.js events, not the kernel ones.\n> - Sending a chunk greater than [`highWaterMark`](https://nodejs.org/api/stream.html#stream_new_stream_writable_options) will result in invalid `upload` and `response` timings. You can avoid this by splitting the payload into smaller chunks.\n\n```js\nimport https from 'https';\nimport timer from '@szmarczak/http-timer';\n\nconst request = https.get('https://httpbin.org/anything');\ntimer(request);\n\nrequest.once('response', response => {\n\tresponse.resume();\n\tresponse.once('end', () => {\n\t\tconsole.log(response.timings); // You can use `request.timings` as well\n\t});\n});\n\n// {\n//   start: 1572712180361,\n//   socket: 1572712180362,\n//   lookup: 1572712180415,\n//   connect: 1572712180571,\n//   upload: 1572712180884,\n//   response: 1572712181037,\n//   end: 1572712181039,\n//   error: undefined,\n//   abort: undefined,\n//   phases: {\n//     wait: 1,\n//     dns: 53,\n//     tcp: 156,\n//     request: 313,\n//     firstByte: 153,\n//     download: 2,\n//     total: 678\n//   }\n// }\n```\n\n## API\n\n### timer(request)\n\nReturns: `Object`\n\n**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.\n\n- `start` - Time when the request started.\n- `socket` - Time when a socket was assigned to the request.\n- `lookup` - Time when the DNS lookup finished.\n- `connect` - Time when the socket successfully connected.\n- `secureConnect` - Time when the socket securely connected.\n- `upload` - Time when the request finished uploading.\n- `response` - Time when the request fired `response` event.\n- `end` - Time when the response fired `end` event.\n- `error` - Time when the request fired `error` event.\n- `abort` - Time when the request fired `abort` event.\n- `phases`\n\t- `wait` - `timings.socket - timings.start`\n\t- `dns` - `timings.lookup - timings.socket`\n\t- `tcp` - `timings.connect - timings.lookup`\n\t- `tls` - `timings.secureConnect - timings.connect`\n\t- `request` - `timings.upload - (timings.secureConnect || timings.connect)`\n\t- `firstByte` - `timings.response - timings.upload`\n\t- `download` - `timings.end - timings.response`\n\t- `total` - `(timings.end || timings.error || timings.abort) - timings.start`\n\nIf something has not been measured yet, it will be `undefined`.\n\n## License\n\nMIT\n","publish_time":1629501971251,"_cnpm_publish_time":1629501971251,"dist-tags":{"latest":"5.0.1"}}