You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
convert "resp types" to interfaces to allow circular references
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { RedisArgument, BlobStringReply, NullReply, TuplesReply, NumberReply, Command, ArrayReply } from '../RESP/types';
|
||||
import { RedisArgument, BlobStringReply, NullReply, ArrayReply, TuplesReply, NumberReply, UnwrapReply, Command } from '../RESP/types';
|
||||
|
||||
type XPendingRawReply = TuplesReply<[
|
||||
pending: NumberReply,
|
||||
@@ -16,15 +16,19 @@ export default {
|
||||
transformArguments(key: RedisArgument, group: RedisArgument) {
|
||||
return ['XPENDING', key, group];
|
||||
},
|
||||
transformReply(reply: XPendingRawReply) {
|
||||
transformReply(reply: UnwrapReply<XPendingRawReply>) {
|
||||
const consumers = reply[3] as unknown as UnwrapReply<typeof reply[3]>;
|
||||
return {
|
||||
pending: reply[0],
|
||||
firstId: reply[1],
|
||||
lastId: reply[2],
|
||||
consumers: reply[3] === null ? null : reply[3].map(([name, deliveriesCounter]) => ({
|
||||
name,
|
||||
deliveriesCounter: Number(deliveriesCounter)
|
||||
}))
|
||||
consumers: consumers === null ? null : consumers.map(consumer => {
|
||||
const [name, deliveriesCounter] = consumer as unknown as UnwrapReply<typeof consumer>;
|
||||
return {
|
||||
name,
|
||||
deliveriesCounter: Number(deliveriesCounter)
|
||||
};
|
||||
})
|
||||
}
|
||||
}
|
||||
} as const satisfies Command;
|
||||
|
Reference in New Issue
Block a user