1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

add errors iterator to MultiErrorReply

This commit is contained in:
Leibale
2023-12-07 09:01:43 -05:00
parent 98cbdd0a7b
commit 3b28aa6c81
2 changed files with 7 additions and 0 deletions

View File

@@ -295,6 +295,7 @@ describe('Client', () => {
assert.equal(err.replies.length, 2); assert.equal(err.replies.length, 2);
assert.deepEqual(err.errorIndexes, [1]); assert.deepEqual(err.errorIndexes, [1]);
assert.ok(err.replies[1] instanceof ErrorReply); assert.ok(err.replies[1] instanceof ErrorReply);
assert.deepEqual([...err.errors()], [err.replies[1]]);
return true; return true;
} }
); );

View File

@@ -79,4 +79,10 @@ export class MultiErrorReply extends ErrorReply {
this.replies = replies; this.replies = replies;
this.errorIndexes = errorIndexes; this.errorIndexes = errorIndexes;
} }
*errors() {
for (const index of this.errorIndexes) {
yield this.replies[index];
}
}
} }