@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
23 lines (22 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isPerformanceAPIAvailable = isPerformanceAPIAvailable;
exports.isPerformanceObserverAvailable = isPerformanceObserverAvailable;
exports.isPerformanceObserverLongTaskAvailable = isPerformanceObserverLongTaskAvailable;
var hasRequiredPerformanceAPIs;
function isPerformanceAPIAvailable() {
if (hasRequiredPerformanceAPIs === undefined) {
hasRequiredPerformanceAPIs = typeof window !== 'undefined' && 'performance' in window && ['measure', 'clearMeasures', 'clearMarks', 'getEntriesByName', 'getEntriesByType', 'now'].every(function (api) {
return !!performance[api];
});
}
return hasRequiredPerformanceAPIs;
}
function isPerformanceObserverAvailable() {
return !!(typeof window !== 'undefined' && 'PerformanceObserver' in window);
}
function isPerformanceObserverLongTaskAvailable() {
return isPerformanceObserverAvailable() && PerformanceObserver.supportedEntryTypes && PerformanceObserver.supportedEntryTypes.includes('longtask');
}