1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

add buffer support to a bunch of commands

This commit is contained in:
leibale
2021-12-15 17:08:50 -05:00
parent 72072f6b1c
commit a1bed9a10f
88 changed files with 821 additions and 381 deletions

View File

@@ -1,23 +1,44 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
export function transformArguments(key: string, group: string): Array<string> {
export function transformArguments(
key: RedisCommandArgument,
group: RedisCommandArgument
): RedisCommandArguments {
return ['XPENDING', key, group];
}
type XPendingRawReply = [
pending: number,
firstId: string | null,
lastId: string | null,
consumers: Array<[
name: string,
deliveriesCounter: number
]> | null
]
interface XPendingReply {
pending: number;
firstId: string | null;
lastId: number | null
consumers: Array<string> | null;
lastId: string | null
consumers: Array<{
name: string,
deliveriesCounter: number
}> | null;
}
export function transformReply(reply: [number, string | null, number | null, Array<string> | null]): XPendingReply {
export function transformReply(reply: XPendingRawReply): XPendingReply {
return {
pending: reply[0],
firstId: reply[1],
lastId: reply[2],
consumers: reply[3]
consumers: reply[3] === null ? null : reply[3].map(([name, deliveriesCounter]) => ({
name,
deliveriesCounter
}))
};
}