https://project.mdnd-it.cc/work_packages/94
This commit is contained in:
2025-08-23 04:25:28 +02:00
parent 725516ad6c
commit 19cfa031d0
25823 changed files with 1095587 additions and 2801760 deletions
+5
View File
@@ -0,0 +1,5 @@
export declare const isBrowser: boolean;
export declare const isWebWorker: boolean;
export declare const isNode: boolean;
export declare const isJsDom: boolean;
export declare const isDeno: boolean;
+29
View File
@@ -0,0 +1,29 @@
const isBrowser =
typeof window !== "undefined" && typeof window.document !== "undefined";
const isNode =
typeof process !== "undefined" &&
process.versions != null &&
process.versions.node != null;
const isWebWorker =
typeof self === "object" &&
self.constructor &&
self.constructor.name === "DedicatedWorkerGlobalScope";
/**
* @see https://github.com/jsdom/jsdom/releases/tag/12.0.0
* @see https://github.com/jsdom/jsdom/issues/1537
*/
const isJsDom =
(typeof window !== "undefined" && window.name === "nodejs") ||
(typeof navigator !== "undefined" &&
(navigator.userAgent.includes("Node.js") ||
navigator.userAgent.includes("jsdom")));
const isDeno =
typeof Deno !== "undefined" &&
typeof Deno.version !== "undefined" &&
typeof Deno.version.deno !== "undefined";
export { isBrowser, isWebWorker, isNode, isJsDom, isDeno };