{"id":19443464,"url":"https://github.com/tbeseda/header-timers","last_synced_at":"2025-04-25T00:32:29.582Z","repository":{"id":204048028,"uuid":"711005941","full_name":"tbeseda/header-timers","owner":"tbeseda","description":"Server-Timing HTTP header helper","archived":false,"fork":false,"pushed_at":"2024-07-10T17:36:55.000Z","size":318,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T20:16:05.435Z","etag":null,"topics":["headers","http","nodejs","server-timing","timers"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/header-timers","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tbeseda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-28T00:14:12.000Z","updated_at":"2024-07-10T17:36:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"583cdce0-3af8-4ed9-879a-4e5039497d1a","html_url":"https://github.com/tbeseda/header-timers","commit_stats":null,"previous_names":["tbeseda/header-timers"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbeseda%2Fheader-timers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbeseda%2Fheader-timers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbeseda%2Fheader-timers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbeseda%2Fheader-timers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tbeseda","download_url":"https://codeload.github.com/tbeseda/header-timers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250733482,"owners_count":21478374,"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":["headers","http","nodejs","server-timing","timers"],"created_at":"2024-11-10T15:43:12.522Z","updated_at":"2025-04-25T00:32:29.306Z","avatar_url":"https://github.com/tbeseda.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003ccode\u003eheader-timers\u003c/code\u003e ⏱️\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eServer-Timing HTTP header helper\u003c/strong\u003e\u003cbr\u003e\n  Create timers and report to the browser with a \u003ccode\u003eServer-Timing\u003c/code\u003e header.\u003cbr\u003e\n  \u003ca href=\"https://www.npmjs.com/package/header-timers\"\u003e\u003cstrong\u003e\u003ccode\u003eheader-timers\u003c/code\u003e on npmjs.org »\u003c/strong\u003e\u003c/a\u003e\u003cbr\u003e\n  \u003cbr\u003e\n  Contents:\n  \u003ca href=\"#Install\"\u003eInstall\u003c/a\u003e\n  •\n  \u003ca href=\"#Usage\"\u003eUsage\u003c/a\u003e\n  •\n  \u003ca href=\"#Goals\"\u003eGoals\u003c/a\u003e\n  •\n  \u003ca href=\"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing\"\u003e\u003ccode\u003eServer-Timing\u003c/code\u003e Reference\u003c/a\u003e\n\u003c/p\u003e\n\n## Install\n\n```sh\nnpm i header-timers\n```\n\n\u003e [!NOTE]  \n\u003e This is a Node.js library and won't work in a browser runtime.\n\n## Usage\n\nJust .js samples for now:\n\n```js\nimport HeaderTimers from 'header-timers'\n\nconst timers = HeaderTimers()\nconst { start, stop } = timers\n\nstart('open')\nstop('open')\n\nstart('database', 'collecting data') // with a description\n\nstart('analytics', 'log request data')\nawait new Promise(resolve =\u003e setTimeout(resolve, 100))\nstop('analytics')\n\nawait new Promise(resolve =\u003e setTimeout(resolve, 500))\nstop('database')\n\nconsole.log('TIMER COUNT', timers.timers().length) // 3\n\nconsole.log(timers.key)\n// \"Server-Timing\" - just in case you need it!\nconsole.log(timers.timers())\n// [ Array of Timer Objects ]\nconsole.log(timers.values())\n/**\n [\n   'open;dur=0.026ms',\n   'database;desc=\"collecting data\";dur=603.098792ms',\n   'analytics;desc=\"log request data\";dur=101.776917ms'\n ]\n*/\nconsole.log(timers.value()) \n// \"open;dur=0.014ms, database;desc=\"collecting data\";dur=603.512ms, analytics;desc=\"log request data\";dur=101.475709ms\"\nconsole.log(timers.string())\n// \"Server-Timing: open;dur=0.014ms, database;desc=\"collecting data\";dur=603.512ms, analytics;desc=\"log request data\";dur=101.475709ms\"\nconsole.log(timers.object())\n/**\n {\n   'Server-Timing': 'open;dur=0.026ms, database;desc=\"collecting data\";dur=603.098792ms, analytics;desc=\"log request data\";dur=101.776917ms'\n }\n*/\n```\n\nAlso...\n\n```js\n// ...\n\nstart(\"this won't work\")\ntimers.reset()\nstop(\"this won't work\")\n\nconsole.log('TIMER COUNT', timers.timers().length) // 0\n\nstart('reset')\nawait new Promise(resolve =\u003e setTimeout(resolve, 100))\nstop('reset')\n\nconsole.log('TIMER COUNT', timers.timers().length) // 1\n\nconsole.log('NEW Header String', timers.string())\n// NEW Header String \"Server-Timing: reset;dur=101.799166ms\"\n```\n\nAnd...\n\n```js\n// names optional; be aware of the order, though!\nstart() // 1\nstop()  // stop 1 =\u003e \u003c1ms\n\nstart() // 2\nstart('foo')\nstart() // 3\n\nstop() // stop 3 =\u003e \u003c1ms\n\nawait new Promise(resolve =\u003e setTimeout(resolve, 100))\n\nstop() // stop 2 =\u003e 100+ms\nstop('foo') // =\u003e 100+ms\n```\n\n## Goals\n\nBe helpful and accurate. Stay small and fast. Then be intuitive. This means:\n\n- zero dependencies\n- measure in nanoseconds\n- option to disable\n- fast primitives/operations (this needs review)\n  - no Classes\n- terse but readable API\n\n---\n\n_\"It's just strings all the way down\"_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbeseda%2Fheader-timers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbeseda%2Fheader-timers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbeseda%2Fheader-timers/lists"}