1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00
This commit is contained in:
Leibale
2023-06-22 19:41:35 -04:00
parent 6059b1edd8
commit e95634b375
6 changed files with 281 additions and 202 deletions

View File

@@ -0,0 +1,30 @@
import { NullReply, TuplesReply, NumberReply, BlobStringReply, DoubleReply, Command } from '../RESP/types';
import ZRANK from './ZRANK';
export default {
FIRST_KEY_INDEX: ZRANK.FIRST_KEY_INDEX,
IS_READ_ONLY: ZRANK.IS_READ_ONLY,
transformArguments(...args: Parameters<typeof ZRANK.transformArguments>) {
const redisArgs = ZRANK.transformArguments(...args);
redisArgs.push('WITHSCORE');
return redisArgs;
},
transformReply: {
2: (reply: NullReply | TuplesReply<[NumberReply, BlobStringReply]>) => {
if (reply === null) return null;
return {
rank: reply[0],
score: Number(reply[1])
};
},
3: (reply: NullReply | TuplesReply<[BlobStringReply, DoubleReply]>) => {
if (reply === null) return null;
return {
rank: reply[0],
score: reply[1]
};
}
}
} as const satisfies Command;