Last active
July 8, 2022 07:26
-
-
Save AvocadoVenom/d6abe36ef32c6cf2bc4f30316479bec7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum DesktopOS { | |
Linux = 'linux', | |
MacOS = 'mac_os', | |
Unix = 'unix', | |
Unknown = 'unknown', | |
Windows = 'windows' | |
} | |
const getDesktopOS = (): DesktopOS | undefined => { | |
if (isDesktopDevice()) { | |
if (userAgent.indexOf('Win') !== -1) return DesktopOS.Windows | |
else if (userAgent.indexOf('Mac') !== -1) return DesktopOS.MacOS | |
else if (userAgent.indexOf('X11') !== -1) return DesktopOS.Unix | |
else if (userAgent.indexOf('Linux') !== -1) return DesktopOS.Linux | |
return DesktopOS.Unknown | |
} else return undefined | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment