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 { TuplesToMapReply, BlobStringReply, ArrayReply, Command, Resp2Reply } from '../RESP/types';
|
||||
import { TuplesToMapReply, BlobStringReply, ArrayReply, UnwrapReply, Resp2Reply, Command } from '../RESP/types';
|
||||
import FUNCTION_LIST, { FunctionListReplyItem } from './FUNCTION_LIST';
|
||||
|
||||
export type FunctionListWithCodeReply = ArrayReply<TuplesToMapReply<[
|
||||
@@ -15,17 +15,23 @@ export default {
|
||||
return redisArgs;
|
||||
},
|
||||
transformReply: {
|
||||
2: (reply: Resp2Reply<FunctionListWithCodeReply>) => {
|
||||
return reply.map((library: any) => ({
|
||||
library_name: library[1],
|
||||
engine: library[3],
|
||||
functions: library[5].map((fn: any) => ({
|
||||
name: fn[1],
|
||||
description: fn[3],
|
||||
flags: fn[5]
|
||||
})),
|
||||
library_code: library[7]
|
||||
})) as unknown as number;
|
||||
2: (reply: UnwrapReply<Resp2Reply<FunctionListWithCodeReply>>) => {
|
||||
return reply.map(library => {
|
||||
const unwrapped = library as unknown as UnwrapReply<typeof library>;
|
||||
return {
|
||||
library_name: unwrapped[1],
|
||||
engine: unwrapped[3],
|
||||
functions: (unwrapped[5] as unknown as UnwrapReply<typeof unwrapped[5]>).map(fn => {
|
||||
const unwrapped = fn as unknown as UnwrapReply<typeof fn>;
|
||||
return {
|
||||
name: unwrapped[1],
|
||||
description: unwrapped[3],
|
||||
flags: unwrapped[5]
|
||||
};
|
||||
}),
|
||||
library_code: unwrapped[7]
|
||||
};
|
||||
});
|
||||
},
|
||||
3: undefined as unknown as () => FunctionListWithCodeReply
|
||||
}
|
||||
|
Reference in New Issue
Block a user