Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created November 15, 2022 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfldex/c69612be47e078d090467bf3972fc3f2 to your computer and use it in GitHub Desktop.
Save gfldex/c69612be47e078d090467bf3972fc3f2 to your computer and use it in GitHub Desktop.
sub limit-rate(Supply $in, $per-seconds = 1 --> Supply:D) {
my $out = Supplier::Preserving.new;
start react whenever $in -> \value {
$out.emit: value;
sleep(1 / $per-seconds);
}
$out.Supply;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment