diff --git a/packages/bloom/lib/commands/bloom/INSERT.ts b/packages/bloom/lib/commands/bloom/INSERT.ts index 59fe1dabbd..f6deb7a861 100644 --- a/packages/bloom/lib/commands/bloom/INSERT.ts +++ b/packages/bloom/lib/commands/bloom/INSERT.ts @@ -1,4 +1,5 @@ import { pushVerdictArguments } from '@redis/client/dist/lib/commands/generic-transformers'; +import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands'; export const FIRST_KEY_INDEX = 1; @@ -12,9 +13,9 @@ interface InsertOptions { export function transformArguments( key: string, - items: string | Array, + items: RedisCommandArgument | Array, options?: InsertOptions -): Array { +): RedisCommandArguments { const args = ['BF.INSERT', key]; if (options?.CAPACITY) { @@ -38,9 +39,7 @@ export function transformArguments( } args.push('ITEMS'); - pushVerdictArguments(args, items); - - return args; + return pushVerdictArguments(args, items); } export { transformBooleanArrayReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers'; diff --git a/packages/client/lib/commands/PUBSUB_NUMSUB.ts b/packages/client/lib/commands/PUBSUB_NUMSUB.ts index c68b0d9a7f..f47238f888 100644 --- a/packages/client/lib/commands/PUBSUB_NUMSUB.ts +++ b/packages/client/lib/commands/PUBSUB_NUMSUB.ts @@ -1,13 +1,14 @@ import { pushVerdictArguments } from './generic-transformers'; +import { RedisCommandArgument, RedisCommandArguments } from '.'; export const IS_READ_ONLY = true; -export function transformArguments(channels?: Array | string): Array { +export function transformArguments( + channels?: Array | RedisCommandArgument +): RedisCommandArguments { const args = ['PUBSUB', 'NUMSUB']; - if (channels) { - pushVerdictArguments(args, channels); - } + if (channels) return pushVerdictArguments(args, channels); return args; } diff --git a/packages/client/lib/commands/XCLAIM.ts b/packages/client/lib/commands/XCLAIM.ts index c87d254754..bc38f9b9e9 100644 --- a/packages/client/lib/commands/XCLAIM.ts +++ b/packages/client/lib/commands/XCLAIM.ts @@ -18,9 +18,10 @@ export function transformArguments( id: RedisCommandArgument | Array, options?: XClaimOptions ): RedisCommandArguments { - const args = ['XCLAIM', key, group, consumer, minIdleTime.toString()]; - - pushVerdictArguments(args, id); + const args = pushVerdictArguments( + ['XCLAIM', key, group, consumer, minIdleTime.toString()], + id + ); if (options?.IDLE) { args.push('IDLE', options.IDLE.toString()); diff --git a/packages/client/lib/commands/generic-transformers.ts b/packages/client/lib/commands/generic-transformers.ts index 728378bb27..d3a57a9346 100644 --- a/packages/client/lib/commands/generic-transformers.ts +++ b/packages/client/lib/commands/generic-transformers.ts @@ -428,7 +428,8 @@ export function pushEvalArguments(args: Array, options?: EvalOptions): A export function pushVerdictArguments(args: RedisCommandArguments, value: RedisCommandArgument | Array): RedisCommandArguments { if (Array.isArray(value)) { - args.push(...value); + // https://github.com/redis/node-redis/pull/2160 + args = args.concat(value); } else { args.push(value); } diff --git a/packages/json/lib/commands/GET.ts b/packages/json/lib/commands/GET.ts index 36bb9bc4e4..21bad09568 100644 --- a/packages/json/lib/commands/GET.ts +++ b/packages/json/lib/commands/GET.ts @@ -1,4 +1,5 @@ import { pushVerdictArguments } from '@redis/client/dist/lib/commands/generic-transformers'; +import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; export const FIRST_KEY_INDEX = 1; @@ -12,11 +13,11 @@ interface GetOptions { NOESCAPE?: true; } -export function transformArguments(key: string, options?: GetOptions): Array { - const args = ['JSON.GET', key]; +export function transformArguments(key: string, options?: GetOptions): RedisCommandArguments { + let args: RedisCommandArguments = ['JSON.GET', key]; if (options?.path) { - pushVerdictArguments(args, options.path); + args = pushVerdictArguments(args, options.path); } if (options?.INDENT) { diff --git a/packages/time-series/lib/commands/MGET_WITHLABELS.ts b/packages/time-series/lib/commands/MGET_WITHLABELS.ts index cf83f4bcd1..b0875cefe0 100644 --- a/packages/time-series/lib/commands/MGET_WITHLABELS.ts +++ b/packages/time-series/lib/commands/MGET_WITHLABELS.ts @@ -8,6 +8,7 @@ import { pushFilterArgument } from '.'; import { MGetRawReply, MGetReply } from './MGET'; +import { RedisCommandArguments } from '@redis/client/dist/lib/commands'; export const IS_READ_ONLY = true; @@ -18,14 +19,9 @@ interface MGetWithLabelsOptions { export function transformArguments( filter: Filter, options?: MGetWithLabelsOptions -): Array { - const args = ['TS.MGET']; - - pushWithLabelsArgument(args, options?.SELECTED_LABELS); - - pushFilterArgument(args, filter); - - return args; +): RedisCommandArguments { + const args = pushWithLabelsArgument(['TS.MGET'], options?.SELECTED_LABELS); + return pushFilterArgument(args, filter); } export interface MGetWithLabelsReply extends MGetReply { diff --git a/packages/time-series/lib/commands/index.ts b/packages/time-series/lib/commands/index.ts index 4cc638a424..aba3ae2de9 100644 --- a/packages/time-series/lib/commands/index.ts +++ b/packages/time-series/lib/commands/index.ts @@ -313,8 +313,7 @@ export type Filter = string | Array; export function pushFilterArgument(args: RedisCommandArguments, filter: string | Array): RedisCommandArguments { args.push('FILTER'); - pushVerdictArguments(args, filter); - return args; + return pushVerdictArguments(args, filter); } export interface MRangeOptions extends RangeOptions { @@ -328,10 +327,9 @@ export function pushMRangeArguments( filter: Filter, options?: MRangeOptions ): RedisCommandArguments { - pushRangeArguments(args, fromTimestamp, toTimestamp, options); - pushFilterArgument(args, filter); - pushMRangeGroupByArguments(args, options?.GROUPBY); - return args; + args = pushRangeArguments(args, fromTimestamp, toTimestamp, options); + args = pushFilterArgument(args, filter); + return pushMRangeGroupByArguments(args, options?.GROUPBY); } export type SelectedLabels = string | Array; @@ -341,7 +339,7 @@ export function pushWithLabelsArgument(args: RedisCommandArguments, selectedLabe args.push('WITHLABELS'); } else { args.push('SELECTED_LABELS'); - pushVerdictArguments(args, selectedLabels); + args = pushVerdictArguments(args, selectedLabels); } return args; @@ -358,11 +356,10 @@ export function pushMRangeWithLabelsArguments( filter: Filter, options?: MRangeWithLabelsOptions ): RedisCommandArguments { - pushRangeArguments(args, fromTimestamp, toTimestamp, options); - pushWithLabelsArgument(args, options?.SELECTED_LABELS); - pushFilterArgument(args, filter); - pushMRangeGroupByArguments(args, options?.GROUPBY); - return args; + args = pushRangeArguments(args, fromTimestamp, toTimestamp, options); + args = pushWithLabelsArgument(args, options?.SELECTED_LABELS); + args = pushFilterArgument(args, filter); + return pushMRangeGroupByArguments(args, options?.GROUPBY); } export function transformRangeReply(reply: Array): Array {