Repository navigation
Add throttle() and keep this in debounce() - #81
Merged
Merged
Conversation
Runs the first call right away, then at most once per interval, with one trailing call that gets the latest arguments. Keeps the caller's this, so it works on handleEvent objects and methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PsQ2rEfRCb5esUCN5whWoy
Owner
Author
|
The Workers Builds: vanillapod check failure isn't from this PR. The same check also fails on the current Generated by Claude Code |
debounce() called fn with the debounced wrapper as this, so it broke on methods and handleEvent objects. Pass the caller's this instead, for both the trailing and the asap call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PsQ2rEfRCb5esUCN5whWoy
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Requested by Carl · project thread
Adds
throttle(fn, interval = 100)todom/utils.js, next todebounce().this, so it works as a method or on ahandleEventobject.Also fixes
debounce()so it passes the caller'sthistofn(it used to pass the debounced wrapper), for both the trailing and theasapcall.Neither function is exported from
dom/main.jsyet. Exporting them is a separate decision.Tests
Six new tests in
dom/utils.test.ts: four forthrottle()(leading call, trailing call, interval reset,this) and two fordebounce()'sthis.deno test,deno checkwithcheckJs,deno lintanddeno fmt --checkpass on the two files.https://claude.ai/code/session_01PsQ2rEfRCb5esUCN5whWoy
Generated by Claude Code