Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@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 2,293,297 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.