human-format
Advanced tools
Comparing version 0.9.0 to 0.9.1
21
index.js
@@ -280,3 +280,8 @@ // UMD: https://github.com/umdjs/umd/blob/master/returnExports.js | ||
var power | ||
var decimals = opts.decimals | ||
if (decimals !== undefined) { | ||
power = Math.pow(10, decimals) | ||
} | ||
var prefix = opts.prefix | ||
@@ -290,15 +295,8 @@ var factor | ||
factor = scale._prefixes[prefix] | ||
value /= factor | ||
if (decimals !== undefined) { | ||
var p = Math.pow(10, decimals) | ||
value = Math.round(value * p) / p | ||
} | ||
} else { | ||
var _ref = scale.findPrefix(value) | ||
factor = _ref.factor | ||
if (decimals !== undefined) { | ||
if (power !== undefined) { | ||
do { | ||
factor = _ref.factor | ||
var r = Math.pow(10, decimals) / factor | ||
var r = power / factor | ||
value = Math.round(value * r) / r | ||
@@ -310,3 +308,2 @@ } while ((_ref = scale.findPrefix(value)).factor !== factor) | ||
value /= factor | ||
prefix = _ref.prefix | ||
@@ -317,3 +314,5 @@ } | ||
prefix: prefix, | ||
value: value | ||
value: power === undefined | ||
? value / factor | ||
: Math.round(value * power / factor) / power | ||
} | ||
@@ -320,0 +319,0 @@ } |
{ | ||
"name": "human-format", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "description": "Converts a number to/from a human readable string: `1337` ↔ `1.34kB`", |
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
12351
268