You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
28 lines
759 B
TypeScript
28 lines
759 B
TypeScript
import { TransformArgumentsReply } from '.';
|
|
import { pushVerdictArgument, transformReplyStringArray } from './generic-transformers';
|
|
|
|
export const FIRST_KEY_INDEX = 2;
|
|
|
|
export const IS_READ_ONLY = true;
|
|
|
|
interface ZUnionOptions {
|
|
WEIGHTS?: Array<number>;
|
|
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
|
}
|
|
|
|
export function transformArguments(keys: Array<string> | string, options?: ZUnionOptions): TransformArgumentsReply {
|
|
const args = pushVerdictArgument(['ZUNION'], keys);
|
|
|
|
if (options?.WEIGHTS) {
|
|
args.push('WEIGHTS', ...options.WEIGHTS.map(weight => weight.toString()));
|
|
}
|
|
|
|
if (options?.AGGREGATE) {
|
|
args.push('AGGREGATE', options.AGGREGATE);
|
|
}
|
|
|
|
return args;
|
|
}
|
|
|
|
export const transformReply = transformReplyStringArray;
|