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,10 +1,10 @@
|
||||
import { NumberReply, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||
import { TuplesReply, BlobStringReply, NumberReply, ArrayReply, UnwrapReply, Command } from '../RESP/types';
|
||||
|
||||
type RawNode = [
|
||||
type RawNode = TuplesReply<[
|
||||
host: BlobStringReply,
|
||||
port: NumberReply,
|
||||
id: BlobStringReply
|
||||
];
|
||||
]>;
|
||||
|
||||
type ClusterSlotsRawReply = ArrayReply<[
|
||||
from: NumberReply,
|
||||
@@ -21,7 +21,7 @@ export default {
|
||||
transformArguments() {
|
||||
return ['CLUSTER', 'SLOTS'];
|
||||
},
|
||||
transformReply(reply: ClusterSlotsRawReply) {
|
||||
transformReply(reply: UnwrapReply<ClusterSlotsRawReply>) {
|
||||
return reply.map(([from, to, master, ...replicas]) => ({
|
||||
from,
|
||||
to,
|
||||
@@ -31,7 +31,8 @@ export default {
|
||||
}
|
||||
} as const satisfies Command;
|
||||
|
||||
function transformNode([host, port, id ]: RawNode) {
|
||||
function transformNode(node: RawNode) {
|
||||
const [host, port, id] = node as unknown as UnwrapReply<typeof node>;
|
||||
return {
|
||||
host,
|
||||
port,
|
||||
|
Reference in New Issue
Block a user