You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
26
packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.ts
Normal file
26
packages/bloom/lib/commands/top-k/LIST_WITHCOUNT.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
return ['TOPK.LIST', key, 'WITHCOUNT'];
|
||||
}
|
||||
|
||||
type ListWithCountRawReply = Array<string | number>;
|
||||
|
||||
type ListWithCountReply = Array<{
|
||||
item: string,
|
||||
count: number
|
||||
}>;
|
||||
|
||||
export function transformReply(rawReply: ListWithCountRawReply): ListWithCountReply {
|
||||
const reply: ListWithCountReply = [];
|
||||
for (let i = 0; i < rawReply.length; i++) {
|
||||
reply.push({
|
||||
item: rawReply[i] as string,
|
||||
count: rawReply[++i] as number
|
||||
});
|
||||
}
|
||||
|
||||
return reply;
|
||||
}
|
Reference in New Issue
Block a user