You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
(docs) add jsdoc comments to command parsers (#2984)
* (docs) bloom: add jsdocs for all commands * (docs) json: add jsdocs * (docs) search: add jsdocs for all commands * (docs) jsdocs for std commands * (docs) jsdoc comments to time series commands
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
import { CommandParser } from '../client/parser';
|
||||
import { RedisArgument, CommandArguments, BlobStringReply, ArrayReply, Command } from '../RESP/types';
|
||||
|
||||
/**
|
||||
* Common options for SCAN-type commands
|
||||
*
|
||||
* @property MATCH - Pattern to filter returned keys
|
||||
* @property COUNT - Hint for how many elements to return per iteration
|
||||
*/
|
||||
export interface ScanCommonOptions {
|
||||
MATCH?: string;
|
||||
COUNT?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses scan arguments for SCAN-type commands
|
||||
*
|
||||
* @param parser - The command parser
|
||||
* @param cursor - The cursor position for iteration
|
||||
* @param options - Scan options
|
||||
*/
|
||||
export function parseScanArguments(
|
||||
parser: CommandParser,
|
||||
cursor: RedisArgument,
|
||||
@@ -21,6 +34,14 @@ export function parseScanArguments(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes scan arguments to the command arguments array
|
||||
*
|
||||
* @param args - The command arguments array
|
||||
* @param cursor - The cursor position for iteration
|
||||
* @param options - Scan options
|
||||
* @returns The updated command arguments array
|
||||
*/
|
||||
export function pushScanArguments(
|
||||
args: CommandArguments,
|
||||
cursor: RedisArgument,
|
||||
@@ -39,6 +60,11 @@ export function pushScanArguments(
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for the SCAN command
|
||||
*
|
||||
* @property TYPE - Filter by value type
|
||||
*/
|
||||
export interface ScanOptions extends ScanCommonOptions {
|
||||
TYPE?: RedisArgument;
|
||||
}
|
||||
@@ -46,6 +72,14 @@ export interface ScanOptions extends ScanCommonOptions {
|
||||
export default {
|
||||
NOT_KEYED_COMMAND: true,
|
||||
IS_READ_ONLY: true,
|
||||
/**
|
||||
* Constructs the SCAN command
|
||||
*
|
||||
* @param parser - The command parser
|
||||
* @param cursor - The cursor position to start scanning from
|
||||
* @param options - Scan options
|
||||
* @see https://redis.io/commands/scan/
|
||||
*/
|
||||
parseCommand(parser: CommandParser, cursor: RedisArgument, options?: ScanOptions) {
|
||||
parser.push('SCAN');
|
||||
parseScanArguments(parser, cursor, options);
|
||||
@@ -54,6 +88,12 @@ export default {
|
||||
parser.push('TYPE', options.TYPE);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Transforms the SCAN reply into a structured object
|
||||
*
|
||||
* @param reply - The raw reply containing cursor and keys
|
||||
* @returns Object with cursor and keys properties
|
||||
*/
|
||||
transformReply([cursor, keys]: [BlobStringReply, ArrayReply<BlobStringReply>]) {
|
||||
return {
|
||||
cursor,
|
||||
|
Reference in New Issue
Block a user