1.0.3 • Published 2 years ago

get-os-name v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

get-os-name

This is a very simple and small npm package that gives you the operating system name of a client. It has no dependencies and uses JavaScript and the Navigator Web API, which has wide browser support.

Installation

npm install get-os-name

Important

To be more specific, this package uses navigator.userAgent. Keep in mind that browser users can change the value of this field if they want (UA spoofing).

Exports

Function nameReturn typeDescription
getOperatingSystemNamestringThe default package export. A function that returns the name of the operating system (e.g. "Windows"). Fallbacks to "Unknown".
isUNIXbooleanA function that returns true if the operating system is UNIX
isWindowsbooleanA function that returns true if the operating system is Windows
isMacOSbooleanA function that returns true if the operating system is macOS
isLinuxbooleanA function that returns true if the operating system is Linux
isAndroidbooleanA function that returns true if the operating system is Android
isIOSbooleanA function that returns true if the operating system is iOS

Usage

import getOperatingSystemName, {
  isUNIX,
  isWindows,
  isMacOS,
  isLinux,
  isAndroid,
  isIOS,
} from "get-os-name";

const osName = getOperatingSystemName()
const isOSNameUNIX = isUNIX()
const isOSNameWindows = isWindows()
const isOSNameMacOS = isMacOS()
const isOSNameLinux = isLinux()
const isOSNameAndroid = isAndroid()
const isOSNameIOS = isIOS()

Demo