@beenotung/tslib
Version:
utils library in Typescript
24 lines • 766 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectMobilePlatform = void 0;
function detectMobilePlatform() {
if (typeof navigator === 'undefined' &&
(typeof window === 'undefined' ||
typeof window.opera === 'undefined')) {
// not browser env
return 'unknown';
}
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/windows phone/i.test(userAgent)) {
return 'Windows Phone';
}
if (/android/i.test(userAgent)) {
return 'Android';
}
if (/ipad|iphone|ipod/i.test(userAgent)) {
return 'iOS';
}
return 'unknown';
}
exports.detectMobilePlatform = detectMobilePlatform;
//# sourceMappingURL=platform.js.map