You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-03 04:01:40 +03:00
28 lines
701 B
TypeScript
28 lines
701 B
TypeScript
import { RedisJSON, transformRedisJsonNullReply } from '.';
|
|
|
|
export const FIRST_KEY_INDEX = 1;
|
|
|
|
export function transformArguments(key: string, path?: string, index?: number): Array<string> {
|
|
const args = ['JSON.ARRPOP', key];
|
|
|
|
if (path) {
|
|
args.push(path);
|
|
|
|
if (index !== undefined && index !== null) {
|
|
args.push(index.toString());
|
|
}
|
|
}
|
|
|
|
return args;
|
|
}
|
|
|
|
export function transformReply(reply: null | string | Array<null | string>): null | RedisJSON | Array<RedisJSON> {
|
|
if (reply === null) return null;
|
|
|
|
if (Array.isArray(reply)) {
|
|
return reply.map(transformRedisJsonNullReply);
|
|
}
|
|
|
|
return transformRedisJsonNullReply(reply);
|
|
}
|