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

chore: improve multi performance by refactoring a array check away

This commit is contained in:
Ruben Bridgewater
2017-05-26 17:07:21 +02:00
parent f69aba72d1
commit a3a74559da
3 changed files with 25 additions and 26 deletions

View File

@ -3,18 +3,11 @@
/**
* @description Convert an array to an object
*
* hgetall converts its replies to an object. If the reply is empty, null is returned.
* The reply might be a string or a buffer if this is called in a transaction (multi)
* because of the queuing response.
*
* reply.length can be undefined but `undefined > 0` === false.
*
* @param {any} reply
* @param {any[]} reply
* @returns object
*/
function replyToObject (reply) {
// The reply might be a string or a buffer if this is called in a transaction (multi)
if (reply.length === 0 || !(reply instanceof Array)) {
if (reply.length === 0) {
return null
}
const obj = {}