@dnlup/hrtime-utils

中文文档
1.1.0发布于 2020/11/09ISCCommonJS零依赖近 30 天下载 4675

A small collection of useful functions to work with Node.js process.hrtime values

原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. API
  4. hrtime2ns(time)
  5. hrtime2us(time)
  6. hrtime2ms(time)
  7. hrtime2s(time)

hrtime-utils

npm version Tests Coverage Status Known Vulnerabilities

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) // time in nanoseconds
hrtime2us(time) // time in microseconds
hrtime2ms(time) // time in milliseconds
hrtime2s(time) // time in seconds

const 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)

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.

版本与发布记录

@dnlup/hrtime-utils 共发布 6 个版本,首次发布于 2020/10/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.0latest2020/11/096 年前
1.0.42020/11/086 年前
1.0.32020/11/086 年前
1.0.22020/11/086 年前
1.0.12020/10/146 年前
1.0.02020/10/136 年前

关于 @dnlup/hrtime-utils 的常见问题

@dnlup/hrtime-utils 是什么?

A small collection of useful functions to work with Node.js process.hrtime values

如何安装 @dnlup/hrtime-utils?

在项目目录运行 npm install @dnlup/hrtime-utils,或使用 pnpm add / yarn add / bun add。

@dnlup/hrtime-utils 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dnlup__hrtime-utils 是否存在。

@dnlup/hrtime-utils 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dnlup/hrtime-utils 可以商用吗?

@dnlup/hrtime-utils 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dnlup/hrtime-utils 的下载量有多少?

根据 npm 官方下载统计,@dnlup/hrtime-utils 在 2026/10/13 – 2026/11/11 这 30 天内被下载 4,675 次,日均约 156 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dnlup/hrtime-utils 还在维护吗?

最新版本 1.1.0 发布于 2020/11/09(6 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/10/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。