-
Notifications
You must be signed in to change notification settings - Fork 25
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 once
function
#80
Conversation
src/curry/once.ts
Outdated
@@ -0,0 +1,55 @@ | |||
const onceResult = '__once__' |
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.
We can use Symbol
to avoid any potential collisions (but I don't expect too much of them 😄 )
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.
I did that originally, but since we use isolated declarations, we would have to export the symbol :)
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.
Okay, I found a way to use a symbol without exporting it! I'm also using that same symbol to represent an uncalled state, instead of using the in
and delete
operators.
Tip
The owner of this PR can publish a preview release by commenting
/publish
in this PR. Afterwards, anyone can try it out by runningpnpm add radashi@pr<PR_NUMBER>
.Summary
once
function that mimicslodash.once
but with less bloat.once.reset
function that allows a “onced” function to be called again.For any code change,
Does this PR introduce a breaking change?
No