{"id":13448554,"url":"https://github.com/szmarczak/http-timer","last_synced_at":"2025-04-08T13:07:15.612Z","repository":{"id":57164183,"uuid":"146032789","full_name":"szmarczak/http-timer","owner":"szmarczak","description":"🕐 Performance timings for HTTP requests","archived":false,"fork":false,"pushed_at":"2021-08-20T23:26:47.000Z","size":51,"stargazers_count":192,"open_issues_count":6,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T13:07:00.955Z","etag":null,"topics":["http","https","nodejs","timer","timings"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szmarczak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-24T19:39:03.000Z","updated_at":"2024-10-09T04:57:02.000Z","dependencies_parsed_at":"2022-09-04T02:51:16.624Z","dependency_job_id":null,"html_url":"https://github.com/szmarczak/http-timer","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szmarczak%2Fhttp-timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szmarczak%2Fhttp-timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szmarczak%2Fhttp-timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szmarczak%2Fhttp-timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szmarczak","download_url":"https://codeload.github.com/szmarczak/http-timer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247375111,"owners_count":20928951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","https","nodejs","timer","timings"],"created_at":"2024-07-31T05:01:48.878Z","updated_at":"2025-04-08T13:07:15.590Z","avatar_url":"https://github.com/szmarczak.png","language":"TypeScript","readme":"# http-timer\n\u003e 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\u003e `npm install @szmarczak/http-timer`\n\nYarn:\n\n\u003e `yarn add @szmarczak/http-timer`\n\n## Usage\n**Note:**\n\u003e - The measured events resemble Node.js events, not the kernel ones.\n\u003e - 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 =\u003e {\n\tresponse.resume();\n\tresponse.once('end', () =\u003e {\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","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszmarczak%2Fhttp-timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszmarczak%2Fhttp-timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszmarczak%2Fhttp-timer/lists"}