Skip to content

Commit

Permalink
fix(useThrottleFn): check negative timeout (#2620)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaakian committed Feb 18, 2023
1 parent 820e28e commit a7238d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/shared/utils/filters.ts
Expand Up @@ -160,14 +160,14 @@ export function throttleFilter(ms: MaybeComputedRef<number>, trailing = true, le
invoke()
}
else if (trailing) {
return new Promise((resolve, reject) => {
lastValue = new Promise((resolve, reject) => {
lastRejector = rejectOnCancel ? reject : resolve
timer = setTimeout(() => {
lastExec = Date.now()
isLeading = true
resolve(invoke())
clear()
}, duration - elapsed)
}, Math.max(0, duration - elapsed))
})
}

Expand Down

0 comments on commit a7238d8

Please sign in to comment.