1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
Files
node-redis/packages/client/lib/commands/BZPOPMAX.ts
2021-12-15 17:08:50 -05:00

32 lines
846 B
TypeScript

import { RedisCommandArgument, RedisCommandArguments } from '.';
import { pushVerdictArguments, transformReplyNumberInfinity, ZMember } from './generic-transformers';
export const FIRST_KEY_INDEX = 1;
export function transformArguments(
key: RedisCommandArgument | Array<RedisCommandArgument>,
timeout: number
): RedisCommandArguments {
const args = pushVerdictArguments(['BZPOPMAX'], key);
args.push(timeout.toString());
return args;
}
interface ZMemberWithKey extends ZMember<string> {
key: string;
}
type BZPopMaxReply = ZMemberWithKey | null;
export function transformReply(reply: [key: string, value: string, score: string] | null): BZPopMaxReply | null {
if (!reply) return null;
return {
key: reply[0],
value: reply[1],
score: transformReplyNumberInfinity(reply[2])
};
}