UNPKG

user-device-type

Version:

**Browser, OS, and device detection based on the available user agent string. Can be used both in a browser (also as a standalone script) or in a server environment.**

8 lines (7 loc) 661 B
function a(e) { const t = /Mobile|Android|iP(hone|od)|BlackBerry|IEMobile|Silk|Opera Mini|Fennec|webOS|Windows Phone|PlayStation Vita/i, o = /Tablet|iPad|Nexus 7|Nexus 9|Kindle|Silk|Fennec/i, i = /Win(dows NT|dows NT 10.0|dows NT 6.1|dows NT 6.2|dows NT 6.3|dows NT 5.1|dows NT 5.2|dows NT 6.0|dows NT 5.0)|Macintosh|Intel Mac OS X|Linux|Ubuntu|CrOS/i, n = /SmartTV|AppleTV|GoogleTV|HbbTV|NetCast|WebTV|Tizen|Roku|Xbox|PlayStation|CrKey|DIAL/i; return /Watch|Wearable|Google Glass|SmartWatch|Gear/i.test(e) ? "wearable" : n.test(e) ? "tv" : o.test(e) ? "tablet" : t.test(e) ? "mobile" : i.test(e) ? "desktop" : "unknown"; } export { a as getDeviceType };