UNPKG

@docusign/iam-sdk

Version:

Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@docusign/iam-sdk* API.

82 lines 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.detectRuntime = detectRuntime; /** * Detects the current runtime environment (Node.js, Deno, Bun, or Browser). */ function detectRuntime() { const gt = globalThis; if (isDeno(gt)) { return { runtime: "deno", version: gt.Deno.version.deno, }; } if (isBun(gt)) { return { runtime: "bun", version: gt.Bun.version, }; } if (isBrowser(gt)) { return { runtime: "browser", version: gt.navigator?.userAgent ?? "unknown", }; } if (isNode(gt)) { return { runtime: "node", version: gt.process.versions.node, }; } return { runtime: "unknown", version: "unknown", }; } function isDeno(globalThisObj) { if (typeof globalThisObj !== "object" || globalThisObj === null) { return false; } if (!("Deno" in globalThisObj)) { return false; } return true; } function isBun(globalThisObj) { if (typeof globalThisObj !== "object" || globalThisObj === null) { return false; } if (!("Bun" in globalThisObj)) { return false; } return true; } function isNode(globalThisObj) { if (typeof globalThis !== "object" || globalThis === null) { return false; } if (!("process" in globalThis)) { return false; } // Check if it has the node version property const process = globalThisObj.process; return (typeof process === "object" && process !== null && "versions" in process && typeof process.versions === "object" && process.versions !== null && "node" in process.versions); } function isBrowser(globalThisObj) { if (typeof globalThisObj !== "object" || globalThisObj === null) { return false; } // Check for the presence of window and document objects, which are browser-specific return ("window" in globalThisObj && "document" in globalThisObj && typeof globalThisObj.window === "object" && typeof globalThisObj.document === "object"); } //# sourceMappingURL=detect-runtime.js.map