UNPKG

@gotake/gotake-sdk

Version:

SDK for interacting with GoTake blockchain contracts

39 lines (38 loc) 1.04 kB
/** * Safe environment detection utilities */ /** * Check if running in Node.js environment */ export function isNodeEnvironment() { return typeof process !== 'undefined' && process.versions != null && process.versions.node != null; } /** * Check if running in browser environment */ export function isBrowserEnvironment() { return typeof window !== 'undefined' && typeof document !== 'undefined'; } /** * Check if environment variables are available */ export function hasEnvironmentVariables() { return isNodeEnvironment() && typeof process !== 'undefined' && typeof process['env'] === 'object'; } /** * Safe environment variable getter */ export function getEnvironmentVariable(key, defaultValue) { if (!hasEnvironmentVariables()) { return defaultValue; } // Additional safety check before accessing environment variables if (typeof process === 'undefined' || !process['env']) { return defaultValue; } return process['env'][key] || defaultValue; }