Skip to content

Commit dd53cee

Browse files
committed
lint
1 parent e232f6e commit dd53cee

File tree

7 files changed

+144
-147
lines changed

7 files changed

+144
-147
lines changed

lib/stream.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,37 @@ function Stream() {
77
util.inherits(Stream, events.EventEmitter);
88
exports.Stream = Stream;
99

10-
Stream.prototype.pipe = function (dest, options) {
10+
Stream.prototype.pipe = function(dest, options) {
1111
var source = this;
1212

13-
function ondata (chunk) {
13+
function ondata(chunk) {
1414
if (dest.writable) {
1515
if (false === dest.write(chunk)) source.pause();
1616
}
1717
}
1818

19-
source.on("data", ondata);
19+
source.on('data', ondata);
2020

21-
function ondrain () {
21+
function ondrain() {
2222
if (source.readable) source.resume();
2323
}
2424

25-
dest.on("drain", ondrain);
25+
dest.on('drain', ondrain);
2626

2727
/*
2828
* If the 'end' option is not supplied, dest.end() will be called when
2929
* source gets the 'end' event.
3030
*/
3131

3232
if (!options || options.end !== false) {
33-
function onend () {
33+
function onend() {
3434
dest.end();
3535
}
3636

37-
source.on("end", onend);
37+
source.on('end', onend);
3838
}
3939

40-
dest.on('close', function () {
40+
dest.on('close', function() {
4141
source.removeListener('data', ondata);
4242
dest.removeListener('drain', ondrain);
4343
source.removeListener('end', onend);
@@ -49,22 +49,22 @@ Stream.prototype.pipe = function (dest, options) {
4949
*/
5050

5151
if (!source.pause) {
52-
source.pause = function () {
53-
source.emit("pause");
52+
source.pause = function() {
53+
source.emit('pause');
5454
};
5555
}
5656

5757
if (!source.resume) {
58-
source.resume = function () {
59-
source.emit("resume");
58+
source.resume = function() {
59+
source.emit('resume');
6060
};
6161
}
6262

63-
dest.on("pause", function () {
63+
dest.on('pause', function() {
6464
source.pause();
6565
});
6666

67-
dest.on("resume", function () {
67+
dest.on('resume', function() {
6868
if (source.readable) source.resume();
6969
});
7070
};

lib/string_decoder.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var StringDecoder = exports.StringDecoder = function (encoding) {
2-
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/,'');
1+
var StringDecoder = exports.StringDecoder = function(encoding) {
2+
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
33
if (this.encoding === 'utf8') {
44
this.charBuffer = new Buffer(4);
55
this.charReceived = 0;
@@ -8,7 +8,7 @@ var StringDecoder = exports.StringDecoder = function (encoding) {
88
};
99

1010

11-
StringDecoder.prototype.write = function (buffer) {
11+
StringDecoder.prototype.write = function(buffer) {
1212
// If not utf8...
1313
if (this.encoding !== 'utf8') {
1414
return buffer.toString(this.encoding);
@@ -18,9 +18,9 @@ StringDecoder.prototype.write = function (buffer) {
1818
// if our last write ended with an incomplete multibyte character
1919
if (this.charLength) {
2020
// determine how many remaining bytes this buffer has to offer for this char
21-
var i = (buffer.length >= this.charLength - this.charReceived)
22-
? this.charLength - this.charReceived
23-
: buffer.length;
21+
var i = (buffer.length >= this.charLength - this.charReceived) ?
22+
this.charLength - this.charReceived :
23+
buffer.length;
2424

2525
// add the new bytes to the char buffer
2626
buffer.copy(this.charBuffer, this.charReceived, 0, i);
@@ -46,7 +46,8 @@ StringDecoder.prototype.write = function (buffer) {
4646
// determine how many bytes we have to check at the end of this buffer
4747
var i = (buffer.length >= 3) ? 3 : buffer.length;
4848

49-
// figure out if one of the last i bytes of our buffer announces an incomplete char
49+
// Figure out if one of the last i bytes of our buffer announces an
50+
// incomplete char.
5051
for (; i > 0; i--) {
5152
c = buffer[buffer.length - i];
5253

lib/sys.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
var util = require("util");
1+
var util = require('util');
22

33
var sysWarning;
44
if (!sysWarning) {
5-
sysWarning = "The 'sys' module is now called 'util'. It should have a similar interface.";
5+
sysWarning = 'The "sys" module is now called "util". ' +
6+
'It should have a similar interface.';
67
// Uncomment in 2011
78
//util.error(sysWarning);
89
}

lib/timers.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ var assert = process.assert;
55
* To enable debug statements for the timers do NODE_DEBUG=8 ./node script.js
66
*/
77
var debugLevel = parseInt(process.env.NODE_DEBUG, 16);
8-
function debug () {
9-
if (debugLevel & 0x8) {
10-
require('util').error.apply(this, arguments);
11-
}
8+
var debug;
9+
if (debugLevel & 0x8) {
10+
debug = function() { require('util').error.apply(this, arguments); };
11+
} else {
12+
debug = function() { };
1213
}
1314

15+
1416
// IDLE TIMEOUTS
1517
//
1618
// Because often many sockets will have the same idle timeout we will not
@@ -25,29 +27,29 @@ function debug () {
2527
var lists = {};
2628

2729
// show the most idle item
28-
function peek (list) {
30+
function peek(list) {
2931
if (list._idlePrev == list) return null;
3032
return list._idlePrev;
3133
}
3234

3335

3436
// remove the most idle item from the list
35-
function shift (list) {
37+
function shift(list) {
3638
var first = list._idlePrev;
3739
remove(first);
3840
return first;
3941
}
4042

4143

4244
// remove a item from its list
43-
function remove (item) {
45+
function remove(item) {
4446
item._idleNext._idlePrev = item._idlePrev;
4547
item._idlePrev._idleNext = item._idleNext;
4648
}
4749

4850

4951
// remove a item from its list and place at the end.
50-
function append (list, item) {
52+
function append(list, item) {
5153
item._idleNext = list._idleNext;
5254
list._idleNext._idlePrev = item;
5355
item._idlePrev = list;
@@ -57,7 +59,7 @@ function append (list, item) {
5759

5860
// the main function - creates lists on demand and the watchers associated
5961
// with them.
60-
function insert (item, msecs) {
62+
function insert(item, msecs) {
6163
item._idleStart = new Date();
6264
item._idleTimeout = msecs;
6365

@@ -74,18 +76,18 @@ function insert (item, msecs) {
7476

7577
lists[msecs] = list;
7678

77-
list.callback = function () {
79+
list.callback = function() {
7880
debug('timeout callback ' + msecs);
7981
// TODO - don't stop and start the watcher all the time.
8082
// just set its repeat
8183
var now = new Date();
82-
debug("now: " + now);
84+
debug('now: ' + now);
8385
var first;
8486
while (first = peek(list)) {
8587
var diff = now - first._idleStart;
8688
if (diff < msecs) {
8789
list.again(msecs - diff);
88-
debug(msecs + ' list wait because diff is ' + diff);
90+
debug(msecs + ' list wait because diff is ' + diff);
8991
return;
9092
} else {
9193
remove(first);
@@ -109,7 +111,7 @@ function insert (item, msecs) {
109111
}
110112

111113

112-
var unenroll = exports.unenroll = function (item) {
114+
var unenroll = exports.unenroll = function(item) {
113115
if (item._idleNext) {
114116
remove(item);
115117

@@ -125,7 +127,7 @@ var unenroll = exports.unenroll = function (item) {
125127

126128

127129
// Does not start the time, just sets up the members needed.
128-
exports.enroll = function (item, msecs) {
130+
exports.enroll = function(item, msecs) {
129131
// if this item was already in a list somewhere
130132
// then we should unenroll it from that
131133
if (item._idleNext) unenroll(item);
@@ -137,7 +139,7 @@ exports.enroll = function (item, msecs) {
137139

138140
// call this whenever the item is active (not idle)
139141
// it will reset its timeout.
140-
exports.active = function (item) {
142+
exports.active = function(item) {
141143
var msecs = item._idleTimeout;
142144
if (msecs >= 0) {
143145
var list = lists[msecs];
@@ -162,8 +164,8 @@ exports.active = function (item) {
162164
*/
163165

164166

165-
exports.setTimeout = function (callback, after) {
166-
var timer;
167+
exports.setTimeout = function(callback, after) {
168+
var timer;
167169

168170
if (after <= 0) {
169171
// Use the slow case for after == 0
@@ -186,7 +188,7 @@ exports.setTimeout = function (callback, after) {
186188
*/
187189
if (arguments.length > 2) {
188190
var args = Array.prototype.slice.call(arguments, 2);
189-
var c = function () {
191+
var c = function() {
190192
callback.apply(timer, args);
191193
};
192194

@@ -207,7 +209,7 @@ exports.setTimeout = function (callback, after) {
207209
};
208210

209211

210-
exports.clearTimeout = function (timer) {
212+
exports.clearTimeout = function(timer) {
211213
if (timer && (timer.callback || timer._onTimeout)) {
212214
timer.callback = timer._onTimeout = null;
213215
exports.unenroll(timer);
@@ -216,12 +218,12 @@ exports.clearTimeout = function (timer) {
216218
};
217219

218220

219-
exports.setInterval = function (callback, repeat) {
221+
exports.setInterval = function(callback, repeat) {
220222
var timer = new Timer();
221223

222224
if (arguments.length > 2) {
223225
var args = Array.prototype.slice.call(arguments, 2);
224-
timer.callback = function () {
226+
timer.callback = function() {
225227
callback.apply(timer, args);
226228
};
227229
} else {
@@ -233,7 +235,7 @@ exports.setInterval = function (callback, repeat) {
233235
};
234236

235237

236-
exports.clearInterval = function (timer) {
238+
exports.clearInterval = function(timer) {
237239
if (timer instanceof Timer) {
238240
timer.callback = null;
239241
timer.stop();

lib/tls.js

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ var inherits = require('util').inherits;
3636
// TODO:
3737
// cleartext.credentials (by mirroring from pair object)
3838
// cleartext.getCertificate() (by mirroring from pair.credentials.context)
39-
function Server ( /* [options], listener */) {
39+
function Server(/* [options], listener */) {
4040
var options, listener;
41-
if (typeof arguments[0] == "object") {
41+
if (typeof arguments[0] == 'object') {
4242
options = arguments[0];
4343
listener = arguments[1];
44-
} else if (typeof arguments[0] == "function") {
44+
} else if (typeof arguments[0] == 'function') {
4545
options = {};
4646
listener = arguments[0];
4747
}
@@ -51,10 +51,9 @@ function Server ( /* [options], listener */) {
5151
var self = this;
5252

5353
// constructor call
54-
net.Server.call(this, function (socket) {
55-
var creds = crypto.createCredentials({ key: self.key,
56-
cert: self.cert,
57-
ca: self.ca });
54+
net.Server.call(this, function(socket) {
55+
var creds = crypto.createCredentials(
56+
{ key: self.key, cert: self.cert, ca: self.ca });
5857
creds.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');
5958

6059
var pair = crypto.createPair(creds,
@@ -63,30 +62,24 @@ function Server ( /* [options], listener */) {
6362
pair.encrypted.pipe(socket);
6463
socket.pipe(pair.encrypted);
6564

66-
pair.on('secure', function () {
65+
pair.on('secure', function() {
6766
var verifyError = pair._ssl.verifyError();
6867

6968
if (verifyError) {
7069
if (self.unauthorizedPeers) {
7170
self.emit('unauthorized', pair.cleartext, verifyError);
7271
} else {
73-
console.error("REJECT PEER. verify error: %s", verifyError);
72+
console.error('REJECT PEER. verify error: %s', verifyError);
7473
socket.destroy();
7574
}
7675
} else {
7776
self.emit('authorized', pair.cleartext);
7877
}
7978
});
8079

81-
pair.on('error', function (e) {
80+
pair.on('error', function(e) {
8281
console.log('pair got error: ' + e);
83-
84-
// TODO better way to get error code.
85-
if (/no shared cipher/.test(e.message)) {
86-
;
87-
} else {
88-
self.emit('error', e);
89-
}
82+
self.emit('error', e);
9083
});
9184

9285
pair.cleartext.on('error', function(err) {
@@ -110,13 +103,13 @@ function Server ( /* [options], listener */) {
110103

111104
inherits(Server, net.Server);
112105
exports.Server = Server;
113-
exports.createServer = function (options, listener) {
106+
exports.createServer = function(options, listener) {
114107
return new Server(options, listener);
115108
};
116109

117110

118-
Server.prototype.setOptions = function (options) {
119-
if (typeof options.unauthorizedPeers == "boolean") {
111+
Server.prototype.setOptions = function(options) {
112+
if (typeof options.unauthorizedPeers == 'boolean') {
120113
this.unauthorizedPeers = options.unauthorizedPeers;
121114
} else {
122115
this.unauthorizedPeers = false;

0 commit comments

Comments
 (0)