1
0
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:
Leibale
2023-07-13 13:42:59 -04:00
parent 54c3a66c72
commit a3e813d3ac
41 changed files with 522 additions and 428 deletions

View File

@@ -1,4 +1,4 @@
import { ArrayReply, TuplesToMapReply, BlobStringReply, NumberReply, Resp2Reply, Command } from '../RESP/types';
import { ArrayReply, TuplesToMapReply, BlobStringReply, NumberReply, UnwrapReply, Resp2Reply, Command } from '../RESP/types';
type ClusterLinksReply = ArrayReply<TuplesToMapReply<[
[BlobStringReply<'direction'>, BlobStringReply],
@@ -16,14 +16,17 @@ export default {
return ['CLUSTER', 'LINKS'];
},
transformReply: {
2: (reply: Resp2Reply<ClusterLinksReply>) => reply.map(link => ({
direction: link[1],
node: link[3],
'create-time': link[5],
events: link[7],
'send-buffer-allocated': link[9],
'send-buffer-used': link[11]
})),
2: (reply: UnwrapReply<Resp2Reply<ClusterLinksReply>>) => reply.map(link => {
const unwrapped = link as unknown as UnwrapReply<typeof link>;
return {
direction: unwrapped[1],
node: unwrapped[3],
'create-time': unwrapped[5],
events: unwrapped[7],
'send-buffer-allocated': unwrapped[9],
'send-buffer-used': unwrapped[11]
};
}),
3: undefined as unknown as () => ClusterLinksReply
}
} as const satisfies Command;