You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
24 lines
766 B
TypeScript
24 lines
766 B
TypeScript
import { ArrayReply, BlobStringReply, NumberReply, UnwrapReply, Command } from '../RESP/types';
|
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
|
|
|
export default {
|
|
FIRST_KEY_INDEX: undefined,
|
|
IS_READ_ONLY: true,
|
|
transformArguments(channels?: RedisVariadicArgument) {
|
|
const args = ['PUBSUB', 'NUMSUB'];
|
|
|
|
if (channels) return pushVariadicArguments(args, channels);
|
|
|
|
return args;
|
|
},
|
|
transformReply(rawReply: UnwrapReply<ArrayReply<BlobStringReply | NumberReply>>) {
|
|
const reply = Object.create(null);
|
|
let i = 0;
|
|
while (i < rawReply.length) {
|
|
reply[rawReply[i++].toString()] = rawReply[i++].toString();
|
|
}
|
|
|
|
return reply as Record<string, NumberReply>;
|
|
}
|
|
} as const satisfies Command;
|