@xh/hoist 67.0.0-SNAPSHOT.1725049253748 → 67.0.0-SNAPSHOT.1725050021281

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,8 @@ import {
13
13
  isInteger,
14
14
  isNil,
15
15
  isNumber,
16
- isString
16
+ isString,
17
+ round
17
18
  } from 'lodash';
18
19
  import Numbro from 'numbro';
19
20
  import numbro from 'numbro';
@@ -498,14 +499,11 @@ function buildFormatConfig(
498
499
 
499
500
  // Calculate numbro mantissa and trimMantissa options based on precision and zeroPad settings.
500
501
  if (isNumber(zeroPad)) {
501
- // Specific zeroPad set - need to read actual precision of number to determine exact
502
- // mantissa, as we cannot use trimMantissa (since we do want to allow some trailing zeroes).
503
- const actualPrecision = countDecimalPlaces(absVal);
504
-
505
- // How much precision do we actually want/need? Lower of actual vs. precision set above.
506
- // Ensures we respect a deliberately low precision spec, but otherwise include only as
507
- // much precision as we need to show the value.
508
- const requiredPrecision = Math.min(actualPrecision, precision);
502
+ // Specific zeroPad set - we want to show at least this much precision, but not more unless
503
+ // the value actually has more precision. Note, we round to requested *max* precision first,
504
+ // then determine the value's actual precision. This avoids issues where values resulting
505
+ // from floating point operations have spurious precision that would defeat this routine.
506
+ const requiredPrecision = countDecimalPlaces(round(absVal, precision));
509
507
 
510
508
  // Then set mantissa to higher of required precision vs. requested zeroPad.
511
509
  // Ensures we display all of the requested/available precision + extra zeros if needed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "67.0.0-SNAPSHOT.1725049253748",
3
+ "version": "67.0.0-SNAPSHOT.1725050021281",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",