Zizzamia/perfume.js

View on GitHub
src/isSupported.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { WP } from './constants';

/**
 * True if the browser supports the Navigation Timing API,
 * User Timing API and the PerformanceObserver Interface.
 * In Safari, the User Timing API (performance.mark()) is not available,
 * so the DevTools timeline will not be annotated with marks.
 * Support: developer.mozilla.org/en-US/docs/Web/API/Performance/mark
 * Support: developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver
 * Support: developer.mozilla.org/en-US/docs/Web/API/Performance/getEntriesByType
 */
export const isPerformanceSupported = (): boolean =>
  WP && !!WP.getEntriesByType && !!WP.now && !!WP.mark;