{ "source": "doc/api/globals.markdown", "globals": [ { "textRaw": "global", "name": "global", "type": "global", "desc": "
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 this is different. The top-level scope is not the global\nscope; var something
inside a Node module will be local to that module.\n\n
The process object. See the [process object][] section.\n\n
\n" }, { "textRaw": "console", "name": "console", "type": "global", "desc": "Used to print to stdout and stderr. See the [console][] section.\n\n
\n" }, { "textRaw": "Class: Buffer", "type": "global", "name": "Buffer", "desc": "Used to handle binary data. See the [buffer section][]\n\n
\n" }, { "textRaw": "clearInterval(t)", "type": "global", "name": "clearInterval", "desc": "Stop a timer that was previously created with setInterval()
. The callback\nwill not execute.\n\n
The timer functions are global variables. See the [timers][] section.\n\n
\n" } ], "vars": [ { "textRaw": "require()", "type": "var", "name": "require", "desc": "To require modules. See the [Modules][] section. require
isn't actually a\nglobal but rather local to each module.\n\n
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\n
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.\n\n
Instruct require
on how to handle certain file extensions.\n\n
Process files with the extension .sjs
as .js
:\n\n
require.extensions['.sjs'] = require.extensions['.js'];
\nDeprecated In the past, this list has been used to load\nnon-JavaScript modules into Node by compiling them on-demand.\nHowever, in practice, there are much better ways to do this, such as\nloading modules via some other Node program, or compiling them to\nJavaScript ahead of time.\n\n
\nSince 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\n
\n" } ] }, { "textRaw": "__filename", "name": "__filename", "type": "var", "desc": "The filename of the code being executed. This is the resolved absolute path\nof this code file. For a main program this is not necessarily the same\nfilename used in the command line. The value inside a module is the path\nto that module file.\n\n
\nExample: running node example.js
from /Users/mjr
\n\n
console.log(__filename);\n// /Users/mjr/example.js
\n__filename
isn't actually a global but rather local to each module.\n\n
The name of the directory that the currently executing script resides in.\n\n
\nExample: running node example.js
from /Users/mjr
\n\n
console.log(__dirname);\n// /Users/mjr
\n__dirname
isn't actually a global but rather local to each module.\n\n\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\n
module
isn't actually a global but rather local to each module.\n\n
See the [module system documentation][] for more information.\n\n
\n" }, { "textRaw": "exports", "name": "exports", "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\n
exports
isn't actually a global but rather local to each module.\n\n
See the [module system documentation][] for more information.\n\n
\nSee the [module section][] for more information.\n\n
\n" } ], "methods": [ { "textRaw": "setTimeout(cb, ms)", "type": "method", "name": "setTimeout", "desc": "Run callback cb
after at least ms
milliseconds. The actual delay depends\non external factors like OS timer granularity and system load.\n\n
The timeout must be in the range of 1-2,147,483,647 inclusive. If the value is\noutside that range, it's changed to 1 millisecond. Broadly speaking, a timer\ncannot span more than 24.8 days.\n\n
\nReturns an opaque value that represents the timer.\n\n
\n", "signatures": [ { "params": [ { "name": "cb" }, { "name": "ms" } ] } ] }, { "textRaw": "clearTimeout(t)", "type": "method", "name": "clearTimeout", "desc": "Stop a timer that was previously created with setTimeout()
. The callback will\nnot execute.\n\n
Run callback cb
repeatedly every ms
milliseconds. Note that the actual\ninterval may vary, depending on external factors like OS timer granularity and\nsystem load. It's never less than ms
but it may be longer.\n\n
The interval must be in the range of 1-2,147,483,647 inclusive. If the value is\noutside that range, it's changed to 1 millisecond. Broadly speaking, a timer\ncannot span more than 24.8 days.\n\n
\nReturns an opaque value that represents the timer.\n\n
\n", "signatures": [ { "params": [ { "name": "cb" }, { "name": "ms" } ] } ] } ], "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\n
\n", "globals": [ { "textRaw": "global", "name": "global", "type": "global", "desc": "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 this is different. The top-level scope is not the global\nscope; var something
inside a Node module will be local to that module.\n\n
The process object. See the [process object][] section.\n\n
\n" }, { "textRaw": "console", "name": "console", "type": "global", "desc": "Used to print to stdout and stderr. See the [console][] section.\n\n
\n" }, { "textRaw": "Class: Buffer", "type": "global", "name": "Buffer", "desc": "Used to handle binary data. See the [buffer section][]\n\n
\n" }, { "textRaw": "clearInterval(t)", "type": "global", "name": "clearInterval", "desc": "Stop a timer that was previously created with setInterval()
. The callback\nwill not execute.\n\n
The timer functions are global variables. See the [timers][] section.\n\n
\n" } ], "vars": [ { "textRaw": "require()", "type": "var", "name": "require", "desc": "To require modules. See the [Modules][] section. require
isn't actually a\nglobal but rather local to each module.\n\n
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\n
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.\n\n
Instruct require
on how to handle certain file extensions.\n\n
Process files with the extension .sjs
as .js
:\n\n
require.extensions['.sjs'] = require.extensions['.js'];
\nDeprecated In the past, this list has been used to load\nnon-JavaScript modules into Node by compiling them on-demand.\nHowever, in practice, there are much better ways to do this, such as\nloading modules via some other Node program, or compiling them to\nJavaScript ahead of time.\n\n
\nSince 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\n
\n" } ] }, { "textRaw": "__filename", "name": "__filename", "type": "var", "desc": "The filename of the code being executed. This is the resolved absolute path\nof this code file. For a main program this is not necessarily the same\nfilename used in the command line. The value inside a module is the path\nto that module file.\n\n
\nExample: running node example.js
from /Users/mjr
\n\n
console.log(__filename);\n// /Users/mjr/example.js
\n__filename
isn't actually a global but rather local to each module.\n\n
The name of the directory that the currently executing script resides in.\n\n
\nExample: running node example.js
from /Users/mjr
\n\n
console.log(__dirname);\n// /Users/mjr
\n__dirname
isn't actually a global but rather local to each module.\n\n\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\n
module
isn't actually a global but rather local to each module.\n\n
See the [module system documentation][] for more information.\n\n
\n" }, { "textRaw": "exports", "name": "exports", "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\n
exports
isn't actually a global but rather local to each module.\n\n
See the [module system documentation][] for more information.\n\n
\nSee the [module section][] for more information.\n\n
\n" } ], "methods": [ { "textRaw": "setTimeout(cb, ms)", "type": "method", "name": "setTimeout", "desc": "Run callback cb
after at least ms
milliseconds. The actual delay depends\non external factors like OS timer granularity and system load.\n\n
The timeout must be in the range of 1-2,147,483,647 inclusive. If the value is\noutside that range, it's changed to 1 millisecond. Broadly speaking, a timer\ncannot span more than 24.8 days.\n\n
\nReturns an opaque value that represents the timer.\n\n
\n", "signatures": [ { "params": [ { "name": "cb" }, { "name": "ms" } ] } ] }, { "textRaw": "clearTimeout(t)", "type": "method", "name": "clearTimeout", "desc": "Stop a timer that was previously created with setTimeout()
. The callback will\nnot execute.\n\n
Run callback cb
repeatedly every ms
milliseconds. Note that the actual\ninterval may vary, depending on external factors like OS timer granularity and\nsystem load. It's never less than ms
but it may be longer.\n\n
The interval must be in the range of 1-2,147,483,647 inclusive. If the value is\noutside that range, it's changed to 1 millisecond. Broadly speaking, a timer\ncannot span more than 24.8 days.\n\n
\nReturns an opaque value that represents the timer.\n\n
\n", "signatures": [ { "params": [ { "name": "cb" }, { "name": "ms" } ] } ] } ] } ] }