You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
convert "resp types" to interfaces to allow circular references
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { RedisArgument, ArrayReply, TuplesToMapReply, BlobStringReply, NumberReply, Resp2Reply, Command } from '../RESP/types';
|
||||
import { RedisArgument, ArrayReply, TuplesToMapReply, BlobStringReply, NumberReply, UnwrapReply, Resp2Reply, Command } from '../RESP/types';
|
||||
|
||||
export type XInfoConsumersReply = ArrayReply<TuplesToMapReply<[
|
||||
[BlobStringReply<'name'>, BlobStringReply],
|
||||
@@ -18,13 +18,16 @@ export default {
|
||||
return ['XINFO', 'CONSUMERS', key, group];
|
||||
},
|
||||
transformReply: {
|
||||
2: (reply: Resp2Reply<XInfoConsumersReply>) => {
|
||||
return reply.map(consumer => ({
|
||||
name: consumer[1],
|
||||
pending: consumer[3],
|
||||
idle: consumer[5],
|
||||
inactive: consumer[7]
|
||||
}));
|
||||
2: (reply: UnwrapReply<Resp2Reply<XInfoConsumersReply>>) => {
|
||||
return reply.map(consumer => {
|
||||
const unwrapped = consumer as unknown as UnwrapReply<typeof consumer>;
|
||||
return {
|
||||
name: unwrapped[1],
|
||||
pending: unwrapped[3],
|
||||
idle: unwrapped[5],
|
||||
inactive: unwrapped[7]
|
||||
};
|
||||
});
|
||||
},
|
||||
3: undefined as unknown as () => XInfoConsumersReply
|
||||
}
|
||||
|
Reference in New Issue
Block a user