|
|
@ -13,12 +13,12 @@ export function isExternal(path: string): boolean {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function throttleAndDebounce(fn: () => void, delay: number): () => void {
|
|
|
|
export function throttleAndDebounce(fn: () => void, delay: number): () => void {
|
|
|
|
let timeout: any
|
|
|
|
let timeoutId: NodeJS.Timeout
|
|
|
|
let called = false
|
|
|
|
let called = false
|
|
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
return () => {
|
|
|
|
if (timeout) {
|
|
|
|
if (timeoutId) {
|
|
|
|
clearTimeout(timeout)
|
|
|
|
clearTimeout(timeoutId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!called) {
|
|
|
|
if (!called) {
|
|
|
@ -28,7 +28,7 @@ export function throttleAndDebounce(fn: () => void, delay: number): () => void {
|
|
|
|
called = false
|
|
|
|
called = false
|
|
|
|
}, delay)
|
|
|
|
}, delay)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
timeout = setTimeout(fn, delay)
|
|
|
|
timeoutId = setTimeout(fn, delay)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|