-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat: add withSemaphore
& withMutex
function
#331
base: main
Are you sure you want to change the base?
Conversation
withSemaphore
functionwithSemaphore
& withMutex
function
* const limitedFn = withMutex(() => ...) | ||
* limitedFn() | ||
* limitedFn(() => ...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This usage is not supported by the current type definitions. I assume we'll want to update this example, rather than allow overriding the base function?
* const limitedFn = withSemaphore({ capacity: 2 }, () => ...) | ||
* limitedFn() | ||
* limitedFn(() => ...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue here
Summary
Implements the
withSemaphore
function which creates a semaphoreRelated issue, if any:
Related discussion
For any code change,
Does this PR introduce a breaking change?
No
In addition
I struggled to initialize the function via the radashi cli because of
No radashi dependency found in package.json
error.https://app.warp.dev/block/FMHVZF6RUhM2jAIiADsEUR
Bundle impact
src/async/withMutex.ts
src/async/withSemaphore.ts
Footnotes
Function size includes the
import
dependencies of the function. ↩