0.1.8 • Published 8 months ago
@bonsai-components/detect-os v0.1.8
Detect OS
Intro
This package aims to make detection of the user's operating system easy.
How to install
npm i @bonsai-components/detect-osHow to use
There are 3 different variants:
detectOSInBrowser- handles detection in the browserdetectOSInNodeProcess- handles detection in nodedetectOS- 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;
}