Skip to main content

global (value)​

For compatibility with Node.js scripts, the global object is accessible via the global variable named "global".

Example

console.log(global === globalThis);
var global: typeof globalThis;

process (object)​

A process global is provided for rudimentary compatibility with Node.js scripts. It contains a subset of the properties found on the Node.js process global, which each forward to their corresponding yavascript API.

For instance, process.env is a getter that returns env, and process.argv is a getter that returns scriptArgs.

If you are writing yavascript-specific code, you should use yavascript's APIs instead of process.

Example

var process: {
version: string;
node: string;
yavascript: string;
unicode: string;
};
arch: string;
readonly env: {
[key: string]: string | undefined;
};
readonly argv: Array<string>;
readonly argv0: string;
readonly execPath: string;
exitCode: number;
exit(code?: number | null | undefined): void;
};

process.version (string property)​

version: string;

process.versions (object property)​

node: string;
yavascript: string;
unicode: string;
}

process.versions.node (string property)​

node: string;

process.versions.yavascript (string property)​

yavascript: string;

process.versions.unicode (string property)​

unicode: string;

process.arch (string property)​

arch: string;

process.env (readonly object property)​

Same as the global env.

Example

console.log(process.env.HOME);
readonly env: {
[key: string]: string | undefined;
};

process.argv (readonly property)​

Same as the global scriptArgs.

Example

const args = process.argv.slice(2);
console.log(args);
readonly argv: Array<string>;

process.argv0 (readonly string property)​

Same as scriptArgs[0].

Example

console.log(process.argv0);
readonly argv0: string;

process.execPath (readonly string property)​

Shortcut for os.realpath(os.execPath()), using the QuickJS os module.

Example

exec([process.execPath, "--version"]);
readonly execPath: string;

process.exitCode (number property)​

Uses std.getExitCode() and std.setExitCode() from the QuickJS std module.

Example

exitCode: number;

process.exit (method)​

Uses std.exit() from the QuickJS std module.

Example

if (process.argv.length < 3) {
console.error("Please specify an input file");
}
exit(code?: number | null | undefined): void;