1.0.0 • Published 5 years ago
hrtime-utils v1.0.0
hrtime-utils
A small collection of useful functions to work with Node.js
process.hrtimevalues.
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
$ npm i @dnlup/hrtime-utilsUsage
const {
hrtime2ns,
hrtime2ms,
hrtime2
} = require('@dnlup/hrtim-utils')
const time = process.hrtime()
hrtime2ns(time) // time in nanoseconds
hrtime2ms(time) // time in milliseconds
hrtime2s(time) // time in seconds
const delta = process.hrtime(time)
hrtime2ns(delta) // delta in nanoseconds
hrtime2ms(delta) // delta in milliseconds
hrtime2s(delta) // delta in secondsAPI
hrtime2ns(time)
time<integer[]> The return value of aprocess.hrtime()callReturns
<number>
This function converts time to nanoseconds.
hrtime2ms(time)
time<integer[]> The return value of aprocess.hrtime()callReturns
<number>
This function converts time to milliseconds.
hrtime2s(time)
time<integer[]> The return value of aprocess.hrtime()callReturns
<number>
This function converts time to seconds.
Note
If your Node.js environment supports it, you could use process.hrtime.bigint() instead of process.hrtime() and this module.
1.0.0
5 years ago