1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00
This commit is contained in:
Leibale
2023-07-18 16:32:45 -04:00
parent 8501db0243
commit fdd1978d92
43 changed files with 377 additions and 506 deletions

View File

@@ -20,11 +20,11 @@ describe('ARRAPPEND', () => {
});
testUtils.testWithClient('client.json.arrAppend', async client => {
await client.json.set('key', '$', []);
const [, reply] = await Promise.all([
client.json.set('key', '$', []),
client.json.arrAppend('key', '$', 1)
]);
assert.deepEqual(
await client.json.arrAppend('key', '$', 1),
[1]
);
assert.deepEqual(reply, [1]);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { RedisJSON, transformRedisJsonArgument } from '.';
import { RedisArgument, ArrayReply, NumberReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
import { RedisArgument, NumberReply, ArrayReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
export default {
FIRST_KEY_INDEX: 1,
@@ -13,5 +13,5 @@ export default {
return args;
},
transformReply: undefined as unknown as () => NumberReply | NullReply | ArrayReply<NumberReply | NullReply>
transformReply: undefined as unknown as () => NumberReply | ArrayReply<NumberReply | NullReply>
} as const satisfies Command;

View File

@@ -2,7 +2,7 @@ import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import ARRINDEX from './ARRINDEX';
describe('ARRINDEX', () => {
describe('JSON.ARRINDEX', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
@@ -10,28 +10,40 @@ describe('ARRINDEX', () => {
['JSON.ARRINDEX', 'key', '$', '"json"']
);
});
it('with start', () => {
assert.deepEqual(
ARRINDEX.transformArguments('key', '$', 'json', 1),
['JSON.ARRINDEX', 'key', '$', '"json"', '1']
);
});
describe('with range', () => {
it('start only', () => {
assert.deepEqual(
ARRINDEX.transformArguments('key', '$', 'json', {
range: {
start: 0
}
}),
['JSON.ARRINDEX', 'key', '$', '"json"', '0']
);
});
it('with start, end', () => {
assert.deepEqual(
ARRINDEX.transformArguments('key', '$', 'json', 1, 2),
['JSON.ARRINDEX', 'key', '$', '"json"', '1', '2']
);
it('with start and stop', () => {
assert.deepEqual(
ARRINDEX.transformArguments('key', '$', 'json', {
range: {
start: 0,
stop: 1
}
}),
['JSON.ARRINDEX', 'key', '$', '"json"', '0', '1']
);
});
});
});
testUtils.testWithClient('client.json.arrIndex', async client => {
await client.json.set('key', '$', []);
const [, reply] = await Promise.all([
client.json.set('key', '$', []),
client.json.arrIndex('key', '$', 'json')
]);
assert.deepEqual(
await client.json.arrIndex('key', '$', 'json'),
[-1]
);
assert.deepEqual(reply, [-1]);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,6 +1,13 @@
import { RedisArgument, ArrayReply, NumberReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
import { RedisArgument, NumberReply, ArrayReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
import { RedisJSON, transformRedisJsonArgument } from '.';
export interface JsonArrIndexOptions {
range?: {
start: number;
stop?: number;
};
}
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: true,
@@ -8,20 +15,19 @@ export default {
key: RedisArgument,
path: RedisArgument,
json: RedisJSON,
start?: number,
stop?: number
options?: JsonArrIndexOptions
) {
const args = ['JSON.ARRINDEX', key, path, transformRedisJsonArgument(json)];
if (start !== undefined && start !== null) {
args.push(start.toString());
if (options?.range) {
args.push(options.range.start.toString());
if (stop !== undefined && stop !== null) {
args.push(stop.toString());
if (options.range.stop !== undefined) {
args.push(options.range.stop.toString());
}
}
return args;
},
transformReply: undefined as unknown as () => NumberReply | NullReply | ArrayReply<NumberReply | NullReply>
transformReply: undefined as unknown as () => NumberReply | ArrayReply<NumberReply | NullReply>
} as const satisfies Command;

View File

@@ -20,11 +20,11 @@ describe('JSON.ARRINSERT', () => {
});
testUtils.testWithClient('client.json.arrInsert', async client => {
await client.json.set('key', '$', []);
const [, reply] = await Promise.all([
client.json.set('key', '$', []),
client.json.arrInsert('key', '$', 0, 'json')
]);
assert.deepEqual(
await client.json.arrInsert('key', '$', 0, 'json'),
[1]
);
assert.deepEqual(reply, [1]);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,11 +1,23 @@
import { RedisArgument, ArrayReply, NumberReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
import { RedisArgument, NumberReply, ArrayReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
import { RedisJSON, transformRedisJsonArgument } from '.';
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(key: RedisArgument, path: RedisArgument, index: number, ...jsons: Array<RedisJSON>) {
const args = ['JSON.ARRINSERT', key, path, index.toString()];
transformArguments(
key: RedisArgument,
path: RedisArgument,
index: number,
json: RedisJSON,
...jsons: Array<RedisJSON>
) {
const args = [
'JSON.ARRINSERT',
key,
path,
index.toString(),
transformRedisJsonArgument(json)
];
for (const json of jsons) {
args.push(transformRedisJsonArgument(json));
@@ -13,5 +25,5 @@ export default {
return args;
},
transformReply: undefined as unknown as () => NumberReply | NullReply | ArrayReply<NumberReply | NullReply>
transformReply: undefined as unknown as () => NumberReply | ArrayReply<NumberReply | NullReply>
} as const satisfies Command;

View File

@@ -4,7 +4,7 @@ import ARRLEN from './ARRLEN';
describe('JSON.ARRLEN', () => {
describe('transformArguments', () => {
it('without path', () => {
it('simple', () => {
assert.deepEqual(
ARRLEN.transformArguments('key'),
['JSON.ARRLEN', 'key']
@@ -13,18 +13,20 @@ describe('JSON.ARRLEN', () => {
it('with path', () => {
assert.deepEqual(
ARRLEN.transformArguments('key', '$'),
ARRLEN.transformArguments('key', {
path: '$'
}),
['JSON.ARRLEN', 'key', '$']
);
});
});
testUtils.testWithClient('client.json.arrLen', async client => {
await client.json.set('key', '$', []);
const [, reply] = await Promise.all([
client.json.set('key', '$', []),
client.json.arrLen('key')
]);
assert.deepEqual(
await client.json.arrLen('key', '$'),
[0]
);
assert.deepEqual(reply, 0);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,16 +1,20 @@
import { RedisArgument, ArrayReply, NumberReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
export interface JsonArrLenOptions {
path?: RedisArgument;
}
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: true,
transformArguments(key: RedisArgument, path?: RedisArgument) {
transformArguments(key: RedisArgument, options?: JsonArrLenOptions) {
const args = ['JSON.ARRLEN', key];
if (path) {
args.push(path);
if (options?.path) {
args.push(options.path);
}
return args;
},
transformReply: undefined as unknown as () => NumberReply | NullReply | ArrayReply<NumberReply | NullReply>
transformReply: undefined as unknown as () => NumberReply | ArrayReply<NumberReply | NullReply>
} as const satisfies Command;

View File

@@ -11,11 +11,11 @@ describe('JSON.ARRTRIM', () => {
});
testUtils.testWithClient('client.json.arrTrim', async client => {
await client.json.set('key', '$', []);
const [, reply] = await Promise.all([
client.json.set('key', '$', []),
client.json.arrTrim('key', '$', 0, 1)
]);
assert.deepEqual(
await client.json.arrTrim('key', '$', 0, 1),
[0]
);
assert.deepEqual(reply, [0]);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -6,5 +6,5 @@ export default {
transformArguments(key: RedisArgument, path: RedisArgument, start: number, stop: number) {
return ['JSON.ARRTRIM', key, path, start.toString(), stop.toString()];
},
transformReply: undefined as unknown as () => NumberReply | NullReply | ArrayReply<NumberReply | NullReply>
transformReply: undefined as unknown as () => NumberReply | ArrayReply<NumberReply | NullReply>
} as const satisfies Command;

View File

@@ -4,17 +4,19 @@ import CLEAR from './CLEAR';
describe('JSON.CLEAR', () => {
describe('transformArguments', () => {
it('key', () => {
it('simple', () => {
assert.deepEqual(
CLEAR.transformArguments('key'),
['JSON.CLEAR', 'key']
);
});
it('key, path', () => {
it('with path', () => {
assert.deepEqual(
CLEAR.transformArguments('key', '$.path'),
['JSON.CLEAR', 'key', '$.path']
CLEAR.transformArguments('key', {
path: '$'
}),
['JSON.CLEAR', 'key', '$']
);
});
});

View File

@@ -1,12 +1,18 @@
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
export interface JsonClearOptions {
path?: RedisArgument;
}
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(key: RedisArgument, path?: RedisArgument) {
transformArguments(key: RedisArgument, options?: JsonClearOptions) {
const args = ['JSON.CLEAR', key];
if (path) args.push(path);
if (options?.path) {
args.push(options.path);
}
return args;
},

View File

@@ -2,7 +2,7 @@ import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import DEBUG_MEMORY from './DEBUG_MEMORY';
describe('DEBUG MEMORY', () => {
describe('JSON.DEBUG MEMORY', () => {
describe('transformArguments', () => {
it('without path', () => {
assert.deepEqual(
@@ -19,10 +19,10 @@ describe('DEBUG MEMORY', () => {
});
});
testUtils.testWithClient('client.json.arrTrim', async client => {
testUtils.testWithClient('client.json.debugMemory', async client => {
assert.deepEqual(
await client.json.debugMemory('key', '$'),
[]
0
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,4 +1,4 @@
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
import { RedisArgument, NumberReply, ArrayReply, Command } from '@redis/client/dist/lib/RESP/types';
export default {
FIRST_KEY_INDEX: 2,

View File

@@ -2,18 +2,20 @@ import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import DEL from './DEL';
describe('DEL', () => {
describe('JSON.DEL', () => {
describe('transformArguments', () => {
it('key', () => {
it('simple', () => {
assert.deepEqual(
DEL.transformArguments('key'),
['JSON.DEL', 'key']
);
});
it('key, path', () => {
it('with path', () => {
assert.deepEqual(
DEL.transformArguments('key', '$.path'),
DEL.transformArguments('key', {
path: '$.path'
}),
['JSON.DEL', 'key', '$.path']
);
});

View File

@@ -1,13 +1,17 @@
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
export interface JsonDelOptions {
path?: RedisArgument
}
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(key: RedisArgument, path?: RedisArgument) {
transformArguments(key: RedisArgument, options?: JsonDelOptions) {
const args = ['JSON.DEL', key];
if (path) {
args.push(path);
if (options?.path) {
args.push(options.path);
}
return args;

View File

@@ -2,7 +2,7 @@ import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import FORGET from './FORGET';
describe('FORGET', () => {
describe('JSON.FORGET', () => {
describe('transformArguments', () => {
it('key', () => {
assert.deepEqual(
@@ -13,7 +13,9 @@ describe('FORGET', () => {
it('key, path', () => {
assert.deepEqual(
FORGET.transformArguments('key', '$.path'),
FORGET.transformArguments('key', {
path: '$.path'
}),
['JSON.FORGET', 'key', '$.path']
);
});

View File

@@ -1,13 +1,17 @@
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
export interface JsonForgetOptions {
path?: RedisArgument;
}
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(key: RedisArgument, path?: RedisArgument) {
transformArguments(key: RedisArgument, options?: JsonForgetOptions) {
const args = ['JSON.FORGET', key];
if (path) {
args.push(path);
if (options?.path) {
args.push(options.path);
}
return args;

View File

@@ -1,42 +1,42 @@
import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
// import { pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
// import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
export const FIRST_KEY_INDEX = 1;
// export const FIRST_KEY_INDEX = 1;
export const IS_READ_ONLY = true;
// export const IS_READ_ONLY = true;
interface GetOptions {
path?: string | Array<string>;
INDENT?: string;
NEWLINE?: string;
SPACE?: string;
NOESCAPE?: true;
}
// interface GetOptions {
// path?: string | Array<string>;
// INDENT?: string;
// NEWLINE?: string;
// SPACE?: string;
// NOESCAPE?: true;
// }
export function transformArguments(key: string, options?: GetOptions): RedisCommandArguments {
let args: RedisCommandArguments = ['JSON.GET', key];
// export function transformArguments(key: string, options?: GetOptions): RedisCommandArguments {
// let args: RedisCommandArguments = ['JSON.GET', key];
if (options?.path) {
args = pushVariadicArguments(args, options.path);
}
// if (options?.path) {
// args = pushVariadicArguments(args, options.path);
// }
if (options?.INDENT) {
args.push('INDENT', options.INDENT);
}
// if (options?.INDENT) {
// args.push('INDENT', options.INDENT);
// }
if (options?.NEWLINE) {
args.push('NEWLINE', options.NEWLINE);
}
// if (options?.NEWLINE) {
// args.push('NEWLINE', options.NEWLINE);
// }
if (options?.SPACE) {
args.push('SPACE', options.SPACE);
}
// if (options?.SPACE) {
// args.push('SPACE', options.SPACE);
// }
if (options?.NOESCAPE) {
args.push('NOESCAPE');
}
// if (options?.NOESCAPE) {
// args.push('NOESCAPE');
// }
return args;
}
// return args;
// }
export { transformRedisJsonNullReply as transformReply } from '.';
// export { transformRedisJsonNullReply as transformReply } from '.';

View File

@@ -1,4 +1,4 @@
import { RedisArgument, Command, ArrayReply, NumberReply, DoubleReply, NullReply } from '@redis/client/dist/lib/RESP/types';
import { RedisArgument, NumberReply, DoubleReply, NullReply, BlobStringReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
export default {
FIRST_KEY_INDEX: 1,
@@ -6,5 +6,10 @@ export default {
transformArguments(key: RedisArgument, path: RedisArgument, by: number) {
return ['JSON.NUMINCRBY', key, path, by.toString()];
},
transformReply: undefined as unknown as () => ArrayReply<NumberReply | DoubleReply | NullReply>
transformReply: {
2: (reply: UnwrapReply<BlobStringReply>) => {
return JSON.parse(reply.toString()) as number | Array<number>;
},
3: undefined as unknown as () => NumberReply | DoubleReply | NullReply
}
} as const satisfies Command;

View File

@@ -1,7 +1,5 @@
import { RedisArgument, ArrayReply, BlobStringReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
type ReplyItem = ArrayReply<BlobStringReply> | NullReply;
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
@@ -14,5 +12,5 @@ export default {
return args;
},
transformReply: undefined as unknown as () => ReplyItem | ArrayReply<ReplyItem>
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply> | ArrayReply<ArrayReply<BlobStringReply> | NullReply>
} as const satisfies Command;

View File

@@ -19,10 +19,10 @@ describe('JSON.OBJLEN', () => {
});
});
// testUtils.testWithClient('client.json.objLen', async client => {
// assert.equal(
// await client.json.objLen('key', '$'),
// [null]
// );
// }, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('client.json.objLen', async client => {
assert.equal(
await client.json.objLen('key', '$'),
[null]
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,8 +1,8 @@
import { RedisArgument, ArrayReply, NumberReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
import { RedisArgument, NumberReply, ArrayReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
IS_READ_ONLY: true,
transformArguments(key: RedisArgument, path?: RedisArgument) {
const args = ['JSON.OBJLEN', key];
@@ -12,5 +12,5 @@ export default {
return args;
},
transformReply: undefined as unknown as () => NumberReply | NullReply | ArrayReply<NumberReply | NullReply>
transformReply: undefined as unknown as () => NumberReply | ArrayReply<NumberReply | NullReply>
} as const satisfies Command;

View File

@@ -19,3 +19,14 @@
// }
// export declare function transformReply(): number | Array<number>;
import { SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments() {
return ['JSON.STRAPPEND'];
},
transformReply: undefined as unknown as () => SimpleStringReply
} as const satisfies Command;

View File

@@ -20,11 +20,11 @@ describe('JSON.STRLEN', () => {
});
testUtils.testWithClient('client.json.strLen', async client => {
await client.json.set('key', '$', '');
const [, reply] = await Promise.all([
client.json.set('key', '$', ''),
client.json.strLen('key', '$')
]);
assert.deepEqual(
await client.json.strLen('key', '$'),
[0]
);
assert.deepEqual(reply, [0]);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -12,5 +12,5 @@ export default {
return args;
},
transformReply: undefined as unknown as () => NumberReply | NullReply | ArrayReply<NumberReply | NullReply>
transformReply: undefined as unknown as () => NumberReply | ArrayReply<NumberReply | NullReply>
} as const satisfies Command;

View File

@@ -20,11 +20,11 @@ describe('JSON.TOGGLE', () => {
});
testUtils.testWithClient('client.json.toggle', async client => {
await client.json.set('key', '$', '');
const [, reply] = await Promise.all([
client.json.set('key', '$', ''),
client.json.toggle('key', '$')
]);
assert.deepEqual(
await client.json.toggle('key', '$'),
[0]
);
assert.deepEqual(reply, [0]);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,12 +1,14 @@
import { RedisArgument, ArrayReply, NumberReply, NullReply, Command, } from '@redis/client/dist/lib/RESP/types';
export default {
FIRST_KEY_INDEX: undefined,
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(key: RedisArgument, path?: RedisArgument) {
const args = ['JSON.TOGGLE', key]
if (path) args.push(path);
if (path) {
args.push(path);
}
return args;
},

View File

@@ -1,93 +1,96 @@
import * as ARRAPPEND from './ARRAPPEND';
import * as ARRINDEX from './ARRINDEX';
import * as ARRINSERT from './ARRINSERT';
import ARRAPPEND from './ARRAPPEND';
import ARRINDEX from './ARRINDEX';
import ARRINSERT from './ARRINSERT';
import CLEAR from './CLEAR';
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 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';
import ARRLEN from './ARRLEN';
// import ARRPOP from './ARRPOP';
import ARRTRIM from './ARRTRIM';
import DEBUG_MEMORY from './DEBUG_MEMORY';
import DEL from './DEL';
import FORGET from './FORGET';
// import GET from './GET';
// import MGET from './MGET';
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';
export default {
ARRAPPEND,
arrAppend: ARRAPPEND,
ARRINDEX,
arrIndex: ARRINDEX,
ARRINSERT,
arrInsert: ARRINSERT,
CLEAR,
clear: CLEAR,
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,
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
ARRAPPEND,
arrAppend: ARRAPPEND,
ARRINDEX,
arrIndex: ARRINDEX,
ARRINSERT,
arrInsert: ARRINSERT,
CLEAR,
clear: CLEAR,
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,
NUMINCRBY,
numIncrBy: NUMINCRBY,
NUMMULTBY,
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
};
// https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface RedisJSONArray extends Array<RedisJSON> {}
interface RedisJSONArray extends Array<RedisJSON> { }
interface RedisJSONObject {
[key: string]: RedisJSON;
[key: number]: RedisJSON;
[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);
return JSON.stringify(json);
}
export function transformRedisJsonReply(json: string): RedisJSON {
return JSON.parse(json);
return JSON.parse(json);
}
export function transformRedisJsonNullReply(json: string | null): RedisJSON | null {
if (json === null) return null;
if (json === null) return null;
return transformRedisJsonReply(json);
return transformRedisJsonReply(json);
}
export function transformNumbersReply(reply: string): number | Array<number> {
return JSON.parse(reply);
return JSON.parse(reply);
}