forked from redis/node-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
93 lines (86 loc) · 2.3 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import * as ARRAPPEND from './ARRAPPEND';
import * as ARRINDEX from './ARRINDEX';
import * as ARRINSERT from './ARRINSERT';
import * as ARRLEN from './ARRLEN';
import * as ARRPOP from './ARRPOP';
import * as ARRTRIM from './ARRTRIM';
import * as DEBUG_MEMORY from './DEBUG_MEMORY';
import * as DEL from './DEL';
import * as FORGET from './FORGET';
import * as GET from './GET';
import * as MGET from './MGET';
import * as MSET from './MSET';
import * as NUMINCRBY from './NUMINCRBY';
import * as NUMMULTBY from './NUMMULTBY';
import * as OBJKEYS from './OBJKEYS';
import * as OBJLEN from './OBJLEN';
import * as RESP from './RESP';
import * as SET from './SET';
import * as STRAPPEND from './STRAPPEND';
import * as STRLEN from './STRLEN';
import * as TYPE from './TYPE';
export default {
ARRAPPEND,
arrAppend: ARRAPPEND,
ARRINDEX,
arrIndex: ARRINDEX,
ARRINSERT,
arrInsert: ARRINSERT,
ARRLEN,
arrLen: ARRLEN,
ARRPOP,
arrPop: ARRPOP,
ARRTRIM,
arrTrim: ARRTRIM,
DEBUG_MEMORY,
debugMemory: DEBUG_MEMORY,
DEL,
del: DEL,
FORGET,
forget: FORGET,
GET,
get: GET,
MGET,
mGet: MGET,
MSET,
mSet: MSET,
NUMINCRBY,
numIncrBy: NUMINCRBY,
NUMMULTBY,
numMultBy: NUMMULTBY,
OBJKEYS,
objKeys: OBJKEYS,
OBJLEN,
objLen: OBJLEN,
RESP,
resp: RESP,
SET,
set: SET,
STRAPPEND,
strAppend: STRAPPEND,
STRLEN,
strLen: STRLEN,
TYPE,
type: TYPE
};
// https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface RedisJSONArray extends Array<RedisJSON> {}
interface RedisJSONObject {
[key: string]: RedisJSON;
[key: number]: RedisJSON;
}
export type RedisJSON = null | boolean | number | string | Date | RedisJSONArray | RedisJSONObject;
export function transformRedisJsonArgument(json: RedisJSON): string {
return JSON.stringify(json);
}
export function transformRedisJsonReply(json: string): RedisJSON {
return JSON.parse(json);
}
export function transformRedisJsonNullReply(json: string | null): RedisJSON | null {
if (json === null) return null;
return transformRedisJsonReply(json);
}
export function transformNumbersReply(reply: string): number | Array<number> {
return JSON.parse(reply);
}