UNPKG

bfs-process

Version:

An emulation of Node's process module. Used in BrowserFS.

137 lines (136 loc) 3.84 kB
/// <reference types="node" /> import TTY from './tty'; import { EventEmitter } from 'events'; /** * Partial implementation of Node's `process` module. * We implement the portions that are relevant for the filesystem. * @see http://nodejs.org/api/process.html * @class */ export default class Process extends EventEmitter { private startTime; private _cwd; /** * Changes the current working directory. * * **Note**: BrowserFS does not validate that the directory actually exists. * * @example Usage example * console.log('Starting directory: ' + process.cwd()); * process.chdir('/tmp'); * console.log('New directory: ' + process.cwd()); * @param [String] dir The directory to change to. */ chdir(dir: string): void; /** * Returns the current working directory. * @example Usage example * console.log('Current directory: ' + process.cwd()); * @return [String] The current working directory. */ cwd(): string; /** * Returns what platform you are running on. * @return [String] */ platform: any; /** * Number of seconds BrowserFS has been running. * @return [Number] */ uptime(): number; argv: string[]; readonly argv0: string; execArgv: string[]; stdout: TTY; stderr: TTY; stdin: TTY; domain: NodeJS.Domain; private _queue; nextTick(fun: any, ...args: any[]): void; execPath: string; abort(): void; env: { [name: string]: string; }; exitCode: number; exit(code: number): never; private _gid; getgid(): number; getegid(): number; setgid(gid: number | string): void; setegid(gid: number | string): void; getgroups(): number[]; setgroups(groups: number[]): void; private _errorCallback; setUncaughtExceptionCaptureCallback(cb: any): void; hasUncaughtExceptionCaptureCallback(): boolean; private _uid; getuid(): number; setuid(uid: number | string): void; geteuid(): number; seteuid(euid: number | string): void; cpuUsage(): { user: number; system: number; }; version: string; versions: { http_parser: string; node: string; v8: string; uv: string; zlib: string; ares: string; icu: string; modules: string; openssl: string; }; config: { target_defaults: { cflags: any[]; default_configuration: string; defines: string[]; include_dirs: string[]; libraries: string[]; }; variables: { clang: number; host_arch: string; node_install_npm: boolean; node_install_waf: boolean; node_prefix: string; node_shared_cares: boolean; node_shared_http_parser: boolean; node_shared_libuv: boolean; node_shared_zlib: boolean; node_shared_v8: boolean; node_use_dtrace: boolean; node_use_etw: boolean; node_use_openssl: boolean; node_shared_openssl: boolean; strict_aliasing: boolean; target_arch: string; v8_use_snapshot: boolean; v8_no_strict_aliasing: number; visibility: string; }; }; kill(pid: number, signal?: string): void; pid: number; ppid: number; title: string; arch: string; memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; private _mask; umask(mask?: number): number; hrtime(): [number, number]; openStdin(): TTY; emitWarning(warning: string | Error, name?: string, ctor?: Function): void; disconnect(): void; connected: boolean; }