Skip to content

Commit

Permalink
refactor: Code improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Jan 23, 2020
1 parent f9fed52 commit 95efe31
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/client.js
Expand Up @@ -51,16 +51,7 @@ function Client (broker, conn, req) {
// queue packets received before client fires 'connect' event. Prevents memory leaks on 'connect' event
this.parser._queue = []

this.on('connected', dequeue)

function dequeue () {
var q = this.parser._queue
for (var i = 0, len = q.length; i < len; i++) {
handle(this, q[i], this._nextBatch)
}

this.parser._queue = null
}
this.once('connected', dequeue)

this.parser.on('packet', enqueue)

Expand Down Expand Up @@ -348,4 +339,13 @@ function enqueue (packet) {
}
}

function dequeue () {
var q = this.parser._queue
for (var i = 0, len = q.length; i < len; i++) {
handle(this, q[i], this._nextBatch)
}

this.parser._queue = null
}

function nop () { }

0 comments on commit 95efe31

Please sign in to comment.