Skip to content
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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

ref: Ladder class #83259

wants to merge 8 commits into from

Conversation

gggritso
Copy link
Member

Extracting a Ladder class out of GranularityLadder. 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.

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 10, 2025
@gggritso gggritso requested a review from a team January 10, 2025 20:50
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.
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Added

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All 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     

Copy link

codecov bot commented Jan 10, 2025

Bundle Report

Changes will increase total bundle size by 33.87kB (0.11%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
app-webpack-bundle-array-push 30.93MB 33.87kB (0.11%) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants