You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-10 11:43:01 +03:00
34 lines
833 B
TypeScript
34 lines
833 B
TypeScript
import { transformReplyNumber } from './generic-transformers';
|
|
|
|
export const FIRST_KEY_INDEX = 1;
|
|
|
|
interface ZInterStoreOptions {
|
|
WEIGHTS?: Array<number>;
|
|
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
|
}
|
|
|
|
export function transformArguments(destination: string, keys: Array<string> | string, options?: ZInterStoreOptions): Array<string> {
|
|
const args = ['ZINTERSTORE', destination];
|
|
|
|
if (typeof keys === 'string') {
|
|
args.push('1', keys);
|
|
} else {
|
|
args.push(keys.length.toString(), ...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 = transformReplyNumber;
|