Skip to content

Commit

Permalink
use null prototype instead of additional check
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Aug 24, 2021
1 parent cba83cb commit 699aba4
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions lib/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,22 +425,9 @@ Command.setArgumentTransformer("hmset", hsetArgumentTransformer);

Command.setReplyTransformer("hgetall", function (result) {
if (Array.isArray(result)) {
const obj = {};
const obj = Object.create(null);
for (let i = 0; i < result.length; i += 2) {
const key = result[i];
const value = result[i + 1];
if (key in obj) {
// can only be truthy if the property is special somehow, like '__proto__' or 'constructor'
// https://github.com/luin/ioredis/issues/1267
Object.defineProperty(obj, key, {
value,
configurable: true,
enumerable: true,
writable: true,
});
} else {
obj[key] = value;
}
obj[result[i]] = result[i + 1];
}
return obj;
}
Expand Down

0 comments on commit 699aba4

Please # to comment.