diff options
| author | Terry Truong <terry06890@gmail.com> | 2023-01-21 15:23:51 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2023-01-21 16:17:31 +1100 |
| commit | c318c4cedf3f50c21c403649945c2abbbc30a89e (patch) | |
| tree | c74f967755c1b653a450973712a99bec65724f6a /src/util.ts | |
| parent | d581e5b61a771ef8619a5bfbc84a6e337c7ca13f (diff) | |
Do more minor refactoring
Document some variables coupled between client and server.
Add more term consistency ('unit', 'event density').
Make console messages more consistent.
Diffstat (limited to 'src/util.ts')
| -rw-r--r-- | src/util.ts | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/util.ts b/src/util.ts index bb0d162..ea9e76e 100644 --- a/src/util.ts +++ b/src/util.ts @@ -43,6 +43,7 @@ export function makeThrottled(hdlr: (...args: any[]) => void, delay: number){ timeout = window.setTimeout(async () => hdlr(...args), delay); }; } + // Like makeThrottled(), but accepts an async function export function makeThrottledAsync(hdlr: (...args: any[]) => Promise<void>, delay: number){ let timeout = 0; @@ -51,6 +52,7 @@ export function makeThrottledAsync(hdlr: (...args: any[]) => Promise<void>, dela timeout = window.setTimeout(async () => await hdlr(...args), delay); }; } + // Like makeThrottled(), but, for runs of fast handler calls, calls it at spaced intervals, and at the start/end export function makeThrottledSpaced(hdlr: (...args: any[]) => void, delay: number){ let lastHdlrTime = 0; // Used for throttling |
