You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
feat: always return strings from "message" listener
Listening to "messageBuffer" returns Buffers
This commit is contained in:
@@ -62,14 +62,14 @@ function returnPubSub (client, reply) {
|
||||
// It would be more straight forward to only listen to a single "message"
|
||||
// and in case of a "pmessage" a third argument would be passed (the pattern).
|
||||
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 (typeof reply[1] !== 'string') {
|
||||
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 (typeof reply[1] !== 'string') {
|
||||
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