
Research
Security News
Malicious npm Packages Use Telegram to Exfiltrate BullX Credentials
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
convert-hrtime
Advanced tools
Convert the result of `process.hrtime.bigint()` to seconds, milliseconds, nanoseconds
The convert-hrtime npm package is designed to convert high-resolution time measurements, typically obtained using process.hrtime(), into various time units such as milliseconds, seconds, nanoseconds, etc. This is particularly useful for performance measurement in Node.js applications where precise timing is crucial.
Convert to milliseconds
This feature allows the conversion of a high-resolution time to milliseconds. It is useful for logging or measuring execution time in milliseconds.
const convertHrtime = require('convert-hrtime');
const hrtime = process.hrtime();
const milliseconds = convertHrtime(hrtime).milliseconds;
Convert to seconds
This feature enables the conversion of a high-resolution time to seconds. It can be used when a broader time measurement is sufficient for the application's needs.
const convertHrtime = require('convert-hrtime');
const hrtime = process.hrtime();
const seconds = convertHrtime(hrtime).seconds;
Convert to nanoseconds
This feature provides the ability to convert high-resolution time to nanoseconds, offering the highest precision for performance measurement in critical applications.
const convertHrtime = require('convert-hrtime');
const hrtime = process.hrtime();
const nanoseconds = convertHrtime(hrtime).nanoseconds;
pretty-hrtime is a package that also focuses on converting high-resolution time measurements but emphasizes formatting the output into a more human-readable string. Unlike convert-hrtime, which provides numerical conversions, pretty-hrtime is more about readability for logging and display purposes.
time-convert offers conversion between various units of time (e.g., hours to minutes, minutes to seconds), including high-resolution time. It provides a broader range of time unit conversions compared to convert-hrtime, which is specifically focused on high-resolution time.
Convert the result of
process.hrtime.bigint()
to seconds, milliseconds, nanoseconds
$ npm install convert-hrtime
import convertHrtime from 'convert-hrtime';
const startTime = process.hrtime.bigint();
expensiveCalculation();
const diff = process.hrtime.bigint() - startTime;
convertHrtime(diff);
//=> {seconds: 0.000002399, milliseconds: 0.002399, nanoseconds: 2399n}
FAQs
Convert the result of `process.hrtime.bigint()` to seconds, milliseconds, nanoseconds
The npm package convert-hrtime receives a total of 1,668,286 weekly downloads. As such, convert-hrtime popularity was classified as popular.
We found that convert-hrtime demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.
Security News
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.