-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
ref: Ladder
class
#83259
base: master
Are you sure you want to change the base?
ref: Ladder
class
#83259
Conversation
static/app/utils/number/ladder.tsx
Outdated
type Rung<T> = [threshold: number, value: T]; | ||
|
||
/** | ||
* Class that represents a value ladder. Given a ladder of increasing thresholds, the ladder can match an incoming value against the known intervals. |
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.
Any chance we could add some examples and maybe an example use case?
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.
Yes! Added
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #83259 +/- ##
=======================================
Coverage 87.54% 87.54%
=======================================
Files 9470 9470
Lines 537279 537269 -10
Branches 21151 21150 -1
=======================================
- Hits 470373 470365 -8
+ Misses 66548 66547 -1
+ Partials 358 357 -1 |
Bundle ReportChanges will increase total bundle size by 33.87kB (0.11%) ⬆️. This is within the configured threshold ✅ Detailed changes
|
Extracting a
Ladder
class out ofGranularityLadder
. The mechanism of matching values against increasing intervals is really common at Sentry, I want to use this in more places.My immediate need is duration formatting. We have code all over the place that takes a count of milliseconds and then decides whether it should be converted to seconds, minutes, years, etc. by checking this exactly kind of ladder logic.