Skip to content

Runtime

Runtime global object holds information about os, process and runtime.

Runtime.platform

Returns current platform as a string

Runtime.platform // "linux"

Possible values:

  • linux
  • win32
  • darwin
  • freebsd
  • openbsd
  • unix
  • unknown

Runtime.pid

Returns process id (number).

Runtime.pid // 2144

Runtime.version

Returns PandJS’s version as a string - semantic version prefixed with v (for example "v1.0.0")

Runtime.version // "v.1.0.3"

Runtime.argv

Returns the script arguments (as an array of strings) to the program.

Terminal window
pand ./your-script.js arg1 arg2 ... argN
Runtime.argv.forEach(item => {
console.log(`Arg: ${item}`);
});
// output:
Arg: pand
Arg: ./your-script.js
Arg: arg1
Arg arg2
...
Arg: argN

Runtime.cwd()

Returns current working directory as a string.

Runtime.cwd() // "/home/example/Wokrspace"

Runtime.exit()

Forcefully exits process without waiting for pending operations.

Runtime.exit(1) // exit process with status 1 (error)

Runtime.sleep()

Pauses the execution of the main thread for the specified number of milliseconds.

Runtime.sleep(2000)