/** * RESP Protocol Parser * Implements Redis Serialization Protocol (RESP) parsing * Requirements: 1.14 */ /** * RESP value types representing all Redis protocol data types */ export type RespSimpleString = { type: 'simple'; value: string; }; export type RespError = { type: 'error'; value: string; }; export type RespInteger = { type: 'integer'; value: number; }; export type RespBulkString = { type: 'bulk'; value: Buffer | null; }; export type RespArray = { type: 'array'; value: RespValue[] | null; }; export type RespValue = RespSimpleString | RespError | RespInteger | RespBulkString | RespArray; /** * Result of parsing RESP data from a buffer */ export interface ParseResult { /** The parsed RESP value, or null if incomplete data */ value: RespValue | null; /** Number of bytes consumed from the buffer */ bytesConsumed: number; } /** * Result of parsing a Redis command */ export interface CommandParseResult { /** The command as an array of strings */ command: string[]; /** Number of bytes consumed from the buffer */ bytesConsumed: number; } /** * RESP Protocol Parser * Parses Redis Serialization Protocol data from buffers */ export declare class RespParser { private buffer; /** * Append data to the internal buffer */ appendData(data: Buffer): void; /** * Get the current buffer contents */ getBuffer(): Buffer; /** * Clear the internal buffer */ clearBuffer(): void; /** * Consume bytes from the internal buffer */ consumeBytes(count: number): void; /** * Parse RESP data from a buffer * @param buffer The buffer containing RESP data * @returns ParseResult with the parsed value and bytes consumed */ parse(buffer: Buffer): ParseResult; /** * Parse a Redis command from the buffer (expects array of bulk strings) * @param buffer The buffer containing the command * @returns CommandParseResult or null if incomplete */ parseCommand(buffer: Buffer): CommandParseResult | null; /** * Find CRLF in buffer starting from offset */ private findCRLF; /** * Parse simple string: +OK\r\n */ private parseSimpleString; /** * Parse error: -ERR message\r\n */ private parseError; /** * Parse integer: :1000\r\n */ private parseInteger; /** * Parse bulk string: $6\r\nfoobar\r\n or $-1\r\n for null */ private parseBulkString; /** * Parse array: *2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n or *-1\r\n for null */ private parseArray; } //# sourceMappingURL=RespParser.d.ts.map