deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

refactor(cli/unstable): move unit related stuff to separate file

Open timreichen opened this issue 6 months ago • 3 comments

This PR removes ProgressBarFormatter.styledData and moves all unit related functions and types inside _unit.ts. Reasoning There are several kinds of ProgressBars. A download progress bar is unit based, but percentage based and task based progress bars do not use units at all.

[##########----------------------------------------] 20%
[##########----------------------------------------] 20/100

The default formatter styles the units already. Imo we should not special treat the unit based progress bar by providing a opinionated styledData and instead provide some kind of unit formatter in @std/fmt/bytes which can be pointed to for custom formats, binary as well as decimal.

timreichen avatar May 28 '25 21:05 timreichen

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.69%. Comparing base (3d44532) to head (a4728f1). Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6693      +/-   ##
==========================================
- Coverage   94.70%   94.69%   -0.01%     
==========================================
  Files         567      568       +1     
  Lines       46793    46792       -1     
  Branches     6582     6582              
==========================================
- Hits        44315    44310       -5     
- Misses       2436     2440       +4     
  Partials       42       42              

: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 28 '25 21:05 codecov[bot]

There are several kinds of ProgressBars. A download progress bar is unit based, but percentage based and task based progress bars do not use units at all.

I see this point, but I don't think removing styledData solves this

kt3k avatar May 29 '25 03:05 kt3k

There are several kinds of ProgressBars. A download progress bar is unit based, but percentage based and task based progress bars do not use units at all.

I see this point, but I don't think removing styledData solves this

Ok, I reverted the removal of ProgressBarFormatter.styledData for now. This is related to https://github.com/denoland/std/pull/6696 and the code overlaps somewhat and could be reduced in a future PR.

timreichen avatar May 30 '25 17:05 timreichen

Note: This increases the amount of calculation because unit and rate are calculated at each rendering. However this also makes the output more correct because now we allow to change max value of progress (unit and rate can be changed at each rendering)

kt3k avatar Jun 02 '25 01:06 kt3k