You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-13 10:02:24 +03:00
Merge branch 'master' of github.com:redis/node-redis into BZMPOP_ZMPOP
This commit is contained in:
@@ -372,6 +372,21 @@ export function pushVerdictArguments(args: RedisCommandArguments, value: RedisCo
|
||||
return args;
|
||||
}
|
||||
|
||||
export function pushVerdictNumberArguments(
|
||||
args: RedisCommandArguments,
|
||||
value: number | Array<number>
|
||||
): RedisCommandArguments {
|
||||
if (Array.isArray(value)) {
|
||||
for (const item of value) {
|
||||
args.push(item.toString());
|
||||
}
|
||||
} else {
|
||||
args.push(value.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export function pushVerdictArgument(
|
||||
args: RedisCommandArguments,
|
||||
value: RedisCommandArgument | Array<RedisCommandArgument>
|
||||
@@ -472,3 +487,77 @@ export function transformCommandReply(
|
||||
categories: new Set(categories)
|
||||
};
|
||||
}
|
||||
|
||||
export interface SortOptions {
|
||||
BY?: string;
|
||||
LIMIT?: {
|
||||
offset: number;
|
||||
count: number;
|
||||
},
|
||||
GET?: string | Array<string>;
|
||||
DIRECTION?: 'ASC' | 'DESC';
|
||||
ALPHA?: true;
|
||||
}
|
||||
|
||||
export function pushSortArguments(
|
||||
args: RedisCommandArguments,
|
||||
options?: SortOptions
|
||||
): RedisCommandArguments {
|
||||
if (options?.BY) {
|
||||
args.push('BY', options.BY);
|
||||
}
|
||||
|
||||
if (options?.LIMIT) {
|
||||
args.push(
|
||||
'LIMIT',
|
||||
options.LIMIT.offset.toString(),
|
||||
options.LIMIT.count.toString()
|
||||
);
|
||||
}
|
||||
|
||||
if (options?.GET) {
|
||||
for (const pattern of (typeof options.GET === 'string' ? [options.GET] : options.GET)) {
|
||||
args.push('GET', pattern);
|
||||
}
|
||||
}
|
||||
|
||||
if (options?.DIRECTION) {
|
||||
args.push(options.DIRECTION);
|
||||
}
|
||||
|
||||
if (options?.ALPHA) {
|
||||
args.push('ALPHA');
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export interface SlotRange {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
|
||||
function pushSlotRangeArguments(
|
||||
args: RedisCommandArguments,
|
||||
range: SlotRange
|
||||
): void {
|
||||
args.push(
|
||||
range.start.toString(),
|
||||
range.end.toString()
|
||||
);
|
||||
}
|
||||
|
||||
export function pushSlotRangesArguments(
|
||||
args: RedisCommandArguments,
|
||||
ranges: SlotRange | Array<SlotRange>
|
||||
): RedisCommandArguments {
|
||||
if (Array.isArray(ranges)) {
|
||||
for (const range of ranges) {
|
||||
pushSlotRangeArguments(args, range);
|
||||
}
|
||||
} else {
|
||||
pushSlotRangeArguments(args, ranges);
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
Reference in New Issue
Block a user