jslint cleanup: path.js, readline.js, repl.js, tls.js, tty_win32.js, url.js

This commit is contained in:
Robert Mustacchi 2011-07-29 10:03:05 -07:00 committed by Ryan Dahl
parent 703a1ffe52
commit de0b8d601c
6 changed files with 31 additions and 36 deletions

View File

@ -73,9 +73,7 @@ if (isWindows) {
resolvedAbsolute = false;
for (var i = arguments.length; i >= -1; i--) {
var path = (i >= 0)
? arguments[i]
: process.cwd();
var path = (i >= 0) ? arguments[i] : process.cwd();
// Skip empty and invalid entries
if (typeof path !== 'string' || !path) {
@ -202,12 +200,12 @@ if (isWindows) {
function trim(arr) {
var start = 0;
for(;start < arr.length; start++) {
for (; start < arr.length; start++) {
if (arr[start] !== '') break;
}
var end = arr.length - 1;
for(;end >= 0; end--) {
for (; end >= 0; end--) {
if (arr[end] !== '') break;
}
@ -223,7 +221,7 @@ if (isWindows) {
var length = Math.min(lowerFromParts.length, lowerToParts.length);
var samePartsLength = length;
for(var i = 0; i < length; i++) {
for (var i = 0; i < length; i++) {
if (lowerFromParts[i] !== lowerToParts[i]) {
samePartsLength = i;
break;
@ -235,7 +233,7 @@ if (isWindows) {
}
var outputParts = [];
for(var i = samePartsLength; i < lowerFromParts.length; i++) {
for (var i = samePartsLength; i < lowerFromParts.length; i++) {
outputParts.push('..');
}
@ -258,9 +256,7 @@ if (isWindows) {
resolvedAbsolute = false;
for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0)
? arguments[i]
: process.cwd();
var path = (i >= 0) ? arguments[i] : process.cwd();
// Skip empty and invalid entries
if (typeof path !== 'string' || !path) {
@ -321,12 +317,12 @@ if (isWindows) {
function trim(arr) {
var start = 0;
for(;start < arr.length; start++) {
for (; start < arr.length; start++) {
if (arr[start] !== '') break;
}
var end = arr.length - 1;
for(;end >= 0; end--) {
for (; end >= 0; end--) {
if (arr[end] !== '') break;
}
@ -339,7 +335,7 @@ if (isWindows) {
var length = Math.min(fromParts.length, toParts.length);
var samePartsLength = length;
for(var i = 0; i < length; i++) {
for (var i = 0; i < length; i++) {
if (fromParts[i] !== toParts[i]) {
samePartsLength = i;
break;
@ -347,7 +343,7 @@ if (isWindows) {
}
var outputParts = [];
for(var i = samePartsLength; i < fromParts.length; i++) {
for (var i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..');
}

View File

@ -335,7 +335,7 @@ Interface.prototype._wordLeft = function() {
this.cursor -= match[0].length;
this._refreshLine();
}
}
};
Interface.prototype._wordRight = function() {
@ -345,7 +345,7 @@ Interface.prototype._wordRight = function() {
this.cursor += match[0].length;
this._refreshLine();
}
}
};
Interface.prototype._deleteLeft = function() {
@ -375,7 +375,7 @@ Interface.prototype._deleteWordLeft = function() {
this.cursor = leading.length;
this._refreshLine();
}
}
};
Interface.prototype._deleteWordRight = function() {
@ -386,20 +386,20 @@ Interface.prototype._deleteWordRight = function() {
trailing.slice(match[0].length);
this._refreshLine();
}
}
};
Interface.prototype._deleteLineLeft = function() {
this.line = this.line.slice(this.cursor);
this.cursor = 0;
this._refreshLine();
}
};
Interface.prototype._deleteLineRight = function() {
this.line = this.line.slice(0, this.cursor);
this._refreshLine();
}
};
Interface.prototype._line = function() {
@ -454,11 +454,11 @@ Interface.prototype._ttyWrite = function(s, key) {
if (key.ctrl && key.shift) {
/* Control and shift pressed */
switch (key.name) {
case "backspace":
case 'backspace':
this._deleteLineLeft();
break;
case "delete":
case 'delete':
this._deleteLineRight();
break;
}

View File

@ -104,8 +104,8 @@ function REPLServer(prompt, stream) {
var sawSIGINT = false;
rli.on('SIGINT', function() {
if (sawSIGINT) {
rli.close();
process.exit();
rli.close();
process.exit();
}
var bareInt = false;
if (!(self.bufferedCommand && self.bufferedCommand.length > 0) &&
@ -298,7 +298,7 @@ REPLServer.prototype.complete = function(line) {
var filter = match[1];
var dir, files, f, name, base, ext, abs, subfiles, s;
group = [];
var paths = module.paths.concat(require("module").globalPaths);
var paths = module.paths.concat(require('module').globalPaths);
for (i = 0; i < paths.length; i++) {
dir = path.resolve(paths[i], subdir);
try {

View File

@ -69,7 +69,7 @@ function convertNPNProtocols(NPNProtocols, out) {
if (Buffer.isBuffer(NPNProtocols)) {
out.NPNProtocols = NPNProtocols;
}
};
}
// Base class of both CleartextStream and EncryptedStream
function CryptoStream(pair) {
@ -379,7 +379,7 @@ CryptoStream.prototype._pull = function() {
this.pair.encrypted._destroyAfterPush = true;
}
this.pair.cycle();
this._done()
this._done();
return;
}
@ -514,9 +514,8 @@ function SecurePair(credentials, isServer, requestCert, rejectUnauthorized,
this._requestCert = requestCert ? true : false;
this.ssl = new Connection(this.credentials.context,
this._isServer ? true : false,
this._requestCert,
this._rejectUnauthorized);
this._isServer ? true : false, this._requestCert,
this._rejectUnauthorized);
if (NPN_ENABLED && NPNProtocols) {
this.ssl.setNPNProtocols(NPNProtocols);
@ -593,28 +592,28 @@ SecurePair.prototype.cycle = function(depth) {
if (!this.cycleEncryptedPullLock) {
this.cycleEncryptedPullLock = true;
debug("encrypted._pull");
debug('encrypted._pull');
this.encrypted._pull();
this.cycleEncryptedPullLock = false;
}
if (!this.cycleCleartextPullLock) {
this.cycleCleartextPullLock = true;
debug("cleartext._pull");
debug('cleartext._pull');
this.cleartext._pull();
this.cycleCleartextPullLock = false;
}
if (!this.cycleCleartextPushLock) {
this.cycleCleartextPushLock = true;
debug("cleartext._push");
debug('cleartext._push');
this.cleartext._push();
this.cycleCleartextPushLock = false;
}
if (!this.cycleEncryptedPushLock) {
this.cycleEncryptedPushLock = true;
debug("encrypted._push");
debug('encrypted._push');
this.encrypted._push();
this.cycleEncryptedPushLock = false;
}

View File

@ -120,7 +120,7 @@ WriteStream.prototype.isTTY = true;
WriteStream.prototype.write = function(data, encoding) {
if (!this.writable) {
this.emit("error", new Error('stream not writable'));
this.emit('error', new Error('stream not writable'));
return false;
}

View File

@ -231,7 +231,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {
for (var i = 0; i < domainArray.length; ++i) {
var s = domainArray[i];
newOut.push(s.match(/[^A-Za-z0-9_-]/) ?
'xn--' + punycode.encode(s) : s);
'xn--' + punycode.encode(s) : s);
}
out.hostname = newOut.join('.');