Browse Source

syntax fixes in src/node.js

v0.7.4-release
Joshaven Potter 15 years ago
committed by Ryan Dahl
parent
commit
7873639f55
  1. 61
      src/node.js

61
src/node.js

@ -12,23 +12,23 @@ GLOBAL.include = function () {
GLOBAL.puts = function () { GLOBAL.puts = function () {
throw new Error("puts() has moved. Use require('sys') to bring it back."); throw new Error("puts() has moved. Use require('sys') to bring it back.");
} };
GLOBAL.print = function () { GLOBAL.print = function () {
throw new Error("print() has moved. Use require('sys') to bring it back."); throw new Error("print() has moved. Use require('sys') to bring it back.");
} };
GLOBAL.p = function () { GLOBAL.p = function () {
throw new Error("p() has moved. Use require('sys') to bring it back."); throw new Error("p() has moved. Use require('sys') to bring it back.");
} };
process.debug = function () { process.debug = function () {
throw new Error("process.debug() has moved. Use require('sys') to bring it back."); throw new Error("process.debug() has moved. Use require('sys') to bring it back.");
} };
process.error = function () { process.error = function () {
throw new Error("process.error() has moved. Use require('sys') to bring it back."); throw new Error("process.error() has moved. Use require('sys') to bring it back.");
} };
GLOBAL.node = {}; GLOBAL.node = {};
@ -118,9 +118,9 @@ process.mixin = function() {
--i; --i;
} }
for ( ; i < length; i++ ) for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values // Only deal with non-null/undefined values
if ( (options = arguments[ i ]) != null ) if ( (options = arguments[ i ]) != null ) {
// Extend the base object // Extend the base object
for ( var name in options ) { for ( var name in options ) {
var src = target[ name ], copy = options[ name ]; var src = target[ name ], copy = options[ name ];
@ -130,18 +130,19 @@ process.mixin = function() {
continue; continue;
// Recurse if we're merging object values // Recurse if we're merging object values
if ( deep && copy && typeof copy === "object" ) if ( deep && copy && typeof copy === "object" ) {
target[ name ] = process.mixin( deep, target[ name ] = process.mixin( deep,
// Never move original objects, clone them // Never move original objects, clone them
src || ( copy.length != null ? [ ] : { } ) src || ( copy.length != null ? [ ] : { } )
, copy ); , copy );
// Don't bring in undefined values // Don't bring in undefined values
else } else {
target[ name ] = copy; target[ name ] = copy;
}
} }
}
}
// Return the modified object // Return the modified object
return target; return target;
}; };
@ -195,7 +196,7 @@ process.Promise = function () {
process.EventEmitter.call(); process.EventEmitter.call();
this._blocking = false; this._blocking = false;
this._hasFired = false; this._hasFired = false;
} };
process.inherits(process.Promise, process.EventEmitter); process.inherits(process.Promise, process.EventEmitter);
process.Promise.prototype.timeout = function(timeout) { process.Promise.prototype.timeout = function(timeout) {
@ -435,18 +436,18 @@ GLOBAL.setTimeout = function (callback, after) {
timer.addListener("timeout", callback); timer.addListener("timeout", callback);
timer.start(after, 0); timer.start(after, 0);
return timer; return timer;
} };
GLOBAL.setInterval = function (callback, repeat) { GLOBAL.setInterval = function (callback, repeat) {
var timer = new process.Timer(); var timer = new process.Timer();
timer.addListener("timeout", callback); timer.addListener("timeout", callback);
timer.start(repeat, repeat); timer.start(repeat, repeat);
return timer; return timer;
} };
GLOBAL.clearTimeout = function (timer) { GLOBAL.clearTimeout = function (timer) {
timer.stop(); timer.stop();
} };
GLOBAL.clearInterval = GLOBAL.clearTimeout; GLOBAL.clearInterval = GLOBAL.clearTimeout;
@ -508,14 +509,14 @@ var posixModule = createInternalModule("posix", function (exports) {
} else { } else {
promise.emitSuccess.apply(promise, arguments); promise.emitSuccess.apply(promise, arguments);
} }
} };
} }
// Yes, the follow could be easily DRYed up but I provide the explicit // Yes, the follow could be easily DRYed up but I provide the explicit
// list to make the arguments clear. // list to make the arguments clear.
exports.close = function (fd) { exports.close = function (fd) {
var promise = new process.Promise() var promise = new process.Promise();
process.fs.close(fd, callback(promise)); process.fs.close(fd, callback(promise));
return promise; return promise;
}; };
@ -525,7 +526,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.open = function (path, flags, mode) { exports.open = function (path, flags, mode) {
var promise = new process.Promise() var promise = new process.Promise();
process.fs.open(path, flags, mode, callback(promise)); process.fs.open(path, flags, mode, callback(promise));
return promise; return promise;
}; };
@ -535,7 +536,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.read = function (fd, length, position, encoding) { exports.read = function (fd, length, position, encoding) {
var promise = new process.Promise() var promise = new process.Promise();
encoding = encoding || "binary"; encoding = encoding || "binary";
process.fs.read(fd, length, position, encoding, callback(promise)); process.fs.read(fd, length, position, encoding, callback(promise));
return promise; return promise;
@ -547,7 +548,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.write = function (fd, data, position, encoding) { exports.write = function (fd, data, position, encoding) {
var promise = new process.Promise() var promise = new process.Promise();
encoding = encoding || "binary"; encoding = encoding || "binary";
process.fs.write(fd, data, position, encoding, callback(promise)); process.fs.write(fd, data, position, encoding, callback(promise));
return promise; return promise;
@ -559,7 +560,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.rename = function (oldPath, newPath) { exports.rename = function (oldPath, newPath) {
var promise = new process.Promise() var promise = new process.Promise();
process.fs.rename(oldPath, newPath, callback(promise)); process.fs.rename(oldPath, newPath, callback(promise));
return promise; return promise;
}; };
@ -569,7 +570,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.rmdir = function (path) { exports.rmdir = function (path) {
var promise = new process.Promise() var promise = new process.Promise();
process.fs.rmdir(path, callback(promise)); process.fs.rmdir(path, callback(promise));
return promise; return promise;
}; };
@ -579,7 +580,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.mkdir = function (path, mode) { exports.mkdir = function (path, mode) {
var promise = new process.Promise() var promise = new process.Promise();
process.fs.mkdir(path, mode, callback(promise)); process.fs.mkdir(path, mode, callback(promise));
return promise; return promise;
}; };
@ -589,7 +590,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.sendfile = function (outFd, inFd, inOffset, length) { exports.sendfile = function (outFd, inFd, inOffset, length) {
var promise = new process.Promise() var promise = new process.Promise();
process.fs.sendfile(outFd, inFd, inOffset, length, callback(promise)); process.fs.sendfile(outFd, inFd, inOffset, length, callback(promise));
return promise; return promise;
}; };
@ -599,7 +600,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.readdir = function (path) { exports.readdir = function (path) {
var promise = new process.Promise() var promise = new process.Promise();
process.fs.readdir(path, callback(promise)); process.fs.readdir(path, callback(promise));
return promise; return promise;
}; };
@ -609,7 +610,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.stat = function (path) { exports.stat = function (path) {
var promise = new process.Promise() var promise = new process.Promise();
process.fs.stat(path, callback(promise)); process.fs.stat(path, callback(promise));
return promise; return promise;
}; };
@ -619,7 +620,7 @@ var posixModule = createInternalModule("posix", function (exports) {
}; };
exports.unlink = function (path) { exports.unlink = function (path) {
var promise = new process.Promise() var promise = new process.Promise();
process.fs.unlink(path, callback(promise)); process.fs.unlink(path, callback(promise));
return promise; return promise;
}; };
@ -752,7 +753,7 @@ function findModulePath (id, dirs, callback) {
path.join(dir, id + ".js"), path.join(dir, id + ".js"),
path.join(dir, id + ".node"), path.join(dir, id + ".node"),
path.join(dir, id, "index.js"), path.join(dir, id, "index.js"),
path.join(dir, id, "index.addon"), path.join(dir, id, "index.addon")
]; ];
var searchLocations = function() { var searchLocations = function() {
@ -768,7 +769,7 @@ function findModulePath (id, dirs, callback) {
return; return;
} }
searchLocations(); searchLocations();
}) });
}; };
searchLocations(); searchLocations();
} }
@ -933,7 +934,7 @@ if (process.ARGV[0].indexOf('/') > 0) {
process.ARGV[0] = path.join(cwd, process.ARGV[0]); process.ARGV[0] = path.join(cwd, process.ARGV[0]);
} }
if (process.ARGV[1].charAt(0) != "/" && !/^http:\/\//.exec(process.ARGV[1])) { if (process.ARGV[1].charAt(0) != "/" && !(/^http:\/\//).exec(process.ARGV[1])) {
process.ARGV[1] = path.join(cwd, process.ARGV[1]); process.ARGV[1] = path.join(cwd, process.ARGV[1]);
} }

Loading…
Cancel
Save