You've already forked node-redis
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:
41
packages/client/lib/commands/XREAD.ts
Normal file
41
packages/client/lib/commands/XREAD.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
export const FIRST_KEY_INDEX = (streams: Array<XReadStream> | XReadStream): string => {
|
||||
return Array.isArray(streams) ? streams[0].key : streams.key;
|
||||
};
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
interface XReadStream {
|
||||
key: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface XReadOptions {
|
||||
COUNT?: number;
|
||||
BLOCK?: number;
|
||||
}
|
||||
|
||||
export function transformArguments(streams: Array<XReadStream> | XReadStream, options?: XReadOptions): Array<string> {
|
||||
const args = ['XREAD'];
|
||||
|
||||
if (options?.COUNT) {
|
||||
args.push('COUNT', options.COUNT.toString());
|
||||
}
|
||||
|
||||
if (typeof options?.BLOCK === 'number') {
|
||||
args.push('BLOCK', options.BLOCK.toString());
|
||||
}
|
||||
|
||||
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';
|
Reference in New Issue
Block a user