Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@types/pretty-hrtime
Advanced tools
TypeScript definitions for pretty-hrtime
@types/pretty-hrtime is a TypeScript type definition package for the pretty-hrtime library, which is used to convert high-resolution time (hrtime) to a human-readable format.
Formatting High-Resolution Time
This feature allows you to format high-resolution time (hrtime) into a human-readable string. The code sample demonstrates how to measure the time taken for a task and then format it using pretty-hrtime.
const prettyHrtime = require('pretty-hrtime');
const start = process.hrtime();
// do some work
const end = process.hrtime(start);
console.log(prettyHrtime(end));
Verbose Formatting
This feature provides a more verbose output for the formatted high-resolution time. The code sample shows how to enable verbose formatting to get a more detailed human-readable string.
const prettyHrtime = require('pretty-hrtime');
const start = process.hrtime();
// do some work
const end = process.hrtime(start);
console.log(prettyHrtime(end, { verbose: true }));
Precise Formatting
This feature allows for precise formatting of the high-resolution time, showing more decimal places. The code sample demonstrates how to enable precise formatting for a more accurate human-readable string.
const prettyHrtime = require('pretty-hrtime');
const start = process.hrtime();
// do some work
const end = process.hrtime(start);
console.log(prettyHrtime(end, { precise: true }));
The humanize-duration package is used to convert a duration in milliseconds to a human-readable format. Unlike pretty-hrtime, which works with high-resolution time, humanize-duration is more suited for general-purpose duration formatting.
Moment.js is a comprehensive library for parsing, validating, manipulating, and formatting dates and times in JavaScript. While it is more feature-rich compared to pretty-hrtime, it is not specifically designed for high-resolution time formatting.
date-fns is a modern JavaScript date utility library that provides a variety of functions for working with dates and times. Similar to moment, it is not specialized for high-resolution time but offers a wide range of date manipulation features.
npm install --save @types/pretty-hrtime
This package contains type definitions for pretty-hrtime (https://github.com/robrich/pretty-hrtime).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pretty-hrtime.
export = prettyHrtime;
declare function prettyHrtime(hrTime: [number, number], options?: prettyHrtime.Options): string;
declare namespace prettyHrtime {
interface Options {
verbose?: boolean | undefined;
precise?: boolean | undefined;
}
}
These definitions were written by BendingBender.
FAQs
TypeScript definitions for pretty-hrtime
The npm package @types/pretty-hrtime receives a total of 886,663 weekly downloads. As such, @types/pretty-hrtime popularity was classified as popular.
We found that @types/pretty-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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.