Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dnlup/hrtime-utils
A small collection of useful functions to work with Node.js `process.hrtime` values
https://github.com/dnlup/hrtime-utils
hrtime hrtime-utils node nodejs process
Last synced: 17 days ago
JSON representation
A small collection of useful functions to work with Node.js `process.hrtime` values
- Host: GitHub
- URL: https://github.com/dnlup/hrtime-utils
- Owner: dnlup
- License: isc
- Created: 2020-03-26T11:42:59.000Z (over 4 years ago)
- Default Branch: next
- Last Pushed: 2023-01-16T11:02:53.000Z (almost 2 years ago)
- Last Synced: 2024-10-15T06:14:06.363Z (about 1 month ago)
- Topics: hrtime, hrtime-utils, node, nodejs, process
- Language: JavaScript
- Homepage:
- Size: 873 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# hrtime-utils
[![npm version](https://badge.fury.io/js/%40dnlup%2Fhrtime-utils.svg)](https://badge.fury.io/js/%40dnlup%2Fhrtime-utils)
![Tests](https://github.com/dnlup/hrtime-utils/workflows/Tests/badge.svg)
[![codecov](https://codecov.io/gh/dnlup/hrtime-utils/branch/next/graph/badge.svg?token=EB373JDPDU)](https://codecov.io/gh/dnlup/hrtime-utils)
[![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)> 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.
`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.
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
* [hrtime2ns(time)](#hrtime2nstime)
* [hrtime2us(time)](#hrtime2ustime)
* [hrtime2ms(time)](#hrtime2mstime)
* [hrtime2s(time)](#hrtime2stime)## Installation
```bash
$ npm i @dnlup/hrtime-utils
````## Usage
```js
const {
hrtime2ns,
hrtime2us,
hrtime2ms,
hrtime2
} = require('@dnlup/hrtime-utils')const time = process.hrtime()
hrtime2ns(time) // time in nanoseconds
hrtime2us(time) // time in microseconds
hrtime2ms(time) // time in milliseconds
hrtime2s(time) // time in secondsconst delta = process.hrtime(time)
hrtime2ns(delta) // delta in nanoseconds
hrtime2us(delta) // delta in microseconds
hrtime2ms(delta) // delta in milliseconds
hrtime2s(delta) // delta in seconds
```## API
### hrtime2ns(time)
* `time` ` The return value of a [`process.hrtime()`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_process_hrtime_time) call
* Returns ``
This function converts `time` to nanoseconds.
### hrtime2us(time)
* `time` ` The return value of a [`process.hrtime()`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_process_hrtime_time) call
* Returns ``
This function converts `time` to microseconds.
### hrtime2ms(time)
* `time` ` The return value of a [`process.hrtime()`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_process_hrtime_time) call
* Returns ``
This function converts `time` to milliseconds.
### hrtime2s(time)
* `time` ` The return value of a [`process.hrtime()`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_process_hrtime_time) call
* Returns ``
This function converts `time` to seconds.