feseur/src/lib/debounce.ts
2025-05-26 23:09:47 +02:00

14 lines
226 B
TypeScript

export class Debouncer {
last = 0
public constructor(
public timeout: number,
) {}
public should_skip() {
const now = Date.now()
const delay = now - this.last
this.last = now
return (delay < this.timeout)
}
}