detect-os

v0.0.2arrow_drop_down
v0.0.2
v0.0.1
STATUS
Passing
DOWNLOADS
131
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 years ago
SIZE
924 B
Gets whether running on a certain operating system according to browser data.
1 contributor
Install detect-os as a package?
Copied
npm i @bit/tomlandau.simple-js.platform-detection.detect-os
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
platformDetection/detectOs ()

Gets whether running on a certain operating system according to browser data. Functions to test for a certain operating system (each returns bool):

  • isAndroid
  • isBlackBerry
  • isIos
  • isMac
  • isWindows
  • isLinux

Function to get the operating system by name:

  • get (possible return values: iOS, Android, Windows, Linux, Mac, BlackBerry, Unknown)
Example
```js
detectOs.isAndroid() => true/false
detectOs.isIos() => true/false
detectOs.isWindows() => true/false
detectOs.isBlackBerry() => true/false
detectOs.isMac() => true/false
detectOs.isLinux() => true/false
detectOs.get() => iOS/Android/Windows/Linux/Mac/BlackBerry/Unknown
```
Test Summary

detectOs .isAndroid should return true for Android userAgent even though platform is Linux

Pass

detectOs .isAndroid should return false for non Android userAgent

Pass

detectOs .isBlackBerry should return true for BlackBerry platform

Pass

detectOs .isBlackBerry should return false for non BlackBerry userAgent

Pass

detectOs .isIos should return true for iPhone platform

Pass

detectOs .isIos should return true for iPad platform

Pass

detectOs .isIos should return true for iPod platform

Pass

detectOs .isIos should return false for non iOS platform

Pass

detectOs .isMac should return true for Macintosh platform

Pass

detectOs .isMac should return true for MacIntel platform

Pass

detectOs .isMac should return true for MacPPC platform

Pass

detectOs .isMac should return true for Mac68K platform

Pass

detectOs .isMac should return false for non-mac platform

Pass

detectOs .isWindows should return true for Windows platform

Pass

detectOs .isWindows should return true for Win16 platform

Pass

detectOs .isWindows should return true for Win32 platform

Pass

detectOs .isWindows should return true for WinCE platform

Pass

detectOs .isWindows should return false for non-Windows platform

Pass

detectOs .isLinux should return true for Linux platform

Pass

detectOs .isLinux should return true for Linux aarch64 platform

Pass

detectOs .isLinux should return true for Linux armv5tejl platform

Pass

detectOs .isLinux should return true for Linux armv6l platform

Pass

detectOs .isLinux should return true for Linux armv7l platform

Pass

detectOs .isLinux should return true for Linux i686 on x86_64 platform

Pass

detectOs .isLinux should return true for Linux i686 X11 platform

Pass

detectOs .isLinux should return true for Linux ppc64 platform

Pass

detectOs .isLinux should return true for Linux x86_64 platform

Pass

detectOs .isLinux should return true for Linux x86_64 X11 platform

Pass

detectOs .isLinux should return false for Linux platform when user agent is Android

Pass

detectOs .isLinux should return false for non-Linux platform

Pass

detectOs .get should return Linux when os is Linux

Pass

detectOs .get should return Windows when os is Windows

Pass

detectOs .get should return Mac when os is Mac

Pass

detectOs .get should return iOS when os is iOS

Pass

detectOs .get should return Android when os is Android

Pass

detectOs .get should return BlackBerry when os is BlackBerry

Pass

detectOs .get should return Unknown for other os

Pass
Help and resources