get-os-name

1.0.3 • Public • Published

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 name Return type Description
getOperatingSystemName string The default package export. A function that returns the name of the operating system (e.g. "Windows"). Fallbacks to "Unknown".
isUNIX boolean A function that returns true if the operating system is UNIX
isWindows boolean A function that returns true if the operating system is Windows
isMacOS boolean A function that returns true if the operating system is macOS
isLinux boolean A function that returns true if the operating system is Linux
isAndroid boolean A function that returns true if the operating system is Android
isIOS boolean A 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

Package Sidebar

Install

npm i get-os-name

Weekly Downloads

10

Version

1.0.3

License

MIT

Unpacked Size

7.01 kB

Total Files

6

Last publish

Collaborators

  • xulw