All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
v3.3.1 - 2026-08-26
- Corrected unpkg entry in package.json.
v3.3.0 - 2026-08-25
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.
- 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.
v3.2.2 - 2026-06-01
- Loosened type restriction on
numericQuantityinput.
v3.2.1 - 2026-02-13
- Parsing of Unicode superscript/subscript fraction notation (e.g.
¹⁄₂) now works correctly by normalizing superscript (⁰–⁹) and subscript (₀–₉) digits to ASCII before processing.
v3.2.0 - 2026-02-12
- #39
isNumericQuantity(str, options?)function for boolean validation without parsing. - #39
percentageoption to parse percentage strings ("50%"→0.5with'decimal'/true, or50with'number'). - #39
allowCurrencyoption to strip Unicode currency symbols ($,€,£,¥,₹,₿, etc.) from prefix or suffix. - #39
verboseoption to return a detailed result object with the following fields:value— the parsed numeric value (NaNif invalid).input— the original input string.currencyPrefix/currencySuffix— currency symbol(s) stripped from start/end, if any.percentageSuffix—trueif a%suffix was stripped.trailingInvalid— trailing non-numeric characters detected in the input, if any. Populated regardless of theallowTrailingInvalidsetting.sign— the leading sign character ('-'or'+'), if present.whole— the whole-number part of a mixed fraction (e.g.1from"1 2/3").numerator/denominator— fraction components (e.g.2and3from"1 2/3"). Always unsigned.
- #39 Leading
+sign support:numericQuantity('+42')now returns42instead ofNaN. Works with all input forms including fractions ('+1/2'), mixed numbers ('+1 1/2'), decimals ('+1.5'), and currency ('+$100').
v3.1.0 - 2026-02-11
- #38 Support for non-ASCII decimal numeral systems (Arabic-Indic, Devanagari, Bengali, Thai, Fullwidth, and 70+ other Unicode
\p{Nd}digit blocks). For example,numericQuantity('٣')now returns3.
v3.0.0 - 2026-01-21
- #37 Now requires ES2021+ (uses
String.prototype.replaceAll). - #37 In line with the rules of modern JavaScript syntax, repeated separators (e.g.
"1__0"or"1,,0") are considered invalid. TheallowTrailingInvalidoption will still permit evaluation of characters before any duplicate separators.
- #37 Option
decimalSeparator, accepting values"."(default) and",". When set to",", numbers will be evaluated with European-style decimal comma (e.g.1,0is equivalent to1, not10).
v2.1.0 - 2025-06-09
bigIntOnOverflowoption will produce abigintvalue if the input represents a valid integer greater thanNumber.MAX_SAFE_INTEGERor less thanNumber.MIN_SAFE_INTEGER.
v2.0.1 - 2024-01-15
- Corrected links in
package.jsonto distributed type definition files.
v2.0.0 - 2023-06-16
- #26
numericQuantityis now a named export; there is no default export. - #26 UMD build assigns all exports, including
numericQuantity, to the global objectNumericQuantity. Previously, it assigned the main function to the global namespace asnumericQuantity.
- #26 Support for comma (
',') and underscore ('_') separators within Arabic numeral sequences. If a numeric sequence has a leading or trailing separator, that sequence will be considered invalid. This will causenumericQuantityto returnNaNunlessallowTrailingInvalidistrue(see next item), in which case the sequence in question and everything after it will be ignored. - #26 Options object as optional second parameter. Accepts the following options:
allowTrailingInvalid(boolean, defaultfalse): AllowsnumericQuantityto more closely resemble the behavior ofparseFloatby accepting and ignoring everything from the first invalid character to the end of the string.romanNumerals(boolean, defaultfalse): Enables support for Roman numerals with modern, strict rules, including the Unicode code pointsU+2160throughU+217F. Roman numerals will only be parsed if an attempt to parse the string based on Arabic numerals fails. To parse Roman numerals unconditionally, callparseRomanNumeralsdirectly.round(number | false, default3): Rounds the result to the specified number of decimal places. Useround: falseto avoid rounding.
- #26 Support for Unicode "Fraction Numerator One" code point (
'⅟',U+215F), which must be followed by a numeric sequence (the denominator) to be considered part of a valid fraction representation. - #26 Named exports of internal utilities like regular expressions, character maps, types, etc.
- #26 Build with tsup.
v1.0.4 - 2022-04-16
- Corrected filenames in package.json.
v1.0.3 - 2022-04-16
- Build with Vite.
v1.0.2 - 2021-08-23
- #21 Support for Unicode fraction slash (
⁄,U+2044).
v1.0.1 - 2021-02-15
- Added description to package.json.
v1.0.0 - 2021-02-11
v0.5.2 - 2021-02-08
- Updated CI badges on README.md.
v0.5.1 - 2019-08-24
- README.md note about return values.
v0.5.0 - 2019-08-24
- Returns
NaNfor invalid inputs instead of-1.
- #3 Handles negative numbers.
v0.4.2 - 2019-08-23
- Publish
distdirectory only.
v0.4.1 - 2019-08-23
- Rewritten in TypeScript.
- Build with Rollup.
v0.4.0 - 2019-08-22
- ESM and CJS builds.
v0.3.3 - 2019-07-21
- JSDoc comments for tooltips
v0.3.2 - 2018-09-21
- TypeScript types.
v0.3.1 - 2015-07-16
- Documentation update.
v0.3.0 - 2015-07-16
- UMD support.
- Minor bug fixes.
v0.2.0 - 2015-05-14
- #1 Accept decimals without a leading zero.
v0.1.2 - 2015-03-20
- Minor performance improvement.
v0.1.1 - 2015-03-19
- Use
parseInt/parseFloatinstead ofstr - 0to parse numbers from strings.
v0.1.0 - 2015-03-18
- Initial release.