@bonsai-components/detect-os
Version:
Make detecting user's OS less annoying
23 lines • 781 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectOSInBrowser = void 0;
function detectOSInBrowser() {
let platform = '';
if (typeof navigator !== 'undefined') {
if (navigator.userAgentData && navigator.userAgentData.platform) {
platform = navigator.userAgentData.platform;
}
else if (navigator.platform) {
platform = navigator.platform;
}
}
if (platform.toUpperCase().indexOf('MAC') >= 0) {
return "mac" /* OS.Mac */;
}
if (platform.toUpperCase().indexOf('WIN') >= 0) {
return "windows" /* OS.Windows */;
}
return "other" /* OS.Other */;
}
exports.detectOSInBrowser = detectOSInBrowser;
//# sourceMappingURL=detect-os-in-browser.js.map