Installations
npm install @postman/pretty-ms
Developer Guide
Typescript
No
Module System
N/A
Min. Node Version
>=10
Node Version
10.18.1
NPM Version
6.13.4
Score
76.3
Supply Chain
99.5
Quality
82.5
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (95.26%)
TypeScript (4.74%)
Developer
postmanlabs
Download Statistics
Total Downloads
908,518
Last Day
556
Last Week
2,247
Last Month
10,127
Last Year
412,870
GitHub Statistics
2 Stars
78 Commits
2 Forks
2 Watching
1 Branches
36 Contributors
Bundle Size
2.29 kB
Minified
1.02 kB
Minified + Gzipped
Package Meta Information
Latest Version
6.1.0
Package Id
@postman/pretty-ms@6.1.0
Unpacked Size
12.41 kB
Size
3.89 kB
File Count
5
NPM Version
6.13.4
Node Version
10.18.1
Total Downloads
Cumulative downloads
Total Downloads
908,518
Last day
51.9%
556
Compared to previous day
Last week
-28.6%
2,247
Compared to previous week
Last month
200.4%
10,127
Compared to previous month
Last year
359.9%
412,870
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
pretty-ms
Convert milliseconds to a human readable string:
1337000000
→15d 11h 23m 20s
Install
$ npm install pretty-ms
Usage
1const prettyMilliseconds = require('pretty-ms'); 2 3prettyMilliseconds(1337000000); 4//=> '15d 11h 23m 20s' 5 6prettyMilliseconds(1337); 7//=> '1.3s' 8 9prettyMilliseconds(133); 10//=> '133ms' 11 12// `compact` option 13prettyMilliseconds(1337, {compact: true}); 14//=> '1s' 15 16// `verbose` option 17prettyMilliseconds(1335669000, {verbose: true}); 18//=> '15 days 11 hours 1 minute 9 seconds' 19 20// `colonNotation` option 21prettyMilliseconds(95500, {colonNotation: true}); 22//=> '1:35.5' 23 24// `padUnits` option 25prettyMilliseconds(1337000000, {padUnits: true}); 26//=> '15 d 11 h 23 m 20 s' 27 28// `formatSubMilliseconds` option 29prettyMilliseconds(100.400080, {formatSubMilliseconds: true}) 30//=> '100ms 400µs 80ns' 31 32// Can be useful for time durations 33prettyMilliseconds(new Date(2014, 0, 1, 10, 40) - new Date(2014, 0, 1, 10, 5)) 34//=> '35m'
API
prettyMilliseconds(milliseconds, options?)
milliseconds
Type: number
Milliseconds to humanize.
options
Type: object
secondsDecimalDigits
Type: number
Default: 1
Number of digits to appear after the seconds decimal point.
millisecondsDecimalDigits
Type: number
Default: 0
Number of digits to appear after the milliseconds decimal point.
Useful in combination with process.hrtime()
.
keepDecimalsOnWholeSeconds
Type: boolean
Default: false
Keep milliseconds on whole seconds: 13s
→ 13.0s
.
Useful when you are showing a number of seconds spent on an operation and don't want the width of the output to change when hitting a whole number.
compact
Type: boolean
Default: false
Only show the first unit: 1h 10m
→ 1h
.
Also ensures that millisecondsDecimalDigits
and secondsDecimalDigits
are both set to 0
.
unitCount
Type: number
Default: Infinity
Number of units to show. Setting compact
to true
overrides this option.
verbose
Type: boolean
Default: false
Use full-length units: 5h 1m 45s
→ 5 hours 1 minute 45 seconds
separateMilliseconds
Type: boolean
Default: false
Show milliseconds separately. This means they won't be included in the decimal part of the seconds.
formatSubMilliseconds
Type: boolean
Default: false
Show microseconds and nanoseconds.
colonNotation
Type: boolean
Default: false
Display time using colon notation: 5h 1m 45s
→ 5:01:45
. Always shows time in at least minutes: 1s
→ 0:01
Useful when you want to display time without the time units, similar to a digital watch.
Setting colonNotation
to true
overrides the following options to false
:
compact
formatSubMilliseconds
separateMilliseconds
verbose
padUnits
Type: boolean
Default: false
Setting padUnits
to true
will show the time with a space before the unit 5h 1m 45s
→ 5 h 1 m 45 s
.
Related
- pretty-ms-cli - CLI for this module
- parse-ms - Parse milliseconds into an object
- to-milliseconds - Convert an object of time properties to milliseconds
- pretty-bytes - Convert bytes to a human readable string
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 1/26 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Score
3
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More