EventEmitter.init = function() { this.domain = null; if (EventEmitter.usingDomains) { // if there is an active domain, then attach to it. domain = domain || require('domain'); if (domain.active && !(thisinstanceof domain.Domain)) { this.domain = domain.active; } }
EventEmitter.prototype.addListener = functionaddListener(type, listener) { var m; var events; var existing; // .... 此处省略10000行 } // 就是这里,大家看到了么~~ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
var http2 = require('http2'); var fs = require('fs');
var server = http2.createServer({ key: fs.readFileSync('privatekey.pem'), cert: fs.readFileSync('certificate.pem') }, function(req, res) { var push = res.push('/client.js') push.end('alert("this is a server push");'); fs.createReadStream('index.html').pipe(res); });
server.listen(443, function() { console.log('listen on 443'); });