fix(striker-ui): isolate now function in time helpers

main
Tsu-ba-me 1 year ago
parent 813767f85a
commit 5e0f5133e7
  1. 18
      striker-ui/lib/time.ts

@ -4,18 +4,20 @@ const before = (time: number, limit: number): boolean => {
return diff > 0;
};
const now = (ms?: boolean): number => {
let nao = Date.now();
if (!ms) nao /= 1000;
return nao;
};
const last = (
time: number,
duration: number,
{ ms }: { ms?: boolean } = {},
): boolean => {
let now = Date.now();
if (!ms) {
now /= 1000;
}
const diff = now - time;
const diff = now(ms) - time;
return diff <= duration;
};
@ -62,4 +64,4 @@ const elapsed = (
};
};
export { before, elapsed, last };
export { before, elapsed, last, now };

Loading…
Cancel
Save