You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-10 11:43:01 +03:00
* Parser support with all commands * remove "dist" from all imports for consistency * address most of my review comments * small tweak to multi type mapping handling * tweak multi commands / fix addScript cases * nits * addressed all in person review comments * revert addCommand/addScript changes to multi-commands addCommand needs to be there for sendCommand like ability within a multi. If its there, it might as well be used by createCommand() et al, to avoid repeating code. addScript is there (even though only used once), but now made private to keep the logic for bookkeeping near each other.
101 lines
2.3 KiB
TypeScript
101 lines
2.3 KiB
TypeScript
import { BlobStringReply, NullReply, UnwrapReply } from '@redis/client/lib/RESP/types';
|
|
import ARRAPPEND from './ARRAPPEND';
|
|
import ARRINDEX from './ARRINDEX';
|
|
import ARRINSERT from './ARRINSERT';
|
|
import ARRLEN from './ARRLEN';
|
|
import ARRPOP from './ARRPOP';
|
|
import ARRTRIM from './ARRTRIM';
|
|
import CLEAR from './CLEAR';
|
|
import DEBUG_MEMORY from './DEBUG_MEMORY';
|
|
import DEL from './DEL';
|
|
import FORGET from './FORGET';
|
|
import GET from './GET';
|
|
import MERGE from './MERGE';
|
|
import MGET from './MGET';
|
|
import MSET from './MSET';
|
|
import NUMINCRBY from './NUMINCRBY';
|
|
import NUMMULTBY from './NUMMULTBY';
|
|
import OBJKEYS from './OBJKEYS';
|
|
import OBJLEN from './OBJLEN';
|
|
// import RESP from './RESP';
|
|
import SET from './SET';
|
|
import STRAPPEND from './STRAPPEND';
|
|
import STRLEN from './STRLEN';
|
|
import TOGGLE from './TOGGLE';
|
|
import TYPE from './TYPE';
|
|
import { isNullReply } from '@redis/client/lib/commands/generic-transformers';
|
|
|
|
export default {
|
|
ARRAPPEND,
|
|
arrAppend: ARRAPPEND,
|
|
ARRINDEX,
|
|
arrIndex: ARRINDEX,
|
|
ARRINSERT,
|
|
arrInsert: ARRINSERT,
|
|
ARRLEN,
|
|
arrLen: ARRLEN,
|
|
ARRPOP,
|
|
arrPop: ARRPOP,
|
|
ARRTRIM,
|
|
arrTrim: ARRTRIM,
|
|
CLEAR,
|
|
clear: CLEAR,
|
|
DEBUG_MEMORY,
|
|
debugMemory: DEBUG_MEMORY,
|
|
DEL,
|
|
del: DEL,
|
|
FORGET,
|
|
forget: FORGET,
|
|
GET,
|
|
get: GET,
|
|
MERGE,
|
|
merge: MERGE,
|
|
MGET,
|
|
mGet: MGET,
|
|
MSET,
|
|
mSet: MSET,
|
|
NUMINCRBY,
|
|
numIncrBy: NUMINCRBY,
|
|
/**
|
|
* @deprecated since JSON version 2.0
|
|
*/
|
|
NUMMULTBY,
|
|
/**
|
|
* @deprecated since JSON version 2.0
|
|
*/
|
|
numMultBy: NUMMULTBY,
|
|
OBJKEYS,
|
|
objKeys: OBJKEYS,
|
|
OBJLEN,
|
|
objLen: OBJLEN,
|
|
// RESP,
|
|
// resp: RESP,
|
|
SET,
|
|
set: SET,
|
|
STRAPPEND,
|
|
strAppend: STRAPPEND,
|
|
STRLEN,
|
|
strLen: STRLEN,
|
|
TOGGLE,
|
|
toggle: TOGGLE,
|
|
TYPE,
|
|
type: TYPE
|
|
};
|
|
|
|
export type RedisJSON = null | boolean | number | string | Date | Array<RedisJSON> | {
|
|
[key: string]: RedisJSON;
|
|
[key: number]: RedisJSON;
|
|
};
|
|
|
|
export function transformRedisJsonArgument(json: RedisJSON): string {
|
|
return JSON.stringify(json);
|
|
}
|
|
|
|
export function transformRedisJsonReply(json: BlobStringReply): RedisJSON {
|
|
return JSON.parse((json as unknown as UnwrapReply<typeof json>).toString());
|
|
}
|
|
|
|
export function transformRedisJsonNullReply(json: NullReply | BlobStringReply): NullReply | RedisJSON {
|
|
return isNullReply(json) ? json : transformRedisJsonReply(json);
|
|
}
|