You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-03 04:01:40 +03:00
* support multiple parametrs on CONFIG SET * clean code Co-authored-by: leibale <leibale1998@gmail.com>
24 lines
726 B
TypeScript
24 lines
726 B
TypeScript
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
|
|
|
type SingleParameter = [parameter: RedisCommandArgument, value: RedisCommandArgument];
|
|
|
|
type MultipleParameters = [config: Record<string, RedisCommandArgument>];
|
|
|
|
export function transformArguments(
|
|
...[parameterOrConfig, value]: SingleParameter | MultipleParameters
|
|
): RedisCommandArguments {
|
|
const args: RedisCommandArguments = ['CONFIG', 'SET'];
|
|
|
|
if (typeof parameterOrConfig === 'string') {
|
|
args.push(parameterOrConfig, value!);
|
|
} else {
|
|
for (const [key, value] of Object.entries(parameterOrConfig)) {
|
|
args.push(key, value);
|
|
}
|
|
}
|
|
|
|
return args;
|
|
}
|
|
|
|
export declare function transformReply(): string;
|