Fix all lib/ files with ESLint rules with 0 errors.

This commit is contained in:
Gunther Brunner
2016-01-19 20:52:38 +09:00
parent 994977ea94
commit 434f63b3a9
69 changed files with 793 additions and 764 deletions

View File

@@ -176,11 +176,13 @@ module.exports = syrup.serial()
}
FrameProducer.prototype.nextFrame = function() {
var frame = null, chunk
var frame = null
var chunk
if (this.parser) {
while ((frame = this.parser.nextFrame()) === null) {
if ((chunk = this.socket.stream.read())) {
chunk = this.socket.stream.read()
if (chunk) {
this.parser.push(chunk)
}
else {
@@ -243,9 +245,9 @@ module.exports = syrup.serial()
return lifecycle.fatal()
}
var match
if ((match = /^PID: (\d+)$/.exec(line))) {
this.pid = +match[1]
var match = /^PID: (\d+)$/.exec(line)
if (match) {
this.pid = Number(match[1])
this.emit('pid', this.pid)
}
@@ -259,7 +261,7 @@ module.exports = syrup.serial()
}
var pidListener
return new Promise(function(resolve/*, reject*/) {
return new Promise(function(resolve) {
this.on('pid', pidListener = resolve)
}.bind(this)).bind(this)
.timeout(2000)
@@ -279,7 +281,7 @@ module.exports = syrup.serial()
if (/closed/.test(err.message) && times > 1) {
return Promise.delay(delay)
.then(function() {
return tryConnect(--times, delay * 2)
return tryConnect(times - 1, delay * 2)
})
}
return Promise.reject(err)
@@ -326,7 +328,7 @@ module.exports = syrup.serial()
socket.stream.removeListener('readable', this.readableListener)
var endListener
return new Promise(function(resolve/*, reject*/) {
return new Promise(function(resolve) {
socket.on('end', endListener = function() {
resolve(true)
})
@@ -354,8 +356,8 @@ module.exports = syrup.serial()
}
var signum = {
'SIGTERM': -15
, 'SIGKILL': -9
SIGTERM: -15
, SIGKILL: -9
}[signal]
log.info('Sending %s to minicap', signal)
@@ -478,8 +480,8 @@ module.exports = syrup.serial()
})
frameProducer.on('readable', function next() {
var frame
if ((frame = frameProducer.nextFrame())) {
var frame = frameProducer.nextFrame()
if (frame) {
Promise.settle([broadcastSet.keys().map(function(id) {
return broadcastSet.get(id).onFrame(frame)
})]).then(next)
@@ -557,8 +559,8 @@ module.exports = syrup.serial()
}
ws.on('message', function(data) {
var match
if ((match = /^(on|off|(size) ([0-9]+)x([0-9]+))$/.exec(data))) {
var match = /^(on|off|(size) ([0-9]+)x([0-9]+))$/.exec(data)
if (match) {
switch (match[2] || match[1]) {
case 'on':
broadcastSet.insert(id, {
@@ -570,7 +572,8 @@ module.exports = syrup.serial()
broadcastSet.remove(id)
break
case 'size':
frameProducer.updateProjection(+match[3], +match[4])
frameProducer.updateProjection(
Number(match[3]), Number(match[4]))
break
}
}

View File

@@ -30,12 +30,17 @@ FrameParser.prototype.nextFrame = function() {
var bytesLeft = len - this.cursor
if (bytesLeft >= this.frameBodyLength) {
var completeBody = this.frameBody
? Buffer.concat([
this.frameBody
var completeBody
if (this.frameBody) {
completeBody = Buffer.concat([
this.frameBody
, this.chunk.slice(this.cursor, this.cursor + this.frameBodyLength)
])
: this.chunk.slice(this.cursor, this.cursor + this.frameBodyLength)
])
}
else {
completeBody = this.chunk.slice(this.cursor,
this.cursor + this.frameBodyLength)
}
this.cursor += this.frameBodyLength
this.frameBodyLength = this.readFrameBytes = 0
@@ -46,9 +51,13 @@ FrameParser.prototype.nextFrame = function() {
else {
// @todo Consider/benchmark continuation frames to prevent
// potential Buffer thrashing.
this.frameBody = this.frameBody
? Buffer.concat([this.frameBody, this.chunk.slice(this.cursor, len)])
: this.chunk.slice(this.cursor, len)
if (this.frameBody) {
this.frameBody =
Buffer.concat([this.frameBody, this.chunk.slice(this.cursor, len)])
}
else {
this.frameBody = this.chunk.slice(this.cursor, len)
}
this.frameBodyLength -= bytesLeft
this.readFrameBytes += bytesLeft