{ "source": "doc/api/globals.md", "globals": [ { "textRaw": "Class: Buffer", "type": "global", "name": "Buffer", "meta": { "added": [ "v0.1.103" ] }, "desc": "\n

Used to handle binary data. See the buffer section.

\n" }, { "textRaw": "clearImmediate(immediateObject)", "type": "global", "name": "clearImmediate", "meta": { "added": [ "v0.9.1" ] }, "desc": "

clearImmediate is described in the timers section.

\n" }, { "textRaw": "clearInterval(intervalObject)", "type": "global", "name": "clearInterval", "meta": { "added": [ "v0.0.1" ] }, "desc": "

clearInterval is described in the timers section.

\n" }, { "textRaw": "clearTimeout(timeoutObject)", "type": "global", "name": "clearTimeout", "meta": { "added": [ "v0.0.1" ] }, "desc": "

clearTimeout is described in the timers section.

\n" }, { "textRaw": "console", "name": "console", "meta": { "added": [ "v0.1.100" ] }, "type": "global", "desc": "\n

Used to print to stdout and stderr. See the console section.

\n" }, { "textRaw": "global", "name": "global", "meta": { "added": [ "v0.1.27" ] }, "type": "global", "desc": "\n

In browsers, the top-level scope is the global scope. That means that in\nbrowsers if you're in the global scope var something will define a global\nvariable. In Node.js this is different. The top-level scope is not the global\nscope; var something inside an Node.js module will be local to that module.

\n" }, { "textRaw": "process", "name": "process", "meta": { "added": [ "v0.1.7" ] }, "type": "global", "desc": "\n

The process object. See the process object section.

\n" }, { "textRaw": "setImmediate(callback[, ...args])", "type": "global", "name": "setImmediate", "meta": { "added": [ "v0.9.1" ] }, "desc": "

setImmediate is described in the timers section.

\n" }, { "textRaw": "setInterval(callback, delay[, ...args])", "type": "global", "name": "setInterval", "meta": { "added": [ "v0.0.1" ] }, "desc": "

setInterval is described in the timers section.

\n" }, { "textRaw": "setTimeout(callback, delay[, ...args])", "type": "global", "name": "setTimeout", "meta": { "added": [ "v0.0.1" ] }, "desc": "

setTimeout is described in the timers section.

\n" } ], "vars": [ { "textRaw": "\\_\\_dirname", "name": "\\_\\_dirname", "meta": { "added": [ "v0.1.27" ] }, "type": "var", "desc": "\n

The directory name of the current module. This the same as the\npath.dirname() of the __filename.

\n

__dirname is not actually a global but rather local to each module.

\n

Example: running node example.js from /Users/mjr

\n
console.log(__dirname);\n// Prints: /Users/mjr\nconsole.log(path.dirname(__filename));\n// Prints: /Users/mjr\n
\n" }, { "textRaw": "\\_\\_filename", "name": "\\_\\_filename", "meta": { "added": [ "v0.0.1" ] }, "type": "var", "desc": "\n

The file name of the current module. This is the resolved absolute path of the\ncurrent module file.

\n

For a main program this is not necessarily the same as the file name used in the\ncommand line.

\n

See __dirname for the directory name of the current module.

\n

__filename is not actually a global but rather local to each module.

\n

Examples:

\n

Running node example.js from /Users/mjr

\n
console.log(__filename);\n// Prints: /Users/mjr/example.js\nconsole.log(__dirname);\n// Prints: /Users/mjr\n
\n

Given two modules: a and b, where b is a dependency of\na and there is a directory structure of:

\n\n

References to __filename within b.js will return\n/Users/mjr/app/node_modules/b/b.js while references to __filename within\na.js will return /Users/mjr/app/a.js.

\n" }, { "textRaw": "exports", "name": "exports", "meta": { "added": [ "v0.1.12" ] }, "type": "var", "desc": "

A reference to the module.exports that is shorter to type.\nSee module system documentation for details on when to use exports and\nwhen to use module.exports.

\n

exports is not actually a global but rather local to each module.

\n

See the module system documentation for more information.

\n" }, { "textRaw": "module", "name": "module", "meta": { "added": [ "v0.1.16" ] }, "type": "var", "desc": "\n

A reference to the current module. In particular\nmodule.exports is used for defining what a module exports and makes\navailable through require().

\n

module is not actually a global but rather local to each module.

\n

See the module system documentation for more information.

\n" }, { "textRaw": "require()", "type": "var", "name": "require", "meta": { "added": [ "v0.1.13" ] }, "desc": "\n

To require modules. See the Modules section. require is not actually a\nglobal but rather local to each module.

\n", "properties": [ { "textRaw": "`cache` {Object} ", "type": "Object", "name": "cache", "meta": { "added": [ "v0.3.0" ] }, "desc": "

Modules are cached in this object when they are required. By deleting a key\nvalue from this object, the next require will reload the module. Note that\nthis does not apply to native addons, for which reloading will result in an\nError.

\n" }, { "textRaw": "`extensions` {Object} ", "type": "Object", "name": "extensions", "meta": { "added": [ "v0.3.0" ], "deprecated": [ "v0.10.6" ] }, "stability": 0, "stabilityText": "Deprecated", "desc": "

Instruct require on how to handle certain file extensions.

\n

Process files with the extension .sjs as .js:

\n
require.extensions['.sjs'] = require.extensions['.js'];\n
\n

Deprecated In the past, this list has been used to load\nnon-JavaScript modules into Node.js by compiling them on-demand.\nHowever, in practice, there are much better ways to do this, such as\nloading modules via some other Node.js program, or compiling them to\nJavaScript ahead of time.

\n

Since the Module system is locked, this feature will probably never go\naway. However, it may have subtle bugs and complexities that are best\nleft untouched.

\n" } ], "methods": [ { "textRaw": "require.resolve()", "type": "method", "name": "resolve", "meta": { "added": [ "v0.3.0" ] }, "desc": "

Use the internal require() machinery to look up the location of a module,\nbut rather than loading the module, just return the resolved filename.

\n", "signatures": [ { "params": [] } ] } ] } ], "miscs": [ { "textRaw": "Global Objects", "name": "Global Objects", "type": "misc", "desc": "

These objects are available in all modules. Some of these objects aren't\nactually in the global scope but in the module scope - this will be noted.

\n

The objects listed here are specific to Node.js. There are a number of\nbuilt-in objects that are part of the JavaScript language itself, which are\nalso globally accessible.

\n", "globals": [ { "textRaw": "Class: Buffer", "type": "global", "name": "Buffer", "meta": { "added": [ "v0.1.103" ] }, "desc": "\n

Used to handle binary data. See the buffer section.

\n" }, { "textRaw": "clearImmediate(immediateObject)", "type": "global", "name": "clearImmediate", "meta": { "added": [ "v0.9.1" ] }, "desc": "

clearImmediate is described in the timers section.

\n" }, { "textRaw": "clearInterval(intervalObject)", "type": "global", "name": "clearInterval", "meta": { "added": [ "v0.0.1" ] }, "desc": "

clearInterval is described in the timers section.

\n" }, { "textRaw": "clearTimeout(timeoutObject)", "type": "global", "name": "clearTimeout", "meta": { "added": [ "v0.0.1" ] }, "desc": "

clearTimeout is described in the timers section.

\n" }, { "textRaw": "console", "name": "console", "meta": { "added": [ "v0.1.100" ] }, "type": "global", "desc": "\n

Used to print to stdout and stderr. See the console section.

\n" }, { "textRaw": "global", "name": "global", "meta": { "added": [ "v0.1.27" ] }, "type": "global", "desc": "\n

In browsers, the top-level scope is the global scope. That means that in\nbrowsers if you're in the global scope var something will define a global\nvariable. In Node.js this is different. The top-level scope is not the global\nscope; var something inside an Node.js module will be local to that module.

\n" }, { "textRaw": "process", "name": "process", "meta": { "added": [ "v0.1.7" ] }, "type": "global", "desc": "\n

The process object. See the process object section.

\n" }, { "textRaw": "setImmediate(callback[, ...args])", "type": "global", "name": "setImmediate", "meta": { "added": [ "v0.9.1" ] }, "desc": "

setImmediate is described in the timers section.

\n" }, { "textRaw": "setInterval(callback, delay[, ...args])", "type": "global", "name": "setInterval", "meta": { "added": [ "v0.0.1" ] }, "desc": "

setInterval is described in the timers section.

\n" }, { "textRaw": "setTimeout(callback, delay[, ...args])", "type": "global", "name": "setTimeout", "meta": { "added": [ "v0.0.1" ] }, "desc": "

setTimeout is described in the timers section.

\n" } ], "vars": [ { "textRaw": "\\_\\_dirname", "name": "\\_\\_dirname", "meta": { "added": [ "v0.1.27" ] }, "type": "var", "desc": "\n

The directory name of the current module. This the same as the\npath.dirname() of the __filename.

\n

__dirname is not actually a global but rather local to each module.

\n

Example: running node example.js from /Users/mjr

\n
console.log(__dirname);\n// Prints: /Users/mjr\nconsole.log(path.dirname(__filename));\n// Prints: /Users/mjr\n
\n" }, { "textRaw": "\\_\\_filename", "name": "\\_\\_filename", "meta": { "added": [ "v0.0.1" ] }, "type": "var", "desc": "\n

The file name of the current module. This is the resolved absolute path of the\ncurrent module file.

\n

For a main program this is not necessarily the same as the file name used in the\ncommand line.

\n

See __dirname for the directory name of the current module.

\n

__filename is not actually a global but rather local to each module.

\n

Examples:

\n

Running node example.js from /Users/mjr

\n
console.log(__filename);\n// Prints: /Users/mjr/example.js\nconsole.log(__dirname);\n// Prints: /Users/mjr\n
\n

Given two modules: a and b, where b is a dependency of\na and there is a directory structure of:

\n\n

References to __filename within b.js will return\n/Users/mjr/app/node_modules/b/b.js while references to __filename within\na.js will return /Users/mjr/app/a.js.

\n" }, { "textRaw": "exports", "name": "exports", "meta": { "added": [ "v0.1.12" ] }, "type": "var", "desc": "

A reference to the module.exports that is shorter to type.\nSee module system documentation for details on when to use exports and\nwhen to use module.exports.

\n

exports is not actually a global but rather local to each module.

\n

See the module system documentation for more information.

\n" }, { "textRaw": "module", "name": "module", "meta": { "added": [ "v0.1.16" ] }, "type": "var", "desc": "\n

A reference to the current module. In particular\nmodule.exports is used for defining what a module exports and makes\navailable through require().

\n

module is not actually a global but rather local to each module.

\n

See the module system documentation for more information.

\n" }, { "textRaw": "require()", "type": "var", "name": "require", "meta": { "added": [ "v0.1.13" ] }, "desc": "\n

To require modules. See the Modules section. require is not actually a\nglobal but rather local to each module.

\n", "properties": [ { "textRaw": "`cache` {Object} ", "type": "Object", "name": "cache", "meta": { "added": [ "v0.3.0" ] }, "desc": "

Modules are cached in this object when they are required. By deleting a key\nvalue from this object, the next require will reload the module. Note that\nthis does not apply to native addons, for which reloading will result in an\nError.

\n" }, { "textRaw": "`extensions` {Object} ", "type": "Object", "name": "extensions", "meta": { "added": [ "v0.3.0" ], "deprecated": [ "v0.10.6" ] }, "stability": 0, "stabilityText": "Deprecated", "desc": "

Instruct require on how to handle certain file extensions.

\n

Process files with the extension .sjs as .js:

\n
require.extensions['.sjs'] = require.extensions['.js'];\n
\n

Deprecated In the past, this list has been used to load\nnon-JavaScript modules into Node.js by compiling them on-demand.\nHowever, in practice, there are much better ways to do this, such as\nloading modules via some other Node.js program, or compiling them to\nJavaScript ahead of time.

\n

Since the Module system is locked, this feature will probably never go\naway. However, it may have subtle bugs and complexities that are best\nleft untouched.

\n" } ], "methods": [ { "textRaw": "require.resolve()", "type": "method", "name": "resolve", "meta": { "added": [ "v0.3.0" ] }, "desc": "

Use the internal require() machinery to look up the location of a module,\nbut rather than loading the module, just return the resolved filename.

\n", "signatures": [ { "params": [] } ] } ] } ] } ] }