1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-03 04:01:40 +03:00
Files
Pavel Pashov b52177752e feat: added support for new bitop operations (#3001)
refactored bitop tests, covered all operations

updated default docker version on all packages
2025-06-19 13:56:00 +03:00

28 lines
969 B
TypeScript

import { CommandParser } from '../client/parser';
import { NumberReply, Command, RedisArgument } from '../RESP/types';
import { RedisVariadicArgument } from './generic-transformers';
export type BitOperations = 'AND' | 'OR' | 'XOR' | 'NOT' | 'DIFF' | 'DIFF1' | 'ANDOR' | 'ONE';
export default {
IS_READ_ONLY: false,
/**
* Performs bitwise operations between strings
* @param parser - The Redis command parser
* @param operation - Bitwise operation to perform: AND, OR, XOR, NOT, DIFF, DIFF1, ANDOR, ONE
* @param destKey - Destination key to store the result
* @param key - Source key(s) to perform operation on
*/
parseCommand(
parser: CommandParser,
operation: BitOperations,
destKey: RedisArgument,
key: RedisVariadicArgument
) {
parser.push('BITOP', operation);
parser.pushKey(destKey);
parser.pushKeys(key);
},
transformReply: undefined as unknown as () => NumberReply
} as const satisfies Command;