Lazy load modules in net.js

v0.7.4-release
Ryan Dahl 2010-10-28 13:15:53 -07:00
parent 5171da5a6c
commit 1eb547fec1
1 changed files with 4 additions and 6 deletions

View File

@ -1,8 +1,6 @@
var util = require("util");
var fs = require("fs");
var events = require("events");
var stream = require("stream");
var dns = require('dns');
var kMinPoolSpace = 128;
var kPoolSize = 40*1024;
@ -796,7 +794,7 @@ Stream.prototype.connect = function () {
doConnect(self, arguments[0]);
} else {
// TCP
dns.lookup(arguments[1], function (err, ip, addressType) {
require('dns').lookup(arguments[1], function (err, ip, addressType) {
if (err) {
self.emit('error', err);
} else {
@ -1085,7 +1083,7 @@ Server.prototype.listen = function () {
var path = arguments[0];
self.path = path;
// unlink sockfile if it exists
fs.stat(path, function (err, r) {
require('fs').stat(path, function (err, r) {
if (err) {
if (err.errno == ENOENT) {
self._doListen(path);
@ -1111,7 +1109,7 @@ Server.prototype.listen = function () {
self._doListen(port);
} else {
// the first argument is the port, the second an IP
dns.lookup(arguments[1], function (err, ip, addressType) {
require('dns').lookup(arguments[1], function (err, ip, addressType) {
if (err) {
self.emit('error', err);
} else {
@ -1192,7 +1190,7 @@ Server.prototype.close = function () {
}
if (self.type === "unix") {
fs.unlink(self.path, function () {
require('fs').unlink(self.path, function () {
self.emit("close");
});
} else {