You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
V5 bringing RESP3, Sentinel and TypeMapping to node-redis
RESP3 Support - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion. Sentinel TypeMapping Correctly types Multi commands Note: some API changes to be further documented in v4-to-v5.md
This commit is contained in:
@@ -1,22 +1,37 @@
|
||||
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { transformLMPopArguments, LMPopOptions, ListSide } from './generic-transformers';
|
||||
import { CommandArguments, NullReply, TuplesReply, BlobStringReply, Command } from '../RESP/types';
|
||||
import { ListSide, RedisVariadicArgument, pushVariadicArgument } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
|
||||
export function transformArguments(
|
||||
keys: RedisCommandArgument | Array<RedisCommandArgument>,
|
||||
side: ListSide,
|
||||
options?: LMPopOptions
|
||||
): RedisCommandArguments {
|
||||
return transformLMPopArguments(
|
||||
['LMPOP'],
|
||||
keys,
|
||||
side,
|
||||
options
|
||||
);
|
||||
export interface LMPopOptions {
|
||||
COUNT?: number;
|
||||
}
|
||||
|
||||
export declare function transformReply(): null | [
|
||||
key: string,
|
||||
elements: Array<string>
|
||||
];
|
||||
export function transformLMPopArguments(
|
||||
args: CommandArguments,
|
||||
keys: RedisVariadicArgument,
|
||||
side: ListSide,
|
||||
options?: LMPopOptions
|
||||
): CommandArguments {
|
||||
args = pushVariadicArgument(args, keys);
|
||||
|
||||
args.push(side);
|
||||
|
||||
if (options?.COUNT !== undefined) {
|
||||
args.push('COUNT', options.COUNT.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export type LMPopArguments = typeof transformLMPopArguments extends (_: any, ...args: infer T) => any ? T : never;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 2,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(...args: LMPopArguments) {
|
||||
return transformLMPopArguments(['LMPOP'], ...args);
|
||||
},
|
||||
transformReply: undefined as unknown as () => NullReply | TuplesReply<[
|
||||
key: BlobStringReply,
|
||||
elements: Array<BlobStringReply>
|
||||
]>
|
||||
} as const satisfies Command;
|
||||
|
Reference in New Issue
Block a user