Add service.
This commit is contained in:
parent
4094afff3d
commit
adfaa2afe2
6 changed files with 86 additions and 3 deletions
14
src/lib/debounce.ts
Normal file
14
src/lib/debounce.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue