v3.3.0
Changed
numericQuantityreturn type is now inferred from the options object:verbose: trueyieldsNumericQuantityVerboseResult,bigIntOnOverflow: trueyieldsnumber | bigint. Options typed as a plainNumericQuantityOptionsvariable now infer the full unionnumber | bigint | NumericQuantityVerboseResultand must be narrowed; usesatisfies NumericQuantityOptionsinstead of: NumericQuantityOptionsto retain literal inference.isNumericQuantityacceptsunknowninstead ofstring | number.
Fixed
- Added
"sideEffects": falseto package.json. vulgarFractionsRegexno longer matches}.bigIntOnOverflownow evaluates decimals, exponents, fractions, mixed numbers, and percentages exactly, rounding half-up instead of discarding the tail.roundis now applied to the value as written, before percentage division, on all code paths. Previously'1%'and'1.0%'could produce different results.- The
percentageoption now applies to Roman numeral results (e.g.'L%'→0.5). verbose.trailingInvalidis now the complete unconsumed suffix of the original input. Previously, whendecimalSeparatorwas",", the internal separator marker could leak into it and part of the suffix could be dropped (e.g.'10,00.,0'reported'&'; it now reports'.,0').symbolinput returnsNaNinstead of throwing. In verbose mode,inputis the stringified symbol (e.g.'Symbol(1)').- Input that cannot be coerced to a string (null-prototype objects, throwing
toString/valueOf) returnsNaNinstead of throwingTypeError. In verbose mode,inputis an empty string. bigIntOnOverflowno longer throwsRangeErrorfor absurdly large exponents (e.g.'1e' + '9'.repeat(400)). Exponents beyond ±10,000 fall back to thenumberpath, yieldingInfinity/0.verbose.trailingInvalidis now populated for multi-comma input whendecimalSeparatoris','andallowTrailingInvalidisfalse, matching the behavior of every other trailing-invalid path.- Non-finite
roundvalues (NaN,±Infinity) are now treated asfalse(no rounding) instead of silently rounding to 0 decimal places. Negative finite values still clamp to 0. - Very large
roundvalues no longer produce incorrect results. The rounding factor was built by string concatenation, so values in exponential range were misread (e.g.round: 1e21became"1e1e+21"→ a factor of10, rounding'1.23456'to1.2). Factors beyondNumber.MAX_VALUEnow fall back to no rounding, as does a rounding operation that would overflow an otherwise finite value (e.g.'1.5e300'withround: 308returnedNaN, now returns1.5e300). - Currency and percentage affixes are now stripped in any order (e.g.
'100€%'→1, matching'50%€'). At most one%is stripped, so'50%%'is stillNaN.
Full Changelog: v3.2.2...v3.3.0