You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
652 B

4 months ago
  1. let supported;
  2. let perf;
  3. export function isPerformanceSupported() {
  4. var _a;
  5. if (supported !== undefined) {
  6. return supported;
  7. }
  8. if (typeof window !== 'undefined' && window.performance) {
  9. supported = true;
  10. perf = window.performance;
  11. }
  12. else if (typeof globalThis !== 'undefined' && ((_a = globalThis.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) {
  13. supported = true;
  14. perf = globalThis.perf_hooks.performance;
  15. }
  16. else {
  17. supported = false;
  18. }
  19. return supported;
  20. }
  21. export function now() {
  22. return isPerformanceSupported() ? perf.now() : Date.now();
  23. }