global

Global helper functions.

var filename = 'script.js';
try {
    load(filename);
} catch(e) {
    console.log("Could not open '" + filename + "': " + e.message)
}
console.log( process.cwd( )  + '\n' + __dirname + '\n' + __filename + '\n' );
var t = setTimeout( function() {
    console.log( "Nidium" );}, 1000 );
clearTimeout( t );
var t = setInterval( console.log, 1000, "Nidium" );
clearInterval( t );

btoa(binary) (static)

Encode binary string to an base64 encodedstring.

Arguments:
binary (String)

The binary to encode.

Returns: String

The encoded string on base64

clearInterval(identifier) (static)

Stop a specified interval timer.

Arguments:
identifier (Integer)

Timer identifier returned by 'global.setInterval'.

clearTimeout(identifier) (static)

Stop a specified timeout timer.

Arguments:
identifier (Integer)

Timer identifier returned by 'global.setTimeout'.

load(path) (static)

Load the specified script in a synchronous way.

The given JavaScript file will be loaded in the global scope. That is, every variables defined in it will be defined on the global scope.

This function is only available if the nidium application is running a NML file that was loaded from a local source (e.g. file://) The 'path' is relative to the NML file that run the current application.

Arguments:
path (String)

The javascript sourcefile that needs to be imported

require(path) (static)

require implementation similar to NodeJS require().

Arguments:
path (String)

modulename

Returns: String

modulename

setImmediate(fn[, args]) (static)

This is meant to replace the old hack of setting a timer to 0ms.

Every 'setImmediate` callback is executed after the I/O completion but before all the other timers.

Arguments:
fn (Function)

The function to be called

args (Any[])

mixed

Returns: Void

This always returns 'null'; thus it means that it cannot be canceled with a 'global.clearTimeout'.

setInterval(fn, timeout=8, args=T) (static)

Calls a function repeatedly, with a fixed time delay between each call to that function.

Arguments:
fn (Function)

The function to be called

timeout (Integer)

timeout in milliseconds

args (Any[])

mixed

Returns: Integer

An identifier representing the timer that can be used to stop the timer with 'global.clearInterval'

setTimeout(fn, timeout, args) (static)

Calls a function after a time delay has passed.

Arguments:
fn (Function)

The function to be called

timeout (Integer)

timeout in milliseconds

args (Any)

argument for the callback

Returns: Integer

An identifier representing the timer that can be used to stop the timer with 'global.clearTimeout'

Debug(readonly)

  • Type: Object

Interfaces to the NidiumDebug class.

var d = {a:1, b: "a"};
var s = Debug.serialize(d);
var u = Debug.unserialize(s)
console.log(JSON.stringify(u));

__dirname(readonly)

  • Type: String

The path (without the filename) of the current JavaScript file ending with a '/'.

__filename(readonly)

  • Type: String

The path (with the filename) of the current JavaScript file.

modules(readonly)

  • Type: Module[]

Exposed Modules.

process(readonly)

  • Type: Object

Instance of the the NidiumProcess class.

console.log(JSON.stringify(process));

window

  • Type: Window

The main window object.


Caught a mistake or want to contribute to the documentation? Edit this page on GitHub!