You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
chore: improve coverage further
This commit is contained in:
@@ -11,7 +11,7 @@ const SUBSCRIBE_COMMANDS = {
|
||||
function subscribeUnsubscribe (client, reply, type) {
|
||||
// Subscribe commands take an optional callback and also emit an event, but only the Last_ response is included in the callback
|
||||
// The pub sub commands return each argument in a separate return value and have to be handled that way
|
||||
const commandObj = client.commandQueue.get(0)
|
||||
const commandObj = client.commandQueue.peekAt(0)
|
||||
const buffer = client._options.returnBuffers || client._options.detectBuffers && commandObj.bufferArgs
|
||||
const channel = (buffer || reply[1] === null) ? reply[1] : reply[1].toString()
|
||||
const count = +reply[2] // Return the channel counter as number no matter if `stringNumbers` is activated or not
|
||||
@@ -31,16 +31,14 @@ function subscribeUnsubscribe (client, reply, type) {
|
||||
|
||||
if (commandObj.argsLength === 1 || client._subCommandsLeft === 1 || commandObj.argsLength === 0 && (count === 0 || channel === null)) {
|
||||
if (count === 0) { // Unsubscribed from all channels
|
||||
var runningCommand
|
||||
var i = 1
|
||||
client._pubSubMode = 0 // Deactivating pub sub mode
|
||||
// This should be a rare case and therefore handling it this way should be good performance wise for the general case
|
||||
for (runningCommand = client.commandQueue.get(i); runningCommand !== undefined; runningCommand = client.commandQueue.get(i)) {
|
||||
for (var i = 1; i < client.commandQueue.length; i++) {
|
||||
const runningCommand = client.commandQueue.peekAt(i)
|
||||
if (SUBSCRIBE_COMMANDS[runningCommand.command]) {
|
||||
client._pubSubMode = i // Entering pub sub mode again
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
client.commandQueue.shift()
|
||||
|
Reference in New Issue
Block a user