UNPKG

@nasriya/atomix

Version:

Composable helper functions for building reliable systems

85 lines (84 loc) 2.86 kB
declare class Runtime { /** * Gets the name of the project. * @returns The name of the project. * @since v1.0.0 */ getProjectName(): string; /** * Determines the module system being used. * * @returns 'commonjs' or 'module'. * @since v1.0.0 */ getModuleSystem(): 'commonjs' | 'module'; /** * Asynchronously loads a module by name, either as a file or a package. * * @param name - The name or path of the module to load. * @param options - Optional settings for loading the module. * @param options.isFile - If true, treats the name as a file path. Defaults to false. * @returns A promise that resolves to the loaded module. * @throws Error with an appropriate message if the module cannot be loaded. * @since v1.0.0 */ loadModule(name: string, options?: { isFile?: boolean; }): Promise<any>; /** * Asynchronously loads a module from a specified file path. * * @param filePath - The path to the file to load as a module. * @returns A promise that resolves to the loaded module. * @throws Error with an appropriate message if the module cannot be loaded. * @since v1.0.0 */ loadFileModule(filePath: string): Promise<any>; readonly platform: { /** * Determines if the current platform is Windows. * * @returns True if the current platform is Windows, false otherwise. * @since v1.0.0 */ isWindows: () => boolean; /** * Determines if the current platform is Linux. * @returns True if the current platform is Linux, false otherwise. * @since v1.0.0 */ isLinux: () => boolean; /** * Determines if the current platform is macOS. * @returns True if the current platform is macOS, false otherwise. * @since v1.0.0 */ isMac: () => boolean; }; /** * Checks if the current environment is Node.js. * @returns true if the environment is Node.js, false otherwise. * @since v1.0.0 */ isNode(): boolean; /** * Checks if the current environment is Bun. * @returns true if the environment is Bun, false otherwise. * @since v1.0.0 */ isBun(): boolean; /** * Checks if the current environment is Deno. * @returns true if the environment is Deno, false otherwise. * @since v1.0.0 */ isDeno(): boolean; /** * Gets the name of the runtime engine (Node.js, Bun, Deno, etc.) that is currently being used. * @returns The name of the runtime engine, or 'unknown' if the engine could not be determined. * @since v1.0.0 */ getRuntimeEngine(): 'node' | 'bun' | 'deno' | 'unknown'; } declare const runtime: Runtime; export default runtime;