Repository navigation
fix: Duration precision beyond 104 days, @stylistic 6, and 4.7.2 - #154
Merged
Merged
Conversation
…tyle @stylistic/eslint-plugin 6 provides list-style, which covers the spacing that array-bracket-spacing and object-curly-spacing enforced and also requires one item per line in multi-line lists. Keep brackets tight and braces padded on a single line, leave parentheses and type parameters alone, and put each option of the multi-line Intl.DateTimeFormat and default-parts literals on its own line.
…anoseconds Scaling the whole duration to nanoseconds exceeded Number.MAX_SAFE_INTEGER after about 104 days, so toParts() and format() could return wrong milliseconds and smaller units even for integer durations such as epoch timestamps. Split off the fraction, which subtracts out of a double exactly, and decompose whole milliseconds and the nanosecond remainder separately. Switch the existing tests to fractions that are exact in binary, add cases beyond the safe-integer range, and document how precision falls off for long durations.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #154 +/- ##
=======================================
Coverage 98.87% 98.88%
=======================================
Files 77 77
Lines 1246 1250 +4
Branches 367 368 +1
=======================================
+ Hits 1232 1236 +4
Partials 14 14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Durationsub-millisecond parts for long durations: scaling the whole value to nanoseconds exceededNumber.MAX_SAFE_INTEGERafter about 104 days, sotoParts()andformat()could return wrong milliseconds and smaller units even for integer values such as epoch timestamps. The fraction is now split off before decomposition. Docs describe how precision falls off for long durations.array-bracket-spacing,object-curly-spacing, andobject-curly-newlinewith@stylistic/list-style, and put each item of multi-line option literals on its own line.@stylistic/eslint-plugin6) and bump the version to 4.7.2.Test plan
npm run lint(no warnings) /npm run tsnpm test(73 files / 2359 tests)npm run build && npx vitest run tests/buildnpm run docs:build