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: mark private variables as such and remove obsolete ones
This commit is contained in:
@@ -12,7 +12,7 @@ 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 buffer = client.options.returnBuffers || client.options.detectBuffers && commandObj.bufferArgs
|
||||
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
|
||||
debug(type, channel)
|
||||
@@ -20,38 +20,38 @@ function subscribeUnsubscribe (client, reply, type) {
|
||||
// Emit first, then return the callback
|
||||
if (channel !== null) { // Do not emit or "unsubscribe" something if there was no channel to unsubscribe from
|
||||
if (type === 'subscribe' || type === 'psubscribe') {
|
||||
client.subscriptionSet[`${type}_${channel}`] = channel
|
||||
client._subscriptionSet[`${type}_${channel}`] = channel
|
||||
} else {
|
||||
const innerType = type === 'unsubscribe' ? 'subscribe' : 'psubscribe' // Make types consistent
|
||||
delete client.subscriptionSet[`${innerType}_${channel}`]
|
||||
delete client._subscriptionSet[`${innerType}_${channel}`]
|
||||
}
|
||||
client.emit(type, channel, count)
|
||||
client.subscribeChannels.push(channel)
|
||||
client._subscribeChannels.push(channel)
|
||||
}
|
||||
|
||||
if (commandObj.argsLength === 1 || client.subCommandsLeft === 1 || commandObj.argsLength === 0 && (count === 0 || channel === null)) {
|
||||
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
|
||||
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)) {
|
||||
if (SUBSCRIBE_COMMANDS[runningCommand.command]) {
|
||||
client.pubSubMode = i // Entering pub sub mode again
|
||||
client._pubSubMode = i // Entering pub sub mode again
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
client.commandQueue.shift()
|
||||
commandObj.callback(null, [count, client.subscribeChannels])
|
||||
client.subscribeChannels = []
|
||||
client.subCommandsLeft = 0
|
||||
commandObj.callback(null, [count, client._subscribeChannels])
|
||||
client._subscribeChannels = []
|
||||
client._subCommandsLeft = 0
|
||||
} else {
|
||||
if (client.subCommandsLeft !== 0) {
|
||||
client.subCommandsLeft--
|
||||
if (client._subCommandsLeft !== 0) {
|
||||
client._subCommandsLeft--
|
||||
} else {
|
||||
client.subCommandsLeft = commandObj.argsLength ? commandObj.argsLength - 1 : count
|
||||
client._subCommandsLeft = commandObj.argsLength ? commandObj.argsLength - 1 : count
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,14 +59,14 @@ function subscribeUnsubscribe (client, reply, type) {
|
||||
function returnPubSub (client, reply) {
|
||||
const type = reply[0].toString()
|
||||
if (type === 'message') { // Channel, message
|
||||
if (!client.options.returnBuffers || client.messageBuffers) { // Backwards compatible. Refactor this in v.3 to always return a string on the normal emitter
|
||||
if (!client._options.returnBuffers || client.messageBuffers) { // Backwards compatible. Refactor this in v.3 to always return a string on the normal emitter
|
||||
client.emit('message', reply[1].toString(), reply[2].toString())
|
||||
client.emit('messageBuffer', reply[1], reply[2])
|
||||
} else {
|
||||
client.emit('message', reply[1], reply[2])
|
||||
}
|
||||
} else if (type === 'pmessage') { // Pattern, channel, message
|
||||
if (!client.options.returnBuffers || client.messageBuffers) { // Backwards compatible. Refactor this in v.3 to always return a string on the normal emitter
|
||||
if (!client._options.returnBuffers || client.messageBuffers) { // Backwards compatible. Refactor this in v.3 to always return a string on the normal emitter
|
||||
client.emit('pmessage', reply[1].toString(), reply[2].toString(), reply[3].toString())
|
||||
client.emit('pmessageBuffer', reply[1], reply[2], reply[3])
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user