1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-03 04:01:40 +03:00
Files
node-redis/packages/client/lib/commands/SCAN.ts
2021-12-20 14:47:51 -05:00

35 lines
818 B
TypeScript

import { RedisCommandArgument, RedisCommandArguments } from '.';
import { ScanOptions, pushScanArguments } from './generic-transformers';
export const IS_READ_ONLY = true;
export interface ScanCommandOptions extends ScanOptions {
TYPE?: RedisCommandArgument;
}
export function transformArguments(
cursor: number,
options?: ScanCommandOptions
): RedisCommandArguments {
const args = pushScanArguments(['SCAN'], cursor, options);
if (options?.TYPE) {
args.push('TYPE', options.TYPE);
}
return args;
}
type ScanRawReply = [string, Array<string>];
export interface ScanReply {
cursor: number;
keys: Array<RedisCommandArgument>;
}
export function transformReply([cursor, keys]: ScanRawReply): ScanReply {
return {
cursor: Number(cursor),
keys
};
}