Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The use of
this
in this function is expected (required, even), so suppress that lint.The use of
arguments
, however, isn't required, so I replaced it.This function isn't like other debounce functions I've seen: it allows you to pass a set of default arguments at creation-time, and in the absence of arguments being passed at call-time you get the defaults. That sounds reasonable enough (although a more conventional way to do this would be to use
bind()
).The weirder thing, though, is what happens if you supply defaults at creation-time and also pass arguments at call-time: in this case, the wrapped function ends up getting called with the defaults appended to the call-time args. I can't imagine a scenario in which this behavior would be non-surprising or useful, and the test suite doesn't even exercise this behavior, so perhaps this is accidental design (it does verify that default args get used in the absence of calltime args).
In any case, I am leaving the behavior intact and just making the changes to satisfy the linter. If we want, we can separately remove the weird concatenating behavior.
Usual test plan:
npm run dev && npm run text && npm run start
and play with demo.Related: #990