You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
* fix: loop over arguments instead of spreading * update to use concat * use the returned array from pushVerdictArguments (instead of assuming it'll push to the original array) * fix "Type 'RedisCommandArguments' is not assignable to type 'string[]'." * fix "Argument of type 'RedisCommandArgument | RedisCommandArguments[]' is not assignable to parameter of type 'RedisCommandArgument | RedisCommandArgument[]'" * fix "Type 'RedisCommandArguments' is not assignable to type 'string[]'" Co-authored-by: Leibale Eidelman <leibale1998@gmail.com>
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
|
import { pushVerdictArguments } from './generic-transformers';
|
|
|
|
export const FIRST_KEY_INDEX = 1;
|
|
|
|
export interface XClaimOptions {
|
|
IDLE?: number;
|
|
TIME?: number | Date;
|
|
RETRYCOUNT?: number;
|
|
FORCE?: true;
|
|
}
|
|
|
|
export function transformArguments(
|
|
key: RedisCommandArgument,
|
|
group: RedisCommandArgument,
|
|
consumer: RedisCommandArgument,
|
|
minIdleTime: number,
|
|
id: RedisCommandArgument | Array<RedisCommandArgument>,
|
|
options?: XClaimOptions
|
|
): RedisCommandArguments {
|
|
const args = pushVerdictArguments(
|
|
['XCLAIM', key, group, consumer, minIdleTime.toString()],
|
|
id
|
|
);
|
|
|
|
if (options?.IDLE) {
|
|
args.push('IDLE', options.IDLE.toString());
|
|
}
|
|
|
|
if (options?.TIME) {
|
|
args.push(
|
|
'TIME',
|
|
(typeof options.TIME === 'number' ? options.TIME : options.TIME.getTime()).toString()
|
|
);
|
|
}
|
|
|
|
if (options?.RETRYCOUNT) {
|
|
args.push('RETRYCOUNT', options.RETRYCOUNT.toString());
|
|
}
|
|
|
|
if (options?.FORCE) {
|
|
args.push('FORCE');
|
|
}
|
|
|
|
return args;
|
|
}
|
|
|
|
export { transformStreamMessagesReply as transformReply } from './generic-transformers';
|