Skip to content

Commit

Permalink
fix: no _ prefix for dispatch methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Aug 12, 2020
1 parent 767e406 commit 8703ee5
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions benchmarks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ class NoopRequest {
this.deferred = deferred
}

_onHeaders () {
onHeaders () {

}

_onData (chunk) {
onData (chunk) {
return true
}

_onComplete (trailers) {
onComplete (trailers) {
this.deferred.resolve()
}
}
Expand All @@ -170,15 +170,15 @@ class SimpleRequest {
this.dst = dst
}

_onHeaders (statusCode, headers, resume) {
onHeaders (statusCode, headers, resume) {
this.dst.on('drain', resume)
}

_onData (chunk) {
onData (chunk) {
return this.dst.write(chunk)
}

_onComplete () {
onComplete () {
this.dst.end()
}
}
4 changes: 2 additions & 2 deletions lib/client-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ConnectRequest {
this.callback = callback
}

_onUpgrade (statusCode, headers, socket) {
onUpgrade (statusCode, headers, socket) {
const { callback, opaque } = this

this.callback = null
Expand All @@ -22,7 +22,7 @@ class ConnectRequest {
})
}

_onError (err) {
onError (err) {
const { callback, opaque } = this

this.callback = null
Expand Down
8 changes: 4 additions & 4 deletions lib/client-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class PipelineHandler extends AsyncResource {
this.res = null
}

_onHeaders (statusCode, headers, resume) {
onHeaders (statusCode, headers, resume) {
const { opaque, handler, ret } = this

if (statusCode < 200) {
Expand Down Expand Up @@ -171,7 +171,7 @@ class PipelineHandler extends AsyncResource {
this.body = body
}

_onData (chunk) {
onData (chunk) {
const { res } = this

if (res._readableState.destroyed) {
Expand All @@ -181,7 +181,7 @@ class PipelineHandler extends AsyncResource {
return res.push(chunk)
}

_onComplete (trailers) {
onComplete (trailers) {
const { res } = this

if (res._readableState.destroyed) {
Expand All @@ -191,7 +191,7 @@ class PipelineHandler extends AsyncResource {
res.push(null)
}

_onError (err) {
onError (err) {
const { ret } = this

this.handler = null
Expand Down
8 changes: 4 additions & 4 deletions lib/client-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RequestHandler extends AsyncResource {
this.res = null
}

_onHeaders (statusCode, headers, resume) {
onHeaders (statusCode, headers, resume) {
const { callback, opaque } = this

if (statusCode < 200) {
Expand All @@ -53,7 +53,7 @@ class RequestHandler extends AsyncResource {
})
}

_onData (chunk) {
onData (chunk) {
const { res } = this

if (res._readableState.destroyed) {
Expand All @@ -63,7 +63,7 @@ class RequestHandler extends AsyncResource {
return res.push(chunk)
}

_onComplete (trailers) {
onComplete (trailers) {
const { res } = this

if (res._readableState.destroyed) {
Expand All @@ -73,7 +73,7 @@ class RequestHandler extends AsyncResource {
res.push(null)
}

_onError (err) {
onError (err) {
const { res, callback, opaque } = this

if (callback) {
Expand Down
8 changes: 4 additions & 4 deletions lib/client-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class StreamHandler extends AsyncResource {
this.trailers = null
}

_onHeaders (statusCode, headers, resume) {
onHeaders (statusCode, headers, resume) {
const { factory, callback, opaque } = this

if (statusCode < 200) {
Expand Down Expand Up @@ -66,7 +66,7 @@ class StreamHandler extends AsyncResource {
this.res = res
}

_onData (chunk) {
onData (chunk) {
const { res } = this

if (util.isDestroyed(res)) {
Expand All @@ -76,7 +76,7 @@ class StreamHandler extends AsyncResource {
return res.write(chunk)
}

_onComplete (trailers) {
onComplete (trailers) {
const { res } = this

if (util.isDestroyed(res)) {
Expand All @@ -88,7 +88,7 @@ class StreamHandler extends AsyncResource {
res.end()
}

_onError (err) {
onError (err) {
const { res, callback, opaque } = this

this.factory = null
Expand Down
4 changes: 2 additions & 2 deletions lib/client-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class UpgradeHandler {
this.callback = callback
}

_onUpgrade (statusCode, headers, socket) {
onUpgrade (statusCode, headers, socket) {
const { callback, opaque } = this

this.callback = null
Expand All @@ -21,7 +21,7 @@ class UpgradeHandler {
})
}

_onError (err) {
onError (err) {
const { callback, opaque } = this

this.callback = null
Expand Down
10 changes: 5 additions & 5 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class Request {

reset.call(this)

this[kHandler]._onUpgrade(statusCode, headers, socket)
this[kHandler].onUpgrade(statusCode, headers, socket)
}

onHeaders (statusCode, headers, resume) {
Expand All @@ -218,7 +218,7 @@ class Request {
clearTimeout(timeout)
}

this[kHandler]._onHeaders(statusCode, headers, resume)
this[kHandler].onHeaders(statusCode, headers, resume)
}

onBody (chunk, offset, length) {
Expand All @@ -228,7 +228,7 @@ class Request {
return
}

return this[kHandler]._onData(chunk.slice(offset, offset + length))
return this[kHandler].onData(chunk.slice(offset, offset + length))
}

onComplete (trailers) {
Expand All @@ -240,7 +240,7 @@ class Request {

reset.call(this)

return this[kHandler]._onComplete(trailers)
return this[kHandler].onComplete(trailers)
}

onError (err) {
Expand All @@ -261,7 +261,7 @@ class Request {
}

process.nextTick((handler, err) => {
handler._onError(err)
handler.onError(err)
}, this[kHandler], err)
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,13 @@ test('pool dispatch', (t) => {
path: '/',
method: 'GET'
}, {
_onHeaders (statusCode, headers) {
onHeaders (statusCode, headers) {
t.strictEqual(statusCode, 200)
},
_onData (chunk) {
onData (chunk) {
buf += chunk
},
_onComplete () {
onComplete () {
t.strictEqual(buf, 'asd')
}
})
Expand Down

0 comments on commit 8703ee5

Please sign in to comment.