JSPM

@bonsai-components/detect-os

0.1.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 236
    • Score
      100M100P100Q94111F
    • License (MIT OR Apache-2.0)

    Make detecting user's OS less annoying

    Package Exports

    • @bonsai-components/detect-os
    • @bonsai-components/detect-os/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@bonsai-components/detect-os) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Bonsai Logo

    Detect OS

    Intro

    This package aims to make detection of the user's operating system easy.

    How to install

    npm i @bonsai-components/detect-os

    How to use

    There are 3 different variants:

    • detectOSInBrowser - handles detection in the browser
    • detectOSInNodeProcess - handles detection in node
    • detectOS - universal detection (the most code delivered but handles universal usage)

    All variants work the same way () => 'mac' | 'windows' | 'other'. There is a const enum for typescript users to take advantage of as well.

    Common usage:

    import { detectOS } from '@bonsai-components/detect-os';
    
    switch (detectOS()) {
      case 'mac':
        // do something
        break;
      case 'windows':
        // do something
        break;
      case 'other':
        // do something
        break;
    }