hrtime-utils
A small collection of useful functions to work with Node.js process.hrtime
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
$ npm i @dnlup/hrtime-utils
Usage
const {
hrtime2ns,
hrtime2us,
hrtime2ms,
hrtime2
} = require('@dnlup/hrtime-utils')
const time = process.hrtime()
hrtime2ns(time)
hrtime2us(time)
hrtime2ms(time)
hrtime2s(time)
const delta = process.hrtime(time)
hrtime2ns(delta)
hrtime2us(delta)
hrtime2ms(delta)
hrtime2s(delta)
API
hrtime2ns(time)
This function converts time
to nanoseconds.
hrtime2us(time)
This function converts time
to microseconds.
hrtime2ms(time)
This function converts time
to milliseconds.
hrtime2s(time)
This function converts time
to seconds.