14 lines
226 B
TypeScript
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)
|
|
}
|
|
}
|