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

Throttle command #45

Merged
merged 1 commit into from
Jul 13, 2024
Merged

Throttle command #45

merged 1 commit into from
Jul 13, 2024

Conversation

zoe-codez
Copy link
Member

@zoe-codez zoe-codez commented Jul 13, 2024

Changes

  • add new helper function throttle
async function doTheThing() {
	await throttle("throttle_based_on", 100 /* within ms */);
}

Throttle will wait for ms, like sleep, then returns void
If it gets called multiple times within the time window, the previous call will not resolve, but the time window will be pushed out.

This can be particularly helpful for event callbacks where it may receive many calls in a short burst, but it it only really needs to run once

Checklist

  • Read the contribution guide and accept the
    code of conduct
  • Readme and docs (updated or not needed)
  • Tests (added, updated or not needed)

Copy link

codecov bot commented Jul 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.33%. Comparing base (7b6be1c) to head (c97b2e1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #45      +/-   ##
==========================================
+ Coverage   70.77%   71.33%   +0.55%     
==========================================
  Files          30       30              
  Lines        1362     1371       +9     
  Branches      186      187       +1     
==========================================
+ Hits          964      978      +14     
+ Misses        384      379       -5     
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zoe-codez zoe-codez merged commit 4d2cd99 into main Jul 13, 2024
3 checks passed
@zoe-codez zoe-codez deleted the throttle branch July 13, 2024 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant