Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Lint all the JavaScripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Feb 18, 2012
1 parent 31721da commit 0cdf85e
Show file tree
Hide file tree
Showing 61 changed files with 750 additions and 543 deletions.
16 changes: 8 additions & 8 deletions lib/_debugger.js
Expand Up @@ -112,8 +112,8 @@ Protocol.prototype.execute = function(d) {

this.state = 'body';

if (Buffer.byteLength(res.raw, 'utf8') - this.bodyStartByteIndex
< this.contentLength) {
var len = Buffer.byteLength(res.raw, 'utf8');
if (len - this.bodyStartByteIndex < this.contentLength) {
break;
}
// pass thru
Expand All @@ -125,16 +125,16 @@ Protocol.prototype.execute = function(d) {
buf.write(res.raw, 0, resRawByteLength, 'utf8');
res.body =
buf.slice(this.bodyStartByteIndex,
this.bodyStartByteIndex
+ this.contentLength).toString('utf8');
this.bodyStartByteIndex +
this.contentLength).toString('utf8');
// JSON parse body?
res.body = res.body.length ? JSON.parse(res.body) : {};

// Done!
this.onResponse(res);

this._newRes(buf.slice(this.bodyStartByteIndex
+ this.contentLength).toString('utf8'));
this._newRes(buf.slice(this.bodyStartByteIndex +
this.contentLength).toString('utf8'));
}
break;

Expand All @@ -149,8 +149,8 @@ Protocol.prototype.serialize = function(req) {
req.type = 'request';
req.seq = this.reqSeq++;
var json = JSON.stringify(req);
return 'Content-Length: ' + Buffer.byteLength(json,'utf8') + '\r\n\r\n'
+ json;
return 'Content-Length: ' + Buffer.byteLength(json, 'utf8') +
'\r\n\r\n' + json;
};


Expand Down
44 changes: 22 additions & 22 deletions lib/child_process.js
Expand Up @@ -115,7 +115,7 @@ function setupChannel(target, channel) {
throw new TypeError('message cannot be undefined');
}

if (!this.connected) throw new Error("channel closed");
if (!this.connected) throw new Error('channel closed');

// For overflow protection don't write if channel queue is too deep.
if (channel.writeQueueSize > 1024 * 1024) {
Expand All @@ -140,33 +140,33 @@ function setupChannel(target, channel) {

target.connected = true;
target.disconnect = function() {
if (!this.connected) {
this.emit('error', new Error('IPC channel is already disconnected'));
return;
}
if (!this.connected) {
this.emit('error', new Error('IPC channel is already disconnected'));
return;
}

// do not allow messages to be written
this.connected = false;
this._channel = null;
// do not allow messages to be written
this.connected = false;
this._channel = null;

var fired = false;
function finish() {
if (fired) return;
fired = true;
var fired = false;
function finish() {
if (fired) return;
fired = true;

channel.close();
target.emit('disconnect');
}
channel.close();
target.emit('disconnect');
}

// If a message is being read, then wait for it to complete.
if (channel.buffering) {
this.once('message', finish);
this.once('internalMessage', finish);
// If a message is being read, then wait for it to complete.
if (channel.buffering) {
this.once('message', finish);
this.once('internalMessage', finish);

return;
}
return;
}

finish();
finish();
};

channel.readStart();
Expand Down
10 changes: 5 additions & 5 deletions lib/cluster.js
Expand Up @@ -90,12 +90,12 @@ function eachWorker(cb) {
}

cluster.setupMaster = function(options) {
// This can only be called from the master.
assert(cluster.isMaster);
// This can only be called from the master.
assert(cluster.isMaster);

// Don't allow this function to run more that once
if (masterStarted) return;
masterStarted = true;
if (masterStarted) return;
masterStarted = true;

// Get filename and arguments
options = options || {};
Expand All @@ -122,7 +122,7 @@ cluster.setupMaster = function(options) {
quickDestroyCluster();
// when done exit process with error code: 1
process.exit(1);
});
});

// emit setup event
cluster.emit('setup');
Expand Down
2 changes: 1 addition & 1 deletion lib/dns.js
Expand Up @@ -32,7 +32,7 @@ function errnoException(errorno, syscall) {

// For backwards compatibility. libuv returns ENOENT on NXDOMAIN.
if (errorno == 'ENOENT') {
errorno = 'ENOTFOUND'
errorno = 'ENOTFOUND';
}

e.errno = e.code = errorno;
Expand Down
66 changes: 37 additions & 29 deletions lib/fs.js
Expand Up @@ -37,18 +37,18 @@ var EventEmitter = require('events').EventEmitter;
var kMinPoolSpace = 128;
var kPoolSize = 40 * 1024;

var O_APPEND = constants.O_APPEND || 0;
var O_CREAT = constants.O_CREAT || 0;
var O_APPEND = constants.O_APPEND || 0;
var O_CREAT = constants.O_CREAT || 0;
var O_DIRECTORY = constants.O_DIRECTORY || 0;
var O_EXCL = constants.O_EXCL || 0;
var O_NOCTTY = constants.O_NOCTTY || 0;
var O_NOFOLLOW = constants.O_NOFOLLOW || 0;
var O_RDONLY = constants.O_RDONLY || 0;
var O_RDWR = constants.O_RDWR || 0;
var O_SYMLINK = constants.O_SYMLINK || 0;
var O_SYNC = constants.O_SYNC || 0;
var O_TRUNC = constants.O_TRUNC || 0;
var O_WRONLY = constants.O_WRONLY || 0;
var O_EXCL = constants.O_EXCL || 0;
var O_NOCTTY = constants.O_NOCTTY || 0;
var O_NOFOLLOW = constants.O_NOFOLLOW || 0;
var O_RDONLY = constants.O_RDONLY || 0;
var O_RDWR = constants.O_RDWR || 0;
var O_SYMLINK = constants.O_SYMLINK || 0;
var O_SYNC = constants.O_SYNC || 0;
var O_TRUNC = constants.O_TRUNC || 0;
var O_WRONLY = constants.O_WRONLY || 0;

fs.Stats = binding.Stats;

Expand Down Expand Up @@ -199,18 +199,18 @@ function stringToFlags(flag) {
}

switch (flag) {
case 'r' : return O_RDONLY;
case 'r' : return O_RDONLY;
case 'r+' : return O_RDWR;

case 'w' : return O_TRUNC | O_CREAT | O_WRONLY;
case 'w' : return O_TRUNC | O_CREAT | O_WRONLY;
case 'wx' : // fall through
case 'xw' : return O_TRUNC | O_CREAT | O_WRONLY | O_EXCL;

case 'w+' : return O_TRUNC | O_CREAT | O_RDWR;
case 'wx+': // fall through
case 'xw+': return O_TRUNC | O_CREAT | O_RDWR | O_EXCL;

case 'a' : return O_APPEND | O_CREAT | O_WRONLY;
case 'a' : return O_APPEND | O_CREAT | O_WRONLY;
case 'ax' : // fall through
case 'xa' : return O_APPEND | O_CREAT | O_WRONLY | O_EXCL;

Expand Down Expand Up @@ -262,8 +262,10 @@ fs.open = function(path, flags, mode, callback) {

mode = modeNum(mode, 438 /*=0666*/);

binding.open(pathModule._makeLong(path), stringToFlags(flags), mode,
callback);
binding.open(pathModule._makeLong(path),
stringToFlags(flags),
mode,
callback);
};

fs.openSync = function(path, flags, mode) {
Expand Down Expand Up @@ -363,13 +365,14 @@ fs.writeSync = function(fd, buffer, offset, length, position) {
};

fs.rename = function(oldPath, newPath, callback) {
binding.rename(pathModule._makeLong(oldPath), pathModule._makeLong(newPath),
callback || noop);
binding.rename(pathModule._makeLong(oldPath),
pathModule._makeLong(newPath),
callback || noop);
};

fs.renameSync = function(oldPath, newPath) {
return binding.rename(pathModule._makeLong(oldPath),
pathModule._makeLong(newPath));
pathModule._makeLong(newPath));
};

fs.truncate = function(fd, len, callback) {
Expand Down Expand Up @@ -407,12 +410,12 @@ fs.fsyncSync = function(fd) {
fs.mkdir = function(path, mode, callback) {
if (typeof mode === 'function') callback = mode;
binding.mkdir(pathModule._makeLong(path), modeNum(mode, 511 /*=0777*/),
callback || noop);
callback || noop);
};

fs.mkdirSync = function(path, mode) {
return binding.mkdir(pathModule._makeLong(path),
modeNum(mode, 511 /*=0777*/));
modeNum(mode, 511 /*=0777*/));
};

fs.sendfile = function(outFd, inFd, inOffset, length, callback) {
Expand Down Expand Up @@ -468,22 +471,23 @@ fs.symlink = function(destination, path, type_, callback) {
var callback_ = arguments[arguments.length - 1];
callback = (typeof(callback_) == 'function' ? callback_ : null);
binding.symlink(pathModule._makeLong(destination),
pathModule._makeLong(path), type, callback);
pathModule._makeLong(path), type, callback);
};

fs.symlinkSync = function(destination, path, type) {
return binding.symlink(pathModule._makeLong(destination),
pathModule._makeLong(path), type);
pathModule._makeLong(path), type);
};

fs.link = function(srcpath, dstpath, callback) {
binding.link(pathModule._makeLong(srcpath), pathModule._makeLong(dstpath),
callback || noop);
binding.link(pathModule._makeLong(srcpath),
pathModule._makeLong(dstpath),
callback || noop);
};

fs.linkSync = function(srcpath, dstpath) {
return binding.link(pathModule._makeLong(srcpath),
pathModule._makeLong(dstpath));
pathModule._makeLong(dstpath));
};

fs.unlink = function(path, callback) {
Expand Down Expand Up @@ -637,7 +641,10 @@ function writeAll(fd, buffer, offset, length, position, callback) {
if (written === length) {
fs.close(fd, callback);
} else {
writeAll(fd, buffer, offset + written, length - written, position + written, callback);
offset += written;
length -= written;
position += written;
writeAll(fd, buffer, offset, length, position, callback);
}
}
});
Expand Down Expand Up @@ -1462,7 +1469,8 @@ function SyncWriteStream(fd) {
this.fd = fd;
this.writable = true;
this.readable = false;
};
}

util.inherits(SyncWriteStream, Stream);


Expand All @@ -1481,7 +1489,7 @@ SyncWriteStream.prototype.write = function(data, arg1, arg2) {
} else if (typeof arg1 === 'function') {
cb = arg1;
} else {
throw new Error("bad arg");
throw new Error('bad arg');
}
}

Expand Down

0 comments on commit 0cdf85e

Please sign in to comment.