Skip to content

Commit

Permalink
refactor: queue key instead of method (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag authored Feb 27, 2021
1 parent 30e75b7 commit 9d7cab6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,9 @@ class Parser extends HTTPParser {

this.resuming = true
while (this.queue.length) {
const [fn, ...args] = this.queue.shift()
const [key, ...args] = this.queue.shift()

Reflect.apply(fn, this, args)
this[key](...args)

if (this.paused) {
this.resuming = false
Expand All @@ -428,7 +428,7 @@ class Parser extends HTTPParser {
[HTTPParser.kOnHeaders] (rawHeaders) {
/* istanbul ignore next: difficult to make a test case for */
if (this.paused) {
this.queue.push([this[HTTPParser.kOnHeaders], rawHeaders])
this.queue.push([HTTPParser.kOnHeaders, rawHeaders])
return
}

Expand All @@ -441,7 +441,7 @@ class Parser extends HTTPParser {

[HTTPParser.kOnExecute] (ret) {
if (this.paused) {
this.queue.push([this[HTTPParser.kOnExecute], ret])
this.queue.push([HTTPParser.kOnExecute, ret])
return
}

Expand Down Expand Up @@ -505,7 +505,7 @@ class Parser extends HTTPParser {
url, statusCode, statusMessage, upgrade, shouldKeepAlive) {
/* istanbul ignore next: difficult to make a test case for */
if (this.paused) {
this.queue.push([this[HTTPParser.kOnHeadersComplete], versionMajor, versionMinor, rawHeaders, method,
this.queue.push([HTTPParser.kOnHeadersComplete, versionMajor, versionMinor, rawHeaders, method,
url, statusCode, statusMessage, upgrade, shouldKeepAlive])
return
}
Expand Down Expand Up @@ -611,7 +611,7 @@ class Parser extends HTTPParser {

[HTTPParser.kOnBody] (chunk, offset, length) {
if (this.paused) {
this.queue.push([this[HTTPParser.kOnBody], chunk, offset, length])
this.queue.push([HTTPParser.kOnBody, chunk, offset, length])
return
}

Expand Down Expand Up @@ -639,7 +639,7 @@ class Parser extends HTTPParser {
[HTTPParser.kOnMessageComplete] () {
/* istanbul ignore next: difficult to make a test case for */
if (this.paused) {
this.queue.push([this[HTTPParser.kOnMessageComplete]])
this.queue.push([HTTPParser.kOnMessageComplete])
return
}

Expand Down

0 comments on commit 9d7cab6

Please sign in to comment.