if (len - this.bodyStartByteIndex < this.contentLength) {
break;
}
- // pass thru
+ // falls through
case 'body':
var resRawByteLength = Buffer.byteLength(res.raw, 'utf8');
default:
throw new Error('Unknown state');
- break;
}
};
Client.prototype.reqVersion = function(cb) {
cb = cb || function() {};
- this.req({ command: 'version' } , function(err, body, res) {
+ this.req({ command: 'version' }, function(err, body, res) {
if (err) return cb(err);
cb(null, res.body.body.V8Version, res.body.running);
});
// reqBacktrace(cb)
// TODO: from, to, bottom
Client.prototype.reqBacktrace = function(cb) {
- this.req({ command: 'backtrace', arguments: { inlineRefs: true } } , cb);
+ this.req({ command: 'backtrace', arguments: { inlineRefs: true } }, cb);
};
var self = this;
cb = cb || function() {};
- this.req({ command: 'scripts' } , function(err, res) {
+ this.req({ command: 'scripts' }, function(err, res) {
if (err) return cb(err);
for (var i = 0; i < res.length; i++) {
}
break;
+ /* eslint-disable max-len */
// list is taken from:
// https://mxr.mozilla.org/mozilla/source/netwerk/protocol/http/src/nsHttpHeaderArray.cpp
+ /* eslint-enable max-len */
case 'content-type':
case 'content-length':
case 'user-agent':
default:
// make comma-separated list
- if (dest[field] !== undefined)
+ if (dest[field] !== undefined) {
dest[field] += ', ' + value;
- else {
+ } else {
dest[field] = value;
}
}
this.once('socket', function(socket) {
socket.setTimeout(msecs);
});
- } else
+ } else {
this.socket.setTimeout(msecs);
+ }
};
this.addListener('request', requestListener);
}
+ /* eslint-disable max-len */
// Similar option to this. Too lazy to write my own docs.
// http://www.squid-cache.org/Doc/config/half_closed_clients/
// http://wiki.squid-cache.org/SquidFaq/InnerWorkings#What_is_a_half-closed_filedescriptor.3F
+ /* eslint-enable max-len */
this.httpAllowHalfOpen = false;
this.addListener('connection', connectionListener);
if (!state.ended) {
state.needReadable = true;
return 0;
- } else
+ } else {
return state.length;
+ }
}
return n;
if (this[i] === undefined && typeof stream[i] === 'function') {
this[i] = function(method) { return function() {
return stream[method].apply(stream, arguments);
- }}(i);
+ }; }(i);
}
}
const util = require('util');
const Stream = require('stream');
-const debug = util.debuglog('stream');
util.inherits(Writable, Stream);
} else {
state.bufferedRequest = state.lastBufferedRequest;
}
- }
- else
+ } else {
doWrite(stream, state, false, len, chunk, encoding, cb);
+ }
return ret;
}
prefinish(stream, state);
state.finished = true;
stream.emit('finish');
- } else
+ } else {
prefinish(stream, state);
+ }
}
return need;
}
if (self.ssl)
self.ssl.newSessionDone();
- };
+ }
}
_throws.apply(this, [false].concat(pSlice.call(arguments)));
};
-assert.ifError = function(err) { if (err) {throw err;}};
+assert.ifError = function(err) { if (err) throw err; };
function onclose() {
self.slave.removeListener('internalMessage', onreply);
callback(new Error('Slave closed before reply'));
- };
+ }
function onreply(msg) {
if (!(msg.cmd === cmd && msg.key === self.key)) return;
self.slave.removeListener('internalMessage', onreply);
callback(null, msg);
- };
+ }
this.slave.once('disconnect', onclose);
this.slave.on('internalMessage', onreply);
const uv = process.binding('uv');
-const cluster = new EventEmitter;
+const cluster = new EventEmitter();
module.exports = cluster;
cluster.Worker = Worker;
cluster.isWorker = ('NODE_UNIQUE_ID' in process.env);
function done() {
if (self.handle.getsockname) {
var out = {};
- var err = self.handle.getsockname(out);
+ self.handle.getsockname(out);
// TODO(bnoordhuis) Check err.
send(null, { sockname: out }, null);
- }
- else {
+ } else {
send(null, null, null); // UNIX socket.
}
self.handoff(worker); // In case there are connections pending.
function masterInit() {
cluster.workers = {};
- var intercom = new EventEmitter;
+ var intercom = new EventEmitter();
cluster.settings = {};
// XXX(bnoordhuis) Fold cluster.schedulingPolicy into cluster.settings?
Console.prototype.trace = function trace() {
// TODO probably can to do this better with V8's debug object once that is
// exposed.
- var err = new Error;
+ var err = new Error();
err.name = 'Trace';
err.message = util.format.apply(this, arguments);
Error.captureStackTrace(err, trace);
if (!(this instanceof Verify))
return new Verify(algorithm, options);
- this._handle = new binding.Verify;
+ this._handle = new binding.Verify();
this._handle.init(algorithm);
stream.Writable.call(this, options);
function newHandle(type) {
if (type == 'udp4') {
- var handle = new UDP;
+ var handle = new UDP();
handle.lookup = lookup4;
return handle;
}
if (type == 'udp6') {
- var handle = new UDP;
+ var handle = new UDP();
handle.lookup = lookup6;
handle.bind = handle.bind6;
handle.send = handle.send6;
if (ex) {
if (callback) callback(ex);
self.emit('error', ex);
- }
- else if (self._handle) {
+ } else if (self._handle) {
var req = new SendWrap();
req.buffer = buffer; // Keep reference alive.
req.length = length;
if (err) throw errnoException(err, bindingName);
callback.immediately = true;
return req;
- }
+ };
}
if (--this._eventsCount === 0) {
this._events = {};
return this;
- } else
+ } else {
delete events[type];
+ }
} else {
spliceOne(list, position);
}
// Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
// is fairly slow to generate.
if (DEBUG) {
- var backtrace = new Error;
+ var backtrace = new Error();
return function(err) {
if (err) {
backtrace.stack = err.name + ': ' + err.message +
});
self._writableState.errorEmitted = true;
}
- };
+ }
if (this.destroyed) {
debug('already destroyed, fire error callbacks');
Server.prototype.address = function() {
if (this._handle && this._handle.getsockname) {
var out = {};
- var err = this._handle.getsockname(out);
+ this._handle.getsockname(out);
// TODO(bnoordhuis) Check err and throw?
return out;
} else if (this._pipeName) {
break;
case charCode('+'):
if (decodeSpaces) c = charCode(' ');
- // pass thru
+ // falls through
default:
out[outIndex++] = c;
break;
// Display prompt again
self.displayPrompt();
- };
+ }
});
self.on('SIGCONT', function() {
function urlParse(url, parseQueryString, slashesDenoteHost) {
if (url instanceof Url) return url;
- var u = new Url;
+ var u = new Url();
u.parse(url, parseQueryString, slashesDenoteHost);
return u;
}
} catch (_) {
return '[Circular]';
}
+ // falls through
default:
return x;
}
if (process._exiting)
return;
- var args = undefined;
+ var args;
if (arguments.length > 1) {
args = [];
for (var i = 1; i < arguments.length; i++)
if (!process.emit('unhandledRejection', reason, promise)) {
// Nobody is listening.
// TODO(petkaantonov) Take some default action, see #830
- } else
+ } else {
hadListeners = true;
+ }
}
}
return hadListeners;