1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

chore: refactor main code base into smaller parts

This commit is contained in:
Ruben Bridgewater
2017-05-26 23:34:28 +02:00
parent 3065e2e7be
commit 1f179ef791
7 changed files with 322 additions and 291 deletions

View File

@@ -129,6 +129,28 @@ function warn (client, msg) {
}
}
/**
* @description Transform the reply as needed.
*
* If detectBuffers option was specified, then the reply from the parser will be a buffer.
* If this command did not use Buffer arguments, then convert the reply to Strings here.
*
* @param {RedisClient} client
* @param {string|number|null|Buffer|any[]} reply
* @param {Command} command
* @returns {string|number|null|Buffer|any[]|object}
*/
function handleReply (client, reply, command) {
if (client.options.detectBuffers === true && command.bufferArgs === false) { // client.messageBuffers
reply = replyToStrings(reply)
}
if (command.command === 'hgetall') {
reply = replyToObject(reply)
}
return reply
}
module.exports = {
replyToStrings,
replyToObject,
@@ -136,5 +158,6 @@ module.exports = {
monitorRegex: /^[0-9]{10,11}\.[0-9]+ \[[0-9]+ .+]( ".+?")+$/,
clone: convenienceClone,
replyInOrder,
warn
warn,
handleReply
}