Created
August 4, 2022 17:37
-
-
Save gfldex/4c1ef3ad5c27aa3a1f176fcbdd1f22cb to your computer and use it in GitHub Desktop.
This file contains 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
use v6.d; | |
# my @loop = |("\x1F550" .. "\x1F55B") xx *; | |
# react whenever Supply.interval(0.1) { | |
# state $it = @loop.iterator; | |
# print "\b\b" ~ $it.pull-one; | |
# } | |
sub progress-bar($max, $width = 10) { | |
sub ($current) { | |
return if $current > $max; | |
my $progress = round(try { $current / $max * ($width - 2) } // 0); | |
print "\b" x $width ~ '[' ~ ('#' x $progress) ~ (' ' x (($width - 2) - $progress)) ~ ']'; | |
} | |
} | |
my &bar = progress-bar(3000, 25); | |
react whenever Supply.interval(0.01) { | |
bar($++); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment