Skip to content

Commit

Permalink
print Object with keys and values; fix issue #15
Browse files Browse the repository at this point in the history
  • Loading branch information
lujiajing1126 committed Dec 27, 2018
1 parent acaf016 commit 30eb22b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,18 @@ class RedisClient {
.then(function (result) {
if (Array.isArray(result)) {
result.forEach((item, index) => {
console.log("%d) %s", index, item);
console.log("%d) %s", index+1, item);
});
} else if(typeof result === 'object') {
let count = 1;
for (let key of Object.keys(result)) {
console.log("%d) %s", count, key);
console.log("%d) %s", count+1, result[key]);
count += 2;
}
} else {
// number or string
// default to print it as `string`
console.log(result);
}
}).catch((e) => {
Expand Down

0 comments on commit 30eb22b

Please sign in to comment.