Skip to content

Commit f3106ae

Browse files
committed
made debounce and rate limiter able to handle 0
1 parent 07cddd6 commit f3106ae

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

library/src/utils/debounce.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export function debounceHelper(delayMS = 300) {
1717
clearTimeout(timer)
1818
}
1919

20-
if (delayMS <= 0) {
21-
throw new Error("delay must be positive and above 0")
20+
if (delayMS < 0) {
21+
throw new Error("delay must be a positive number")
2222
}
2323

2424
timer = window.setTimeout(() => {

library/src/utils/idleRateLimit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export function idleRateLimitHelper(
1313
) {
1414
let lastTime = 0
1515
let timeoutRunning = 0
16-
if (timeoutMS !== undefined && timeoutMS <= 0) {
17-
throw new Error("minDistanceMS must be positive and above 0")
16+
if (timeoutMS !== undefined && timeoutMS < 0) {
17+
throw new Error("timeoutMS must be a positive number")
1818
}
1919

2020
// eslint-disable-next-line @typescript-eslint/no-explicit-any

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"@types/node": "^22.13.10",
136136
"@types/react": "^18.3.18",
137137
"@types/react-dom": "^18.3.5",
138-
"@vitejs/plugin-react-swc": "^3.8.0",
138+
"@vitejs/plugin-react-swc": "^3.8.1",
139139
"eslint-plugin-react-refresh": "^0.4.19",
140140
"prettier-plugin-tailwindcss": "^0.6.11",
141141
"process": "^0.11.10",

0 commit comments

Comments
 (0)