Skip to content

Use fractionDigits & significantDigits options in .convertTo(), allow Number values#101

Merged
jessealama merged 2 commits into
mainfrom
simplify-conversion
Apr 29, 2026
Merged

Use fractionDigits & significantDigits options in .convertTo(), allow Number values#101
jessealama merged 2 commits into
mainfrom
simplify-conversion

Conversation

@eemeli

@eemeli eemeli commented Apr 23, 2026

Copy link
Copy Markdown
Member

Following today's discussion on #90 (comment), this PR:

  • Updates the README to match the spec changes applied in Specify unit conversion for Amount.prototype.convertTo #89.
  • Replaces the .convertTo() precision options (minimum/maximum fraction/significant digits) with those of the constructor, i.e. fractionDigits and significantDigits, and updates their handling to correspond to what we're already doing in the constructor. roundingPriority is dropped, as specifying both fractionDigits and significantDigits is an error.
  • Changes it so that if you .convertTo() without any precision options, you end up with a Number-backed Amount.

CC @sffc, @gibson042

@eemeli eemeli requested review from ben-allen and jessealama April 23, 2026 17:41
@github-actions

github-actions Bot commented Apr 23, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-04-29 06:44 UTC

Comment thread README.md Outdated
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
@jessealama jessealama merged commit eef3dcd into main Apr 29, 2026
3 checks passed
@jessealama jessealama deleted the simplify-conversion branch April 29, 2026 06:44
jessealama added a commit that referenced this pull request Apr 29, 2026
…r values

Aligns Amount.prototype.convertTo with the README updates from #101:
replaces the min/max fraction/significant digit options and roundingPriority
with the constructor-style fractionDigits and significantDigits (mutually
exclusive, throwing RangeError if both are set). When neither precision
option is supplied — or the converted value is non-finite — the resulting
Amount is now Number-backed rather than always String-backed.
jessealama added a commit that referenced this pull request May 5, 2026
…r values (#103)

Aligns Amount.prototype.convertTo with the README updates from #101:
replaces the min/max fraction/significant digit options and roundingPriority with the constructor-style fractionDigits and significantDigits (mutually exclusive, throwing RangeError if both are set). When neither precision option is supplied — or the converted value is non-finite — the resulting Amount is now Number-backed rather than always String-backed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants