Duration: support negative values#1249
Merged
mikearnaldi merged 2 commits intomainfrom Feb 16, 2026
Merged
Conversation
Contributor
📊 JSDoc Documentation Analysis📈 Current Analysis ResultsThis comment is automatically updated on each push. View the analysis script for details. |
Contributor
Bundle Size Analysis
|
5 tasks
5f42e38 to
a755047
Compare
IMax153
approved these changes
Feb 16, 2026
Member
Author
|
@copilot rebase this on main |
|
@mikearnaldi I've opened a new pull request, #1257, to work on those changes. Once the pull request is ready, I'll request review from you. |
Unclamp the make constructor to allow negative durations. Add NegativeInfinity variant to DurationValue, new predicates (isNegative, isPositive, abs, negate), and update all arithmetic, conversions, ordering, and formatting to handle negatives with IEEE 754 sign rules. Guard consumers that would break with negative inputs: RateLimiter, OtlpExporter, PersistedQueue, Persistence, RpcClient, Metric.
OtlpExporter: clamp to zero instead of 100ms to preserve valid sub-100ms intervals. RpcClient: revert timeToLive guard entirely; Pool.makeWithTTL handles DurationInput directly.
a755047 to
7be5e4c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Duration.make— negative numbers now produce negativeMillis/Nanosvalues instead of being clamped to zero.-Infinitymaps to the newNegativeInfinityvariant;NaNmaps tozero.NegativeInfinityvariant added toDurationValuediscriminated union, with full support across ordering (NegativeInfinity < finite < Infinity), arithmetic (signed-infinity rules following IEEE 754), conversions (toMillis,toHrTime,parts,format), and pattern matching (match/matchPair).isNegative,isPositive,abs,negate; updatedisFiniteandisZero.RateLimiter(window ≥ 1ms),OtlpExporter(interval ≥ 100ms),PersistedQueue(intervals ≥ 1ms),Persistence(skip negative TTL),RpcClient(TTL ≥ 1s),Metric(maxAge ≥ 0).NegativeInfinity(maps toMillis(0)since the schema already rejects negatives via validation).Validation
pnpm lint-fix— 0 errorspnpm check— passespnpm test— 5472 tests, 203 files, all passpnpm build— passespnpm docgen— passes