var log = function () { process.stdout.write(format.apply(this, arguments) + '\n'); } var info = function () { process.stdout.write(format.apply(this, arguments) + '\n'); } var warn = function () { writeError(format.apply(this, arguments) + '\n'); } var error = function () { writeError(format.apply(this, arguments) + '\n'); } var dir = function (object) { var util = require('util'); process.stdout.write(util.inspect(object) + '\n'); } var time = function (label) { times[label] = Date.now(); } var timeEnd = function (label) { var duration = Date.now() - times[label]; exports.log('undefined: NaNms', label, duration); } var trace = function (label) { // TODO probably can to do this better with V8's debug object once that is // exposed. var err = new Error; err.name = 'Trace'; err.message = label || ''; Error.captureStackTrace(err, arguments.callee); console.error(err.stack); } var assert = function (expression) { if (!expression) { var arr = Array.prototype.slice.call(arguments, 1); require('assert').ok(false, format.apply(this, arr)); } }
var global = [object global] var process = [object EventEmitter] var GLOBAL = [object global] var root = [object global] var Buffer = function Buffer(subject, encoding, offset) { //太长了,省略 } var setTimeout = function () { var t = NativeModule.require('timers'); return t.setTimeout.apply(this, arguments); } var setInterval = function () { var t = NativeModule.require('timers'); return t.setInterval.apply(this, arguments); } var clearTimeout = function () { var t = NativeModule.require('timers'); return t.clearTimeout.apply(this, arguments); } var clearInterval = function () { var t = NativeModule.require('timers'); return t.clearInterval.apply(this, arguments); } var console = [object Object]
var id = . var exports = [object Object] var parent = null var filename = /home/cheng19840218/node/example.js var loaded = false var exited = false var children = var paths = /home/cheng19840218/node/node_modules,/home/cheng19840218/node_modules,/home/node_modules,/node_modules var load = function (filename) { //太长了,省略 } var _compile = function (content, filename) { //太长了,省略 }
许多人学node.js就立即看其文档,殊不知node.js本身所依赖的V8引擎就拥有许多要学的东西,这其中包括ecma262v5带来的新方法新对象,还有效仿firefox的一些语法: __defineGetter__ __defineSetter__ __lookupGetter__ __lookupSetter__ set get __proto__ 不过以"__"开头的东西我是不建议用的,像set与get现在最新的浏览器都支持,如IE9,可以在其开发人员工具下试试下面的脚本:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn