{"id":17013755,"url":"https://github.com/dnlup/hrtime-utils","last_synced_at":"2025-03-22T16:31:07.616Z","repository":{"id":37093593,"uuid":"250242933","full_name":"dnlup/hrtime-utils","owner":"dnlup","description":"A small collection of useful functions to work with Node.js `process.hrtime` values","archived":false,"fork":false,"pushed_at":"2023-01-16T11:02:53.000Z","size":894,"stargazers_count":2,"open_issues_count":18,"forks_count":0,"subscribers_count":2,"default_branch":"next","last_synced_at":"2025-03-17T22:08:15.831Z","etag":null,"topics":["hrtime","hrtime-utils","node","nodejs","process"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnlup.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["dnlup"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-03-26T11:42:59.000Z","updated_at":"2024-03-10T09:30:15.000Z","dependencies_parsed_at":"2023-02-10T02:40:18.551Z","dependency_job_id":null,"html_url":"https://github.com/dnlup/hrtime-utils","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnlup%2Fhrtime-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnlup%2Fhrtime-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnlup%2Fhrtime-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnlup%2Fhrtime-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnlup","download_url":"https://codeload.github.com/dnlup/hrtime-utils/tar.gz/refs/heads/next","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244986498,"owners_count":20543023,"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":["hrtime","hrtime-utils","node","nodejs","process"],"created_at":"2024-10-14T06:14:07.531Z","updated_at":"2025-03-22T16:31:07.194Z","avatar_url":"https://github.com/dnlup.png","language":"JavaScript","funding_links":["https://github.com/sponsors/dnlup"],"categories":[],"sub_categories":[],"readme":"# hrtime-utils\n[![npm version](https://badge.fury.io/js/%40dnlup%2Fhrtime-utils.svg)](https://badge.fury.io/js/%40dnlup%2Fhrtime-utils)\n![Tests](https://github.com/dnlup/hrtime-utils/workflows/Tests/badge.svg)\n[![codecov](https://codecov.io/gh/dnlup/hrtime-utils/branch/next/graph/badge.svg?token=EB373JDPDU)](https://codecov.io/gh/dnlup/hrtime-utils)\n[![Known Vulnerabilities](https://snyk.io/test/github/dnlup/hrtime-utils/badge.svg?targetFile=package.json)](https://snyk.io/test/github/dnlup/hrtime-utils?targetFile=package.json)\n\n\u003e A small collection of useful functions to work with Node.js [`process.hrtime`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_process_hrtime_time)  values.\n\n`hrtime-utils` is a tiny module that exports a few useful functions that you can use to convert the value returned from `process.hrtime()` to a time unit.\n\n\u003c!-- toc --\u003e\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n  * [hrtime2ns(time)](#hrtime2nstime)\n  * [hrtime2us(time)](#hrtime2ustime)\n  * [hrtime2ms(time)](#hrtime2mstime)\n  * [hrtime2s(time)](#hrtime2stime)\n\n\u003c!-- tocstop --\u003e\n\n## Installation\n\n```bash\n$ npm i @dnlup/hrtime-utils\n````\n\n## Usage\n\n```js\nconst {\n  hrtime2ns,\n  hrtime2us,\n  hrtime2ms,\n  hrtime2\n} = require('@dnlup/hrtime-utils')\n\nconst time = process.hrtime()\n\nhrtime2ns(time) // time in nanoseconds\nhrtime2us(time) // time in microseconds\nhrtime2ms(time) // time in milliseconds\nhrtime2s(time) // time in seconds\n\nconst delta = process.hrtime(time)\n\nhrtime2ns(delta) // delta in nanoseconds\nhrtime2us(delta) // delta in microseconds\nhrtime2ms(delta) // delta in milliseconds\nhrtime2s(delta) // delta in seconds\n```\n\n## API\n\n### hrtime2ns(time)\n\n* `time` `\u003cinteger[]`\u003e The return value of a [`process.hrtime()`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_process_hrtime_time) call\n\n* Returns `\u003cnumber\u003e`\n\nThis function converts `time` to nanoseconds.\n\n### hrtime2us(time)\n\n* `time` `\u003cinteger[]`\u003e The return value of a [`process.hrtime()`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_process_hrtime_time) call\n\n* Returns `\u003cnumber\u003e`\n\nThis function converts `time` to microseconds.\n\n### hrtime2ms(time)\n\n* `time` `\u003cinteger[]`\u003e The return value of a [`process.hrtime()`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_process_hrtime_time) call\n\n* Returns `\u003cnumber\u003e`\n\nThis function converts `time` to milliseconds.\n\n### hrtime2s(time)\n\n* `time` `\u003cinteger[]`\u003e The return value of a [`process.hrtime()`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_process_hrtime_time) call\n\n* Returns `\u003cnumber\u003e`\n\nThis function converts `time` to seconds.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnlup%2Fhrtime-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnlup%2Fhrtime-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnlup%2Fhrtime-utils/lists"}