advanced-js-kit
Version:
Modern TypeScript utility library with tree-shaking support - Array, String, Number, Network, Sleep, and JWT utilities for JavaScript and TypeScript projects
44 lines (42 loc) • 1.54 kB
TypeScript
/**
* Environment detection utilities
*/
/**
* Determines if the current environment is Node.js
* @returns true if running in Node.js, false otherwise
*/
declare function isNodeEnvironment(): boolean;
/**
* Determines if the current environment is a browser
* @returns true if running in a browser, false otherwise
*/
declare function isBrowserEnvironment(): boolean;
/**
* Determines if the current environment is a web worker
* @returns true if running in a web worker, false otherwise
*/
declare function isWebWorkerEnvironment(): boolean;
/**
* Gets the current runtime environment
* @returns 'node' | 'browser' | 'webworker' | 'unknown'
*/
declare function getEnvironment(): 'node' | 'browser' | 'webworker' | 'unknown';
/**
* Error thrown when functionality is not supported in the current environment
*/
declare class EnvironmentError extends Error {
readonly requiredEnvironment: string;
readonly currentEnvironment: string;
constructor(message: string, requiredEnvironment: string, currentEnvironment: string);
}
/**
* Asserts that the current environment is Node.js
* @throws {EnvironmentError} if not running in Node.js
*/
declare function assertNodeEnvironment(): void;
/**
* Asserts that the current environment is a browser
* @throws {EnvironmentError} if not running in a browser
*/
declare function assertBrowserEnvironment(): void;
export { EnvironmentError, assertBrowserEnvironment, assertNodeEnvironment, getEnvironment, isBrowserEnvironment, isNodeEnvironment, isWebWorkerEnvironment };