You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Support multiple parametrs on CONFIG SET (#2042)
* support multiple parametrs on CONFIG SET * clean code Co-authored-by: leibale <leibale1998@gmail.com>
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
export function transformArguments(parameter: string, value: string): Array<string> {
|
||||
return ['CONFIG', 'SET', parameter, value];
|
||||
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;
|
||||
|
Reference in New Issue
Block a user