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

test fixup

This commit is contained in:
Ruben Bridgewater
2017-05-06 08:16:19 +02:00
parent f1a7bcd735
commit b2613b2270
106 changed files with 2900 additions and 2967 deletions

View File

@@ -7,8 +7,8 @@ function replyToObject (reply) {
if (reply.length === 0 || !(reply instanceof Array)) {
return null
}
var obj = {}
for (var i = 0; i < reply.length; i += 2) {
const obj = {}
for (let i = 0; i < reply.length; i += 2) {
obj[reply[i].toString('binary')] = reply[i + 1]
}
return obj
@@ -19,8 +19,8 @@ function replyToStrings (reply) {
return reply.toString()
}
if (reply instanceof Array) {
var res = new Array(reply.length)
for (var i = 0; i < reply.length; i++) {
const res = new Array(reply.length)
for (let i = 0; i < reply.length; i++) {
// Recursively call the function as slowlog returns deep nested replies
res[i] = replyToStrings(reply[i])
}
@@ -33,18 +33,18 @@ function replyToStrings (reply) {
// Deep clone arbitrary objects with arrays. Can't handle cyclic structures (results in a range error)
// Any attribute with a non primitive value besides object and array will be passed by reference (e.g. Buffers, Maps, Functions)
function clone (obj) {
var copy
let copy
if (Array.isArray(obj)) {
copy = new Array(obj.length)
for (var i = 0; i < obj.length; i++) {
for (let i = 0; i < obj.length; i++) {
copy[i] = clone(obj[i])
}
return copy
}
if (Object.prototype.toString.call(obj) === '[object Object]') {
copy = {}
var elements = Object.keys(obj)
for (var elem = elements.pop(); elem !== undefined; elem = elements.pop()) {
const elements = Object.keys(obj)
for (let elem = elements.pop(); elem !== undefined; elem = elements.pop()) {
copy[elem] = clone(obj[elem])
}
return copy
@@ -67,18 +67,18 @@ function callbackOrEmit (self, callback, err, res) {
function replyInOrder (self, callback, err, res, queue) {
// If the queue is explicitly passed, use that, otherwise fall back to the offline queue first,
// as there might be commands in both queues at the same time
var commandObj
let commandObj
if (queue) {
commandObj = queue.peekBack()
} else {
commandObj = self.offlineQueue.peekBack() || self.commandQueue.peekBack()
}
if (!commandObj) {
process.nextTick(function () {
process.nextTick(() => {
callbackOrEmit(self, callback, err, res)
})
} else {
var tmp = commandObj.callback
const tmp = commandObj.callback
commandObj.callback = tmp
? function (e, r) {
tmp(e, r)
@@ -94,11 +94,11 @@ function replyInOrder (self, callback, err, res, queue) {
}
module.exports = {
replyToStrings: replyToStrings,
replyToObject: replyToObject,
replyToStrings,
replyToObject,
errCode: /^([A-Z]+)\s+(.+)$/,
monitorRegex: /^[0-9]{10,11}\.[0-9]+ \[[0-9]+ .+]( ".+?")+$/,
clone: convenienceClone,
callbackOrEmit: callbackOrEmit,
replyInOrder: replyInOrder
callbackOrEmit,
replyInOrder
}