Skip to content

Commit 461a2e4

Browse files
committed
changed throttle function param names
1 parent 46cd0fa commit 461a2e4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/backend/helpers.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ const JSXParser = acorn.Parser.extend(jsx());
1515

1616
/**
1717
* @method throttle
18-
* @param f A function to throttle
19-
* @param t A number of milliseconds to use as throttling interval
20-
* @returns A function that limits input function, `f`, from being called more than once every `t` milliseconds
18+
* @param callback A function to throttle
19+
* @param ms A number of milliseconds to use as throttling interval
20+
* @returns A function that limits input function, `callback`, from being called more than once every `ms` milliseconds
2121
*
2222
*/
23-
export const throttle = (f: Function, t: number): Function => {
23+
export const throttle = (callback: Function, ms: number): Function => {
2424
// Initialize boolean flags for callback, throttledFunc
2525
let isOnCooldown = false;
2626
let isCallQueued = false;
@@ -42,7 +42,7 @@ export const throttle = (f: Function, t: number): Function => {
4242

4343
// CASE 3: If we are ready to "fire":
4444
// Execute the function, f, immediately
45-
f();
45+
callback();
4646
// Initiate a new cooldown period and reset the "call queue"
4747
isOnCooldown = true;
4848
isCallQueued = false;
@@ -53,14 +53,14 @@ export const throttle = (f: Function, t: number): Function => {
5353
if (isCallQueued) {
5454
isCallQueued = false;
5555
isOnCooldown = true; // not needed I think
56-
f();
57-
setTimeout(runAfterTimeout, t);
56+
callback();
57+
setTimeout(runAfterTimeout, ms);
5858
return;
5959
}
6060
isOnCooldown = false;
6161
};
6262

63-
setTimeout(runAfterTimeout, t);
63+
setTimeout(runAfterTimeout, ms);
6464
};
6565

6666
return throttledFunc;

0 commit comments

Comments
 (0)