Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Sep 14, 2024
1 parent 02216fd commit 75420c8
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions panel/models/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function run_scripts(node: Element): void {
}

function throttle(func: Function, limit: number): any {
let lastFunc: ReturnType<typeof setTimeout> | null
let lastFunc: ReturnType<typeof setTimeout> | undefined
let lastRan: number

return function(...args: any) {
Expand All @@ -84,10 +84,7 @@ function throttle(func: Function, limit: number): any {
func.apply(context, args)
lastRan = Date.now()
} else {
if (lastFunc) {
clearTimeout(lastFunc)
}

clearTimeout(lastFunc)
lastFunc = setTimeout(function() {
if ((Date.now() - lastRan) >= limit) {
func.apply(context, args)
Expand Down

0 comments on commit 75420c8

Please sign in to comment.