deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

refactor(fmt): add unit arrays

Open timreichen opened this issue 6 months ago • 1 comments

This PR adds unit arrays which makes it more readable and avoids string manipulation. Several other changes like num = Math.abs(num) only for negative numbers and pre-calculation of magnitudes.

timreichen avatar May 29 '25 07:05 timreichen

Codecov Report

Attention: Patch coverage is 98.78049% with 1 line in your changes missing coverage. Please review.

Project coverage is 94.15%. Comparing base (fc59ca6) to head (bc419dd). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
fmt/bytes.ts 98.78% 0 Missing and 1 partial :warning:
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6696   +/-   ##
=======================================
  Coverage   94.14%   94.15%           
=======================================
  Files         586      586           
  Lines       42465    42501   +36     
  Branches     6701     6694    -7     
=======================================
+ Hits        39980    40018   +38     
+ Misses       2435     2433    -2     
  Partials       50       50           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 29 '25 07:05 codecov[bot]

Let's not do this. It seems very confusing to include many of unused values in the source code

kt3k avatar Jul 17 '25 06:07 kt3k

Let's not do this. It seems very confusing to include many of unused values in the source code

This was in preparation for adding the unitDisplay as an option. I've updated the PR so it is introduced here to avoid unused values. One question remains whether short and altShort should coexist. This implementation deviates from the IEC standard names (for example Kibibyte uses KiB according to IEC but kiB in the current implementation) which seems like an error imo, but I am not sure if that is the consensus.

timreichen avatar Jul 18 '25 12:07 timreichen