1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-19 07:02:06 +03:00
Files
node-redis/lib/commands/SCAN.ts
2021-06-01 17:49:49 -04:00

38 lines
750 B
TypeScript

export const IS_READ_ONLY = true;
export interface ScanOptions {
MATCH?: string;
COUNT?: number;
TYPE?: string;
}
export function transformArguments(cursor: number, options?: ScanOptions): Array<string> {
const args = ['SCAN', cursor.toString()];
if (options?.MATCH) {
args.push('MATCH', options.MATCH);
}
if (options?.COUNT) {
args.push('COUNT', options.COUNT.toString());
}
if (options?.TYPE) {
args.push('TYPE', options.TYPE);
}
return args;
}
interface ScanReply {
cursor: number;
keys: Array<string>
}
export function transformReply(reply: [string, Array<string>]): ScanReply {
return {
cursor: Number(reply[0]),
keys: reply[1]
};
}