日期:2014-05-16  浏览次数:20470 次

nodejs全局对象
下面的东西基本是翻译自以下地址:
http://nodejs.org/docs/latest/api/globals.html
翻译当作学习吧!
全局对象:
原文:These objects are available in all modules. Some of these objects aren't
actually in the global scope but in the module scope-this will be noted.
译文:这些对象在所有的模块中都可用。实际上有些对象并不在全局作用域范围中,但是在它的模块作用域中-这些会标识出来的。

原文: global  {object} The global namespace object.
   In browsers,the top-level scope is the global scope.That means that
in browsers if you're in the global scope var something will define a global variable.In Node this is different.The top-level scope is not the
global scope; var something inside a Node module will be local to that module.
译文: global  {对象} 全局命名空间对象。
    在浏览器中,最顶层的作用域是全局作用域。那意味着如果你在全局作用域中定义一个变量那就是一个全局变量。在Node中不是这样的。最顶层的作用域不是全局作用域;在一个Node模板中声明一个变量,你只是在某模块中声明了一个本地模块。

原文: process {Object} The process object.See the process  object section.

译文:  process  {对象}  这个进程对象。 查看进程对象这一节。

原文: console {Object} Used to print to stdout and stderr.See the stdio section.
译文:控制台 {对象} 用于打印到标准输出和错误输出。查看stdio 章节。

原文: Buffer {Object}  Used to handle binary data. See the buffer section.
译文:Buffer {对象}  用于处理二进制数据,请查看buffer章节。

原文: require() {Function}  To require modules.See the  Modules section. require isn't actually a  global but rather local each module.
译文;用于加载所需模块。参见Modules模块。require 实际是相对于每个模块的一个局部而不是一个全局的函数。

原文: require.resolve() Use the internal require() machinery to look up
the location of a module,but rather than loading the module,just return the resolved filename.
译文:require.resolve() 使用内部的require()机制来查看模块的位置,但是它只是返回解析后的名字,而不是加载模块。

原文:require.cache Object Modules are cached in this object when they
are required.By deleting a key value from this object,the next require
will reloaded the module.
译文: require.cache 对象 当模块被加载之后会缓存在这个对象中。在这个对象中删除一个键值的话,下一次,require将会重新加载模块。

原文: __filename {String}   The filename of the code being executed.This is the resolved absolute path of this code file. For a man 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.
Example:running node exmaple.js from /Users/mjr
console.log(__filename);
// /users/mjr/exmaple.js
__filename isn't actually a global but rather local to each module.

译文:__filename {String} 将被执行的代码的文件名。这是已经被解析代码绝对路径。
对于主程序而言并不要求跟在命令行中使用的名字一样。在一个模块中的值 是对那个模块文件的路径。
示例:从/Users/mjr 运行 node example.js
   console.log(__filename);
// /Users/mjr/exmaple.js
__filename 实际是相对于各模块的本地变量而不是全局的。

原文:__dirname {String} The name of the directory that the currently
executing script resides in.
Example:running node example.js from /Users/mjr
console.log(__dirname);
// /Users/mjr
__dirname isn't actually a global but rather local to each module.

译文:#根__filename类同,暂不译。

原文:module {Object}  A reference to the current module.In particular module.exports is the same as the exports object. See src/node.js for more information. module isn't actually a global but rather local to each module.
译文: module {对象} 一个对当前模块的引用。特别地,module.exports 根exports对象相同。参见src/node.js了解更多。 module实际上是相对于各模块的局部对象而不是全局的。

原文:exports an object which is shared between all instances of the current module and made accessible through require().exports is the same as the module.exports object.See src/node.js for more information.export isn't actually a global but rather local to each module.
See the module system documentation for more information.
See the module section for more information.
译文:#与module类同不译。

原文:setTimeout(cb,ms)
     clearTimeout(t)
     setIn