Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5273016

Browse files
committedMay 5, 2025·
fix: fix various command import issues
there was some sort of a circular dependency in <module>/lib/commands/index.ts for various modules fixes #2937 fixes #2941
1 parent 52e5562 commit 5273016

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+418
-391
lines changed
 

‎packages/bloom/lib/commands/bloom/INFO.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CommandParser } from '@redis/client/dist/lib/client/parser';
22
import { RedisArgument, Command, UnwrapReply, NullReply, NumberReply, TuplesToMapReply, Resp2Reply, SimpleStringReply, TypeMapping } from '@redis/client/dist/lib/RESP/types';
3-
import { transformInfoV2Reply } from '.';
3+
import { transformInfoV2Reply } from './helpers';
44

55
export type BfInfoReplyMap = TuplesToMapReply<[
66
[SimpleStringReply<'Capacity'>, NumberReply],
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { RESP_TYPES, TypeMapping } from "@redis/client";
2+
3+
export function transformInfoV2Reply<T>(reply: Array<any>, typeMapping?: TypeMapping): T {
4+
const mapType = typeMapping ? typeMapping[RESP_TYPES.MAP] : undefined;
5+
6+
switch (mapType) {
7+
case Array: {
8+
return reply as unknown as T;
9+
}
10+
case Map: {
11+
const ret = new Map<string, any>();
12+
13+
for (let i = 0; i < reply.length; i += 2) {
14+
ret.set(reply[i].toString(), reply[i + 1]);
15+
}
16+
17+
return ret as unknown as T;
18+
}
19+
default: {
20+
const ret = Object.create(null);
21+
22+
for (let i = 0; i < reply.length; i += 2) {
23+
ret[reply[i].toString()] = reply[i + 1];
24+
}
25+
26+
return ret as unknown as T;
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)
Please sign in to comment.