-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove {disambiguation: 'balance'}
in with()
and from()
of non-Duration
types
#642
Conversation
Fixes tc39#609. Removes non-`Duration` use of `{disambiguation: 'balance'}` from polyfill, because all known use-cases are better served by using `plus()` instead. Note that balancing _behavior_ is still present, because it's needed for `plus` and `minus`. it's just the `balance` disambiguation option for `with` and `from` that's being removed for non-Duration types. `Duration` still retains this option, because (unlike other types), there's a need to create and persist unbalanced `Duration` instances. Now, non-Duration arithmetic options have the same disambiguation options as `from` and `with`. Abstract operations were renamed accordingly.
Converts the cookbook's single non-Duration use of `{disambiguation: 'balance'}` to use `plus` instead.
b1760b6
to
eab70dd
Compare
Fixed merge conflicts and force-pushed. |
Codecov Report
@@ Coverage Diff @@
## main #642 +/- ##
==========================================
- Coverage 96.15% 96.11% -0.04%
==========================================
Files 17 17
Lines 4027 3988 -39
Branches 650 645 -5
==========================================
- Hits 3872 3833 -39
Misses 153 153
Partials 2 2
Continue to review full report at Codecov.
|
Fixes tc39#609. Removes non-`Duration` use of `{disambiguation: 'balance'}` from spec, because all known use-cases are better served by using `plus()` instead. Note that balancing _behavior_ is still present, because it's needed for `plus` and `minus`. it's just the `balance` disambiguation option for `with` and `from` that's being removed for non-Duration types. `Duration` still retains this option, because (unlike other types), there's a need to create and persist unbalanced `Duration` instances. Now, non-Duration arithmetic options have the same disambiguation options as `from` and `with`. Abstract operations were renamed accordingly.
eab70dd
to
11d5f3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With one small change, I think this is OK. Might be good to see if anyone else weighs in since we've only heard from me and @pipobscure
I have no strong opinion on this and am happy to defer to the other champions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks. Just a few comments.
Co-authored-by: Ujjwal Sharma <[email protected]>
Fixes #609. Removes use of
{disambiguation: 'balance'}
in non-Duration
classes'with
andfrom
methods, because all known use cases are better served by usingplus()
instead. Usage is removed from docs, cookbook, polyfill, tests, TS types, and spec.Note that balancing behavior is still present, because it's needed for
plus
andminus
. it's just thebalance
disambiguation option forwith
andfrom
that's being removed for non-Duration
types, because instead of shoehorning math operations intowith
orfrom
, we want to guide developers to use real math operations likeplus
orminus
.Duration
still retains this option for itswith
andfrom
becauseDuration
(unlike other types) can create and persist unbalancedDuration
instances, so there needs to be some way to create a balanced clone of an existing duration.With this PR, non-Duration arithmetic options now have the same disambiguation options as
from
andwith
. Abstract operations were renamed accordingly:ToTemporalDisambiguation
withbalance
is now used only inDuration
, so it's renamed toToDurationTemporalDisambiguation
ToArithmeticTemporalDisambiguation
now matches the samedisambiguation
options as are used by non-Durationwith
andfrom
methods, so it's been renamed toToTemporalDisambiguation
and this combined abstract operation it's now used for all types'plus
andminus
as well as non-Duration
with
andfrom
.