{ "source": "doc/api/globals.md", "globals": [ { "textRaw": "Class: Buffer", "type": "global", "name": "Buffer", "meta": { "added": [ "v0.1.103" ], "changes": [] }, "desc": "
Used to handle binary data. See the buffer section.
\n" }, { "textRaw": "clearImmediate(immediateObject)", "type": "global", "name": "clearImmediate", "meta": { "added": [ "v0.9.1" ], "changes": [] }, "desc": "clearImmediate
is described in the timers section.
clearInterval
is described in the timers section.
clearTimeout
is described in the timers section.
Used to print to stdout and stderr. See the console
section.
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.
The process object. See the process
object section.
setImmediate
is described in the timers section.
setInterval
is described in the timers section.
setTimeout
is described in the timers section.
The directory name of the current module. This the same as the\npath.dirname()
of the __filename
.
__dirname
is not actually a global but rather local to each module.
Example: running node example.js
from /Users/mjr
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"
],
"changes": []
},
"type": "var",
"desc": "The file name of the current module. This is the resolved absolute path of the\ncurrent module file.
\nFor a main program this is not necessarily the same as the file name used in the\ncommand line.
\nSee __dirname
for the directory name of the current module.
__filename
is not actually a global but rather local to each module.
Examples:
\nRunning node example.js
from /Users/mjr
console.log(__filename);\n// Prints: /Users/mjr/example.js\nconsole.log(__dirname);\n// Prints: /Users/mjr\n
\nGiven two modules: a
and b
, where b
is a dependency of\na
and there is a directory structure of:
/Users/mjr/app/a.js
/Users/mjr/app/node_modules/b/b.js
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
.
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
.
exports
is not actually a global but rather local to each module.
See the module system documentation for more information.
\n" }, { "textRaw": "module", "name": "module", "meta": { "added": [ "v0.1.16" ], "changes": [] }, "type": "var", "desc": "A reference to the current module. In particular\nmodule.exports
is used for defining what a module exports and makes\navailable through require()
.
module
is not actually a global but rather local to each module.
See the module system documentation for more information.
\n" }, { "textRaw": "require()", "type": "var", "name": "require", "meta": { "added": [ "v0.1.13" ], "changes": [] }, "desc": "To require modules. See the Modules section. require
is not actually a\nglobal but rather local to each module.
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.
Instruct require
on how to handle certain file extensions.
Process files with the extension .sjs
as .js
:
require.extensions['.sjs'] = require.extensions['.js'];\n
\nDeprecated 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.
\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.
\nNote that the number of file system operations that the module system\nhas to perform in order to resolve a require(...)
statement to a\nfilename scales linearly with the number of registered extensions.
In other words, adding extensions slows down the module loader and\nshould be discouraged.
\n" } ], "methods": [ { "textRaw": "require.resolve()", "type": "method", "name": "resolve", "meta": { "added": [ "v0.3.0" ], "changes": [] }, "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.
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.
\nThe 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" ], "changes": [] }, "desc": "Used to handle binary data. See the buffer section.
\n" }, { "textRaw": "clearImmediate(immediateObject)", "type": "global", "name": "clearImmediate", "meta": { "added": [ "v0.9.1" ], "changes": [] }, "desc": "clearImmediate
is described in the timers section.
clearInterval
is described in the timers section.
clearTimeout
is described in the timers section.
Used to print to stdout and stderr. See the console
section.
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.
The process object. See the process
object section.
setImmediate
is described in the timers section.
setInterval
is described in the timers section.
setTimeout
is described in the timers section.
The directory name of the current module. This the same as the\npath.dirname()
of the __filename
.
__dirname
is not actually a global but rather local to each module.
Example: running node example.js
from /Users/mjr
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"
],
"changes": []
},
"type": "var",
"desc": "The file name of the current module. This is the resolved absolute path of the\ncurrent module file.
\nFor a main program this is not necessarily the same as the file name used in the\ncommand line.
\nSee __dirname
for the directory name of the current module.
__filename
is not actually a global but rather local to each module.
Examples:
\nRunning node example.js
from /Users/mjr
console.log(__filename);\n// Prints: /Users/mjr/example.js\nconsole.log(__dirname);\n// Prints: /Users/mjr\n
\nGiven two modules: a
and b
, where b
is a dependency of\na
and there is a directory structure of:
/Users/mjr/app/a.js
/Users/mjr/app/node_modules/b/b.js
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
.
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
.
exports
is not actually a global but rather local to each module.
See the module system documentation for more information.
\n" }, { "textRaw": "module", "name": "module", "meta": { "added": [ "v0.1.16" ], "changes": [] }, "type": "var", "desc": "A reference to the current module. In particular\nmodule.exports
is used for defining what a module exports and makes\navailable through require()
.
module
is not actually a global but rather local to each module.
See the module system documentation for more information.
\n" }, { "textRaw": "require()", "type": "var", "name": "require", "meta": { "added": [ "v0.1.13" ], "changes": [] }, "desc": "To require modules. See the Modules section. require
is not actually a\nglobal but rather local to each module.
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.
Instruct require
on how to handle certain file extensions.
Process files with the extension .sjs
as .js
:
require.extensions['.sjs'] = require.extensions['.js'];\n
\nDeprecated 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.
\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.
\nNote that the number of file system operations that the module system\nhas to perform in order to resolve a require(...)
statement to a\nfilename scales linearly with the number of registered extensions.
In other words, adding extensions slows down the module loader and\nshould be discouraged.
\n" } ], "methods": [ { "textRaw": "require.resolve()", "type": "method", "name": "resolve", "meta": { "added": [ "v0.3.0" ], "changes": [] }, "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.