Skip to content

Commit

Permalink
jslint cleanup: path.js, readline.js, repl.js, tls.js, tty_win32.js, …
Browse files Browse the repository at this point in the history
…url.js
  • Loading branch information
rmustacc authored and ry committed Jul 29, 2011
1 parent 703a1ff commit de0b8d6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 36 deletions.
24 changes: 10 additions & 14 deletions lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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('..');
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -339,15 +335,15 @@ 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;
}
}

var outputParts = [];
for(var i = samePartsLength; i < fromParts.length; i++) {
for (var i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..');
}

Expand Down
16 changes: 8 additions & 8 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ Interface.prototype._wordLeft = function() {
this.cursor -= match[0].length;
this._refreshLine();
}
}
};


Interface.prototype._wordRight = function() {
Expand All @@ -345,7 +345,7 @@ Interface.prototype._wordRight = function() {
this.cursor += match[0].length;
this._refreshLine();
}
}
};


Interface.prototype._deleteLeft = function() {
Expand Down Expand Up @@ -375,7 +375,7 @@ Interface.prototype._deleteWordLeft = function() {
this.cursor = leading.length;
this._refreshLine();
}
}
};


Interface.prototype._deleteWordRight = function() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down Expand Up @@ -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 {
Expand Down
17 changes: 8 additions & 9 deletions lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -379,7 +379,7 @@ CryptoStream.prototype._pull = function() {
this.pair.encrypted._destroyAfterPush = true;
}
this.pair.cycle();
this._done()
this._done();
return;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tty_win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('.');

Expand Down

0 comments on commit de0b8d6

Please sign in to comment.