{"name":"@szmarczak/http-timer","version":"3.0.0","description":"Timings for HTTP requests","main":"dist","engines":{"node":">=10"},"scripts":{"test":"xo && nyc ava","build":"del-cli dist && tsc","prepublishOnly":"npm run build","coveralls":"nyc report --reporter=text-lcov | coveralls"},"keywords":["http","https","timer","timings"],"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":"^1.1.0"},"devDependencies":{"@sindresorhus/tsconfig":"^0.3.0","@types/node":"^11.13.6","@typescript-eslint/eslint-plugin":"^1.11.0","@typescript-eslint/parser":"^1.11.0","ava":"^2.1.0","coveralls":"^3.0.3","del-cli":"^1.1.0","eslint-config-xo-typescript":"^0.15.0","nyc":"^14.0.0","p-event":"^4.1.0","ts-node":"^8.1.0","typescript":"^3.4.4","xo":"^0.24.0"},"types":"dist","xo":{"extends":"xo-typescript","extensions":["ts"],"rules":{"ava/no-ignored-test-files":"off"}},"nyc":{"extension":[".ts"]},"ava":{"babel":false,"compileEnhancements":false,"extensions":["ts"],"require":["ts-node/register"]},"gitHead":"9582de3388283ac1aa5d8affa51aa1178f1bf563","_id":"@szmarczak/http-timer@3.0.0","_nodeVersion":"12.10.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-6RcMc4PnnbgOzgmtyKsZuOP4XTLOQAy0sNI9LfbjJt80jw+/7nMu54tke/ysxwQN+AsGsy488vS0UIaR++lDFQ==","shasum":"d774300886281b88c40a1fcbffb4abdbc61585d8","tarball":"http://registry-npm.ywwl.com/@szmarczak/http-timer/download/@szmarczak/http-timer-3.0.0.tgz","fileCount":6,"unpackedSize":12117,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdvbI7CRA9TVsSAnZWagAAatgP/2LV6v1IVJy8GdCPbhGB\nedLSm4Owh+F39hKOWtve9b+mwrWF7E5Q2lm7cfku5ADzKyU7cvl5y/JKufOz\nlL+7sRhPGk2+a/tLkZkTy8cwh9I9H2p3Y6BZxYzfk0qaeeYeCVbp/WaBC8b0\nqJefN+PKy8BDGBw+rQ6hVDwL0eQUoOD0RYClP97kHyIqumWHyKThNIlDUShZ\nFLCtituMAQOM/FV6y5atxvsXCf94FCZk4DppVvRieqSc9dQYu4luaZMDLEBi\nqqq6h2V6eiNkfJHAkLOqDbzMt3P1grMA/TlMZu7OK/gKqaFGoxplSbw5jQyP\n/EHsXKwDmmn6Z3MEq1PLJn8e5uieVpQh86ZSwKvk5ga+ncP/iSpFVBV5WLPk\n+kpd7lUKicNO0S1B2yZNH5irlOUXPd+icIZ71/htMsFAVfAIVPdZj8EWCnvt\n+/bdEM1FY/FZSQOh+nCx15+B6aq4QxGIckhCCv4p0E3XyyByx1sQobHpgV9q\n3hNyKW7A0qm2IkrSLEKI9r15yw6QPYclJ11lEaAb+opHzgmjzRgG2Qt0WUVd\nexwpMOTFu+jmNc2rib4fwcwweC7Xy6Ofj3QGCim1FUkMakzh6eV9tWe0BO3i\nprLy0EQmR2A5K7Ohnopz+zEJVPeXx1fWN/syA6z/O4cHHyuKXU/0yulXw5P9\nya6H\r\n=rdOK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGMB5jNjXkkzfnpjBKlAErwgWhzk7H6KsZP38lUqyXD2AiEA4bPiFdvNlYaAMt8Ezzp2fJ+u8FvtcCKYnrinl1qzbiU="}],"size":4214,"noattachment":false,"key":"/@szmarczak/http-timer/-/@szmarczak/http-timer-3.0.0.tgz"},"maintainers":[{"name":"szmarczak","email":"sz.marczak@gmail.com"}],"_npmUser":{"name":"szmarczak","email":"sz.marczak@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-timer_3.0.0_1572713019096_0.8477653922275252"},"_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":1572713019307,"_cnpm_publish_time":1572713019307,"dist-tags":{"latest":"5.0.1"}}