humanize-duration
Advanced tools
Comparing version 3.17.0 to 3.18.0
@@ -0,1 +1,6 @@ | ||
3.18.0 / 2019-03-07 | ||
=================== | ||
* new: `maxDecimalPoints` option | ||
3.17.0 / 2019-01-06 | ||
@@ -2,0 +7,0 @@ =================== |
@@ -545,3 +545,10 @@ // HumanizeDuration.js - https://git.io/j0HgmQ | ||
if (i + 1 === len) { | ||
unitCount = ms / unitMS | ||
if (options.hasOwnProperty('maxDecimalPoints')) { | ||
// We need to use this expValue to avoid rounding functionality of toFixed call | ||
var expValue = Math.pow(10, options.maxDecimalPoints) | ||
var unitCountFloat = (ms / unitMS) | ||
unitCount = parseFloat((Math.floor(expValue * unitCountFloat) / expValue).toFixed(options.maxDecimalPoints)) | ||
} else { | ||
unitCount = ms / unitMS | ||
} | ||
} else { | ||
@@ -548,0 +555,0 @@ unitCount = Math.floor(ms / unitMS) |
@@ -29,3 +29,3 @@ { | ||
], | ||
"version": "3.17.0", | ||
"version": "3.18.0", | ||
"description": "Convert millisecond durations to English and many other languages.", | ||
@@ -40,5 +40,5 @@ "homepage": "https://github.com/EvanHahn/HumanizeDuration.js", | ||
"check-ecmascript-version-compatibility": "^0.1.1", | ||
"csv-parse": "^1.1.7", | ||
"csv-parse": "^4.3.1", | ||
"mocha": "^5.2.0", | ||
"ms": "^0.7.2", | ||
"ms": "^2.1.1", | ||
"standard": "^12.0.1" | ||
@@ -45,0 +45,0 @@ }, |
@@ -132,2 +132,14 @@ Humanize Duration | ||
**maxDecimalPoints** | ||
Number that defines a maximal decimal points for float values. | ||
```js | ||
humanizeDuration(8123.456789) // 8.12 seconds | ||
humanizeDuration(8123.456789, { maxDecimalPoints: 3 }) // 8.123 seconds | ||
humanizeDuration(8123.456789, { maxDecimalPoints: 6 }) // 8.123456 seconds | ||
humanizeDuration(8123.45, { maxDecimalPoints: 6 }) // 8.12345 seconds | ||
humanizeDuration(8000, { maxDecimalPoints: 6 }) // 8 seconds | ||
``` | ||
**unitMeasures** | ||
@@ -134,0 +146,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44906
698
313