@utilify/environment
Version:
A utility library for detecting the runtime environment (Node.js, browser, Deno, etc.) and various environment-specific properties.
2 lines (1 loc) • 1.29 kB
JavaScript
function e(){return"object"==typeof Bun&&Object.hasOwn(Bun,"version")}function n(){return"object"==typeof Deno&&Object.hasOwn(Deno,"version")}function o(){return"undefined"!=typeof global&&"undefined"!=typeof process}function t(){return o()||n()||e()||"undefined"==typeof window}function i(){if(!t())return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function r(){return"undefined"!=typeof window&&"undefined"!=typeof document}function u(){if(!t())return;if("userAgentData"in navigator)return navigator.userAgentData.platform;const e=navigator.userAgent;return/Android/i.test(e)?"Android":/iPhone|iPad|iPod/i.test(e)?"iOS":/Linux/i.test(e)?"Linux":/Windows/i.test(e)?"Windows":/Mac/i.test(e)?"macOS":"Unknown"}function f(){return"undefined"!=typeof DedicatedWorkerGlobalScope&&self instanceof DedicatedWorkerGlobalScope}function d(){return"undefined"!=typeof SharedWorkerGlobalScope&&self instanceof SharedWorkerGlobalScope}function a(){return"undefined"!=typeof ServiceWorkerGlobalScope&&self instanceof ServiceWorkerGlobalScope}function c(){return f()||d()||a()}export{u as getOS,r as isBrowser,e as isBun,f as isDedicatedWorker,n as isDeno,i as isMobile,o as isNode,t as isServer,a as isServiceWorker,d as isSharedWorker,c as isWebWorker};