You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
fix: fix various command import issues (#2944)
* 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 * remove redundant definition
This commit is contained in:
committed by
GitHub
parent
bc4b2101ee
commit
7b737821b2
@@ -1,6 +1,6 @@
|
||||
import { CommandParser } from '@redis/client/dist/lib/client/parser';
|
||||
import { RedisArgument, Command, UnwrapReply, NullReply, NumberReply, TuplesToMapReply, Resp2Reply, SimpleStringReply, TypeMapping } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformInfoV2Reply } from '.';
|
||||
import { transformInfoV2Reply } from './helpers';
|
||||
|
||||
export type BfInfoReplyMap = TuplesToMapReply<[
|
||||
[SimpleStringReply<'Capacity'>, NumberReply],
|
||||
|
29
packages/bloom/lib/commands/bloom/helpers.ts
Normal file
29
packages/bloom/lib/commands/bloom/helpers.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { RESP_TYPES, TypeMapping } from "@redis/client";
|
||||
|
||||
export function transformInfoV2Reply<T>(reply: Array<any>, typeMapping?: TypeMapping): T {
|
||||
const mapType = typeMapping ? typeMapping[RESP_TYPES.MAP] : undefined;
|
||||
|
||||
switch (mapType) {
|
||||
case Array: {
|
||||
return reply as unknown as T;
|
||||
}
|
||||
case Map: {
|
||||
const ret = new Map<string, any>();
|
||||
|
||||
for (let i = 0; i < reply.length; i += 2) {
|
||||
ret.set(reply[i].toString(), reply[i + 1]);
|
||||
}
|
||||
|
||||
return ret as unknown as T;
|
||||
}
|
||||
default: {
|
||||
const ret = Object.create(null);
|
||||
|
||||
for (let i = 0; i < reply.length; i += 2) {
|
||||
ret[reply[i].toString()] = reply[i + 1];
|
||||
}
|
||||
|
||||
return ret as unknown as T;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
import type { RedisCommands, TypeMapping } from '@redis/client/dist/lib/RESP/types';
|
||||
import type { RedisCommands } from '@redis/client/dist/lib/RESP/types';
|
||||
|
||||
import ADD from './ADD';
|
||||
import CARD from './CARD';
|
||||
@@ -10,7 +10,8 @@ import MADD from './MADD';
|
||||
import MEXISTS from './MEXISTS';
|
||||
import RESERVE from './RESERVE';
|
||||
import SCANDUMP from './SCANDUMP';
|
||||
import { RESP_TYPES } from '@redis/client';
|
||||
|
||||
export * from './helpers';
|
||||
|
||||
export default {
|
||||
ADD,
|
||||
@@ -34,31 +35,3 @@ export default {
|
||||
SCANDUMP,
|
||||
scanDump: SCANDUMP
|
||||
} as const satisfies RedisCommands;
|
||||
|
||||
export function transformInfoV2Reply<T>(reply: Array<any>, typeMapping?: TypeMapping): T {
|
||||
const mapType = typeMapping ? typeMapping[RESP_TYPES.MAP] : undefined;
|
||||
|
||||
switch (mapType) {
|
||||
case Array: {
|
||||
return reply as unknown as T;
|
||||
}
|
||||
case Map: {
|
||||
const ret = new Map<string, any>();
|
||||
|
||||
for (let i = 0; i < reply.length; i += 2) {
|
||||
ret.set(reply[i].toString(), reply[i + 1]);
|
||||
}
|
||||
|
||||
return ret as unknown as T;
|
||||
}
|
||||
default: {
|
||||
const ret = Object.create(null);
|
||||
|
||||
for (let i = 0; i < reply.length; i += 2) {
|
||||
ret[reply[i].toString()] = reply[i + 1];
|
||||
}
|
||||
|
||||
return ret as unknown as T;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user