# os

A Node.js-compatible implementation of the core os module

Availability
8.1.0
8.1.0
9.2.0
Extends
Object

NOTE

This is an abstract type. Any object of this structure can be used where this type is used.

# Overview

Titanium provides a number of shims and ports of core Node.js module functionality.

This module is intended to provide a Node-compatible port of the os core module.

More details on the Node.js API can be found in their os module documentation (opens new window)

# Properties

# constants

Availability
8.1.0
8.1.0
9.2.0
constants :os.constants

Contains commonly used operating system-specific constants for error codes, process signals, and so on.

# Methods

# arch

Availability
8.1.0
8.1.0
9.2.0
arch() String

Returns the operating system CPU architecture for which the binary was compiled. Possible values are return 'arm', 'arm64', 'ia32', 'x64', 'mips', and 'unknown'.

The return value is equivalent to arch. Relates strongly to architecture.

Returns

Type
String

# cpus

Availability
8.1.0
8.1.0
9.2.0
cpus() Array<CPUInfo>

Returns an array of objects containing information about each logical CPU core.

Returns

Type
Array<CPUInfo>

# endianness

Availability
8.1.0
8.1.0
9.2.0
endianness() String

Returns a string identifying the endianness of the CPU for which the binary was compiled.

Possible values are 'BE' for big endian and 'LE' for little endian.

Related to getNativeByteOrder() on Titanium.

Returns

Type
String

# freemem

Availability
8.1.0
8.1.0
9.2.0
freemem() Number

Returns the amount of free system memory in bytes as an integer.

Returns

Type
Number

# getPriority

Availability
8.1.0
8.1.0
9.2.0
getPriority([pid]) Number

Returns the scheduling priority for the process specified by pid. If pid is not provided or is 0, the priority of the current process is returned.

Titanium's shim, will always return 0.

Parameters

Name Type Description
pid Number

The process ID to retrieve scheduling priority for.

Returns

Type
Number

# homedir

Availability
8.1.0
8.1.0
9.2.0
homedir() String

Returns the string path of the current user's home directory.

On Titanium, returns the same value as applicationDataDirectory.

Returns

Type
String

# hostname

Availability
8.1.0
8.1.0
9.2.0
hostname() String

Returns the host name of the operating system as a string. On Titanium, this will return the value of address

Returns

Type
String

# loadavg

Availability
8.1.0
8.1.0
9.2.0
loadavg() Array<Number>

Returns an array containing the 1, 5, and 15 minute load averages.

On Titanium, the return value is always [0, 0, 0].

Returns

Type
Array<Number>

# networkInterfaces

Availability
8.1.0
8.1.0
9.2.0
networkInterfaces() Object

Returns an object containing network interfaces that have been assigned a network address.

Each key on the returned object identifies a network interface. The associated value is an array of objects that each describe an assigned network address.

On Titanium, an empty object ({}) is always returned.

Returns

Type
Object

# platform

Availability
8.1.0
8.1.0
9.2.0
platform() String

Returns a string identifying the operating system platform. Possible values are 'android', 'iphone', 'ipad', 'windowsphone', and 'windowsstore'.

The return value is equivalent to platform.

On Titanium, this is equivalent to osname.

Returns

Type
String

# release

Availability
8.1.0
8.1.0
9.2.0
release() String

Returns the operating system as a string.

On Titanium, this is equivalent to version.

Returns

Type
String

# setPriority

Availability
8.1.0
8.1.0
9.2.0
setPriority([pid, priority]) void

Attempts to set the scheduling priority for the process specified by pid. If pid is not provided or is 0, the process ID of the current process is used.

On Titanium, this method is a no-op.

Parameters

Name Type Description
pid Number

The process ID to set scheduling priority for.

priority Number

The scheduling priority to assign to the process.

Returns

Type
void

# tmpdir

Availability
8.1.0
8.1.0
9.2.0
tmpdir() String

Returns the operating system's default directory for temporary files as a string.

On Titanium, this is equivalent to tempDirectory.

Returns

Type
String

# totalmem

Availability
8.1.0
8.1.0
9.2.0
totalmem() Number

Returns the total amount of system memory in bytes as an integer.

On Titanium, this is equivalent to <Ti.Platform.totalMemory>.

Returns

Type
Number

# type

Availability
8.1.0
8.1.0
9.2.0
type() String

Returns the operating system as a string.

On Titanium, this returns 'Darwin' for iOS, or 'Linux' for Android. May return 'Unknown' for others.

Returns

Type
String

# uptime

Availability
8.1.0
8.1.0
9.2.0
uptime() Number

Returns the system uptime in number of seconds.

On Titanium, this is equivalent to uptime.

Returns

Type
Number

# userInfo

Availability
8.1.0
8.1.0
9.2.0
userInfo([options]) OSUserInfo

Returns information about the currently effective user.

Parameters

Name Type Description
options EncodingOptions

Simple object with encoding property. Ignored on Titanium.

Returns

# Constants

# EOL

Availability
8.1.0
8.1.0
9.2.0
EOL :String

The operating system-specific end-of-line marker.

\n on POSIX \r\n on Windows