Module basic module

Module os

Operating system and file system processing module

Instructions:

1
var os = require('os');

Object

Service

Service Constructor, see Service

1
Service os.Service;

Static function

hostname

Query the host name of the current operating environment

1
static String os.hostname();

Return result:

  • String, Return hostname

endianness

Query the byte order of the current CPU

1
static String os.endianness();

Return result:

  • String, Return byte order

type

Query the operating system name of the current running environment

1
static String os.type();

Return result:

  • String, Returns the system name

release

Query the operating system version of the current operating environment

1
static String os.release();

Return result:

  • String, Return version information

homedir

Query the current user directory

1
static String os.homedir();

Return result:

  • String, Return directory string

arch

Query the current cpu environment

1
static String os.arch();

Return result:

  • String, Returns the cpu type, possible results are'amd64','arm','arm64','ia32'

loadavg

Query the operating environment for 1 minute, 5 minutes, 15 minutes average load

1
static Array os.loadavg();

Return result:

  • Array, Returns an array containing three load data

totalmem

Query the total memory of the operating environment, in bytes

1
static Long os.totalmem();

Return result:

  • Long, Return memory data

freemem

Query the available memory of the operating environment, in bytes

1
static Long os.freemem();

Return result:

  • Long, Return memory data

cpus

Query the number and parameters of the current operating environment cpu

1
static Array os.cpus();

Return result:

  • Array, Returns an array containing cpu parameters, each item corresponds to a cpu

cpuNumbers

Query the number of CPUs in the current operating environment

1
static Integer os.cpuNumbers();

Return result:

  • Integer, Returns the number of cpu

tmpdir

Query the temporary file directory of the current operating environment

1
static String os.tmpdir();

Return result:

  • String, Return to the temporary file directory

userInfo

Return the current effective user information

1
static Object os.userInfo(Object options = {});

Call parameters:

  • options: Object, the character encoding used to interpret the result string

Return result:

  • Object, Current effective execution user information

networkInterfaces

Query current operating environment network information

1
static Object os.networkInterfaces();

Return result:

  • Object, Return network card information

printerInfo

Query the printer information of the current host

1
static Array os.printerInfo();

Return result:

  • Array, Return printer information

openPrinter

Create a printer output object

1
static BufferedStream os.openPrinter(String name) async;

Call parameters:

  • name: String, printer name

Return result:


platform

Query the current platform name

1
static String os.platform();

Return result:

  • String, Returns the platform name, possible results are'darwin','freebsd','linux', or'win32'

time

Parse the time string or query the current time of the runtime environment

1
static Date os.time(String tmString = "");

Call parameters:

  • tmString: String, time string, the current time is queried by default

Return result:

  • Date, Returns the javascript Date object

dateAdd

Time calculation function, specify calculation time according to part

1 2 3
static Date os.dateAdd(Date d, Integer num, String part);

Call parameters:

  • d: Date, specifies the Date object used to calculate
  • num: Integer, specify the value of the operation
  • part: String, specify the time part of the operation, the received values ​​are: "year", "month", "day", "hour", "minute", "second"

Return result:

  • Date, Returns the javascript Date object

Static properties

timezone

Integer, query the current time zone of the operating environment

1
static readonly Integer os.timezone;

EOL

String, query the end-of-line identifier of the current operating environment, posix:\"\n\"; windows:\"\r\n\"

1
static readonly String os.EOL;