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

use dockers for tests, use npm workspaces, add rejson & redisearch modules, fix some bugs

This commit is contained in:
leibale
2021-11-08 19:21:15 -05:00
parent ecbd5b6968
commit 3eb99dbe83
689 changed files with 5321 additions and 1712 deletions

View File

@@ -0,0 +1,55 @@
export interface XReadGroupStream {
key: string;
id: string;
}
export interface XReadGroupOptions {
COUNT?: number;
BLOCK?: number;
NOACK?: true;
}
export const FIRST_KEY_INDEX = (
_group: string,
_consumer: string,
streams: Array<XReadGroupStream> | XReadGroupStream
): string => {
return Array.isArray(streams) ? streams[0].key : streams.key;
};
export const IS_READ_ONLY = true;
export function transformArguments(
group: string,
consumer: string,
streams: Array<XReadGroupStream> | XReadGroupStream,
options?: XReadGroupOptions
): Array<string> {
const args = ['XREADGROUP', 'GROUP', group, consumer];
if (options?.COUNT) {
args.push('COUNT', options.COUNT.toString());
}
if (typeof options?.BLOCK === 'number') {
args.push('BLOCK', options.BLOCK.toString());
}
if (options?.NOACK) {
args.push('NOACK');
}
args.push('STREAMS');
const streamsArray = Array.isArray(streams) ? streams : [streams],
argsLength = args.length;
for (let i = 0; i < streamsArray.length; i++) {
const stream = streamsArray[i];
args[argsLength + i] = stream.key;
args[argsLength + streamsArray.length + i] = stream.id;
}
return args;
}
export { transformReplyStreamsMessages as transformReply } from './generic-transformers';