fix(striker-ui): add helper functions to work with time

main
Tsu-ba-me 1 year ago
parent 3cb1b2fa55
commit d1b7969c94
  1. 23
      striker-ui/lib/time.ts

@ -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…
Cancel
Save