Node.js globals

Static variables

staticread only__dirname:String

The name of the directory that the currently executing script resides in.

staticread only__filename:String

The filename of the code being executed. This is the resolved absolute path of this code file. For a main program this is not necessarily the same filename used in the command line. The value inside a module is the path to that module file.

staticread onlyconsole:Console

The global console is a special Console whose output is sent to process.stdout and process.stderr.

staticread onlyexports:Dynamic<Dynamic>

A reference to the module.exports that is shorter to type. See module system documentation for details on when to use exports and when to use module.exports. exports isn't actually a global but rather local to each module.

staticinlineread onlyglobal:Dynamic<Dynamic> = cast Node

The global namespace object.

staticread onlymodule:Module

A reference to the current module. In particular module.exports is used for defining what a module exports and makes available through require. module isn't actually a global but rather local to each module.

staticread onlyprocess:Process

The process object.

Static methods

staticclearImmediate (immediateObject:ImmediateObject):Void

Stops an immediate from triggering.

staticclearInterval (intervalObject:IntervalObject):Void

Stops a interval from triggering.

staticclearTimeout (timeoutObject:TimeoutObject):Void

Prevents a timeout from triggering.

staticinlinerequire (module:String):Dynamic

Fetches a library and returns the reference to it.

staticsetImmediate (callback:Function, args:Rest<Dynamic>):ImmediateObject

To schedule the "immediate" execution of callback after I/O events callbacks and before setTimeout and setInterval. Returns an ImmediateObject for possible use with clearImmediate. Optionally you can also pass arguments to the callback.

Immediates are queued in the order created, and are popped off the queue once per loop iteration. This is different from Process.nextTick which will execute Process.maxTickDepth queued callbacks per iteration. setImmediate will yield to the event loop after firing a queued callback to make sure I/O is not being starved. While order is preserved for execution, other I/O events may fire between any two scheduled immediate callbacks.

staticsetInterval (callback:Function, delay:Int, args:Rest<Dynamic>):IntervalObject

To schedule the repeated execution of callback every delay milliseconds. Returns a IntervalObject for possible use with clearInterval. Optionally you can also pass arguments to the callback.

staticsetTimeout (callback:Function, delay:Int, args:Rest<Dynamic>):TimeoutObject

To schedule execution of a one-time callback after delay milliseconds. Returns a TimeoutObject for possible use with clearTimeout. Optionally you can also pass arguments to the callback.