parent
3cb1b2fa55
commit
d1b7969c94
1 changed files with 23 additions and 0 deletions
@ -0,0 +1,23 @@ |
|||||||
|
const before = (time: number, limit: number): boolean => { |
||||||
|
const diff = time - limit; |
||||||
|
|
||||||
|
return diff > 0; |
||||||
|
}; |
||||||
|
|
||||||
|
const last = ( |
||||||
|
time: number, |
||||||
|
duration: number, |
||||||
|
{ ms }: { ms?: boolean } = {}, |
||||||
|
): boolean => { |
||||||
|
let now = Date.now(); |
||||||
|
|
||||||
|
if (!ms) { |
||||||
|
now /= 1000; |
||||||
|
} |
||||||
|
|
||||||
|
const diff = now - time; |
||||||
|
|
||||||
|
return diff <= duration; |
||||||
|
}; |
||||||
|
|
||||||
|
export { before, last }; |
Loading…
Reference in new issue