You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
* Support the NOVALUES option of HSCAN Issue #2705 The NOVALUES option instructs HSCAN to only return keys, without their values. This is materialized as a new command, `hScanNoValues`, given that the return type is different from the usual return type of `hScan`. Also a new iterator is provided, `hScanNoValuesIterator`, for the same reason. * skip hscan novalues test if redis < 7.4 * Also don't test hscan no values iterator < 7.4 --------- Co-authored-by: Shaya Potter <spotter@gmail.com>
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import { RedisCommandArgument, RedisCommandArguments } from '.';
|
|
import { ScanOptions, pushScanArguments } from './generic-transformers';
|
|
|
|
export const FIRST_KEY_INDEX = 1;
|
|
|
|
export const IS_READ_ONLY = true;
|
|
|
|
export function transformArguments(
|
|
key: RedisCommandArgument,
|
|
cursor: number,
|
|
options?: ScanOptions
|
|
): RedisCommandArguments {
|
|
return pushScanArguments([
|
|
'HSCAN',
|
|
key
|
|
], cursor, options);
|
|
}
|
|
|
|
export type HScanRawReply = [RedisCommandArgument, Array<RedisCommandArgument>];
|
|
|
|
export interface HScanTuple {
|
|
field: RedisCommandArgument;
|
|
value: RedisCommandArgument;
|
|
}
|
|
|
|
interface HScanReply {
|
|
cursor: number;
|
|
tuples: Array<HScanTuple>;
|
|
}
|
|
|
|
export function transformReply([cursor, rawTuples]: HScanRawReply): HScanReply {
|
|
const parsedTuples = [];
|
|
for (let i = 0; i < rawTuples.length; i += 2) {
|
|
parsedTuples.push({
|
|
field: rawTuples[i],
|
|
value: rawTuples[i + 1]
|
|
});
|
|
}
|
|
|
|
return {
|
|
cursor: Number(cursor),
|
|
tuples: parsedTuples
|
|
};
|
|
}
|