pretty-ms
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
parse-ms | 3.0.0 | 1.72 kB | MIT | prod |
The npm package "pretty-ms" is a handy tool designed to convert milliseconds into a human-readable string format. For instance, it can change a number like 1337000000
into a more comprehensible format like 15d 11h 23m 20s
, making it much easier to understand for non-technical users or for more readable logging or display in applications.
To use the 'pretty-ms' package, you'll first need to install it to your project using npm with the command npm install pretty-ms
. Once installed, you can import it into your JavaScript file using the line import prettyMilliseconds from 'pretty-ms';
.
Here are a few examples of how to use the 'pretty-ms' package:
// Basic usage
prettyMilliseconds(1337000000); // Returns '15d 11h 23m 20s'
// Using compact option
prettyMilliseconds(1337, {compact: true}); // Returns '1s'
// Using verbose option
prettyMilliseconds(1335669000, {verbose: true}); // Returns '15 days 11 hours 1 minute 9 seconds'
// Using colonNotation option
prettyMilliseconds(95500, {colonNotation: true}); // Returns '1:35.5'
The 'pretty-ms' package also offers other options such as formatSubMilliseconds
, unitCount
, and secondsDecimalDigits
among others, to provide more flexibility to users.
The full documentation for the 'pretty-ms' package can be found in its README file on the GitHub repository page. The URL is: https://github.com/sindresorhus/pretty-ms. The README document provides comprehensive details about the package usage, options and the API. It is also the source for any updates or changes made in the package. It is advisable to keep the link bookmarked for your reference.