Gathering detailed insights and metrics for atlas-pretty-hrtime
Gathering detailed insights and metrics for atlas-pretty-hrtime
npm install atlas-pretty-hrtime
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
1,089
Last Day
3
Last Week
4
Last Month
9
Last Year
187
14 Commits
2 Watching
1 Branches
1 Contributors
Latest Version
1.0.0
Package Id
atlas-pretty-hrtime@1.0.0
Unpacked Size
7.21 kB
Size
3.04 kB
File Count
7
NPM Version
6.0.1
Node Version
10.1.0
Cumulative downloads
Total Downloads
Last day
0%
3
Compared to previous day
Last week
300%
4
Compared to previous week
Last month
12.5%
9
Compared to previous month
Last year
-34.8%
187
Compared to previous year
Converts a time in nanoseconds to a pretty string in the most convenient units.
npm install --save atlas-pretty-hrtime
Printing times is annoying, so this is me thinking about it once and hopefully never again. If you are doing performance testing, you will encounter time diffs between different points in your code. With this module, you don't need to worry about how to print those times in various units with varying precision -- it's done automatically for you.
The exported function takes a time
in nanoseconds, an optional precision integer and returns a string. The default precision is 3
decimal places, and the maximum unit is hours.
1const pretty = require("atlas-pretty-time"); 2// all times in nanoseconds 3const times = [ 4 // output units: 5 0, // ns 6 123, // ns 7 1234, // us 8 12345, // us 9 123456, // us 10 1234567, // ms 11 12345678, // ms 12 123456789, // ms 13 1234567890, // sec 14 12345678901, // sec 15 123456789012, // min 16 1234567890123, // min 17 12345678901234 // hr 18] 19times.forEach(time => { 20 // round to 1 decimal place 21 const prettyTime = pretty(time, 1); 22 console.log(prettyTime) 23}); 24// 0.0ns 25// 123.0ns 26// 1.2us 27// 12.3us 28// 123.5us 29// 1.2ms 30// 12.3ms 31// 123.5ms 32// 1.2sec 33// 12.3sec 34// 2.1min 35// 20.6min 36// 3.4hr
Only accepts times in nanoseconds, because supporting multiple input units is outside the scope of this package. This package is primarily for printing time diffs, which should not be in milliseconds or seconds if you're using high resolution time. See atlas-hrtime.
For simplicity, this module does not decompose fractional minutes into "minutes and seconds" (and similarly with hours). This doesn't bother me much, so I'm unlikely to implement something like:
1console.log(pretty(123456789012, 1)) 2// 2min 3sec
At the moment, this is not possible, but I may implement it in the future if I need finer-grained control on the output units:
1console.log(pretty(123456789012, 1, "sec")) 2// 123.5sec
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-30
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