1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
Files
node-redis/lib/commands/BRPOP.ts

32 lines
648 B
TypeScript

import { transformReplyStringArray } from './generic-transformers';
export const FIRST_KEY_INDEX = 1;
export function transformArguments(key: string | Array<string>, timeout: number): Array<string> {
const args = ['BRPOP'];
if (typeof key === 'string') {
args.push(key);
} else {
args.push(...key);
}
args.push(timeout.toString());
return args;
}
type BRPOPReply = null | {
key: string;
element: string;
};
export function transformReply(reply: null | [string, string]): BRPOPReply {
if (reply === null) return null;
return {
key: reply[0],
element: reply[1]
};
}