Installations
npm install pretty-ms-i18n
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=10
Node Version
12.12.0
NPM Version
6.14.8
Score
72
Supply Chain
99.3
Quality
77.8
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
arcblock
Download Statistics
Total Downloads
74,290
Last Day
55
Last Week
429
Last Month
2,550
Last Year
28,241
GitHub Statistics
83 Commits
1 Forks
1 Watching
14 Branches
24 Contributors
Bundle Size
3.29 kB
Minified
1.38 kB
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
1.0.3
Package Id
pretty-ms-i18n@1.0.3
Unpacked Size
12.50 kB
Size
4.51 kB
File Count
8
NPM Version
6.14.8
Node Version
12.12.0
Total Downloads
Cumulative downloads
Total Downloads
74,290
Last day
-28.6%
55
Compared to previous day
Last week
-40.5%
429
Compared to previous week
Last month
-25.3%
2,550
Compared to previous month
Last year
27.8%
28,241
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
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// `locale` option default en_US 17prettyMilliseconds(1337, { locale: 'zh_CN' }); 18//=> '1秒' 19 20// `verbose` option 21prettyMilliseconds(1335669000, { verbose: true }); 22//=> '15 days 11 hours 1 minute 9 seconds' 23 24// `colonNotation` option 25prettyMilliseconds(95500, { colonNotation: true }); 26//=> '1:35.5' 27 28// `formatSubMilliseconds` option 29prettyMilliseconds(100.40008, { 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
locale
Type: string
Default: en_US
you can use 'en_US' or 'zh_CN' to show i18n. Detail to see
Only show: 1s
→ 1秒
.
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
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
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 2/30 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
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
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Reason
28 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
1.7
/10
Last Scanned on 2024-12-23
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