From be5ff18d2372571576508cc0bbb3b4679c0cef7c Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 1 Jul 2021 16:00:01 -0400 Subject: [PATCH] replace "modern" with "v4" --- benchmark/index.js | 2 +- lib/client.spec.ts | 14 +++++++------- lib/client.ts | 12 ++++++------ lib/multi-command.ts | 14 +++++++------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/benchmark/index.js b/benchmark/index.js index affe737045..49f1d5dc4a 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -4,7 +4,7 @@ const cronometro = require('cronometro'), let client; cronometro({ - 'New Client - Modern Mode': { + 'New Client': { async before() { client = newRedis.createClient(); await client.connect(); diff --git a/lib/client.spec.ts b/lib/client.spec.ts index 31bbf2edb0..031b9c36f9 100644 --- a/lib/client.spec.ts +++ b/lib/client.spec.ts @@ -41,7 +41,7 @@ describe('Client', () => { }); before(() => client.connect()); - afterEach(() => client.modern.flushAll()); + afterEach(() => client.v4.flushAll()); after(() => client.disconnect()); it('client.sendCommand should call the callback', done => { @@ -61,12 +61,12 @@ describe('Client', () => { it('client.sendCommand should work without callback', async () => { (client as any).sendCommand('PING'); - await client.modern.ping(); // make sure the first command was replied + await client.v4.ping(); // make sure the first command was replied }); - it('client.modern.sendCommand should return a promise', async () => { + it('client.v4.sendCommand should return a promise', async () => { assert.equal( - await client.modern.sendCommand(['PING']), + await client.v4.sendCommand(['PING']), 'PONG' ); }); @@ -137,12 +137,12 @@ describe('Client', () => { (client as any).multi() .ping() .exec(); - await client.modern.ping(); // make sure the first command was replied + await client.v4.ping(); // make sure the first command was replied }); - it('client.modern.exec should return a promise', async () => { + it('client.v4.exec should return a promise', async () => { assert.deepEqual( - await ((client as any).multi().modern + await ((client as any).multi().v4 .ping() .exec()), ['PONG'] diff --git a/lib/client.ts b/lib/client.ts index 751b114fc1..36aa318473 100644 --- a/lib/client.ts +++ b/lib/client.ts @@ -68,7 +68,7 @@ export default class RedisClient }; - readonly #modern: Record = {}; + readonly #v4: Record = {}; #selectedDB = 0; get options(): RedisClientOptions | null | undefined { @@ -79,12 +79,12 @@ export default class RedisClient { + get v4(): Record { if (!this.#options?.legacyMode) { throw new Error('the client is not in "legacy mode"'); } - return this.#modern; + return this.#v4; } constructor(options?: RedisClientOptions) { @@ -218,13 +218,13 @@ export default class RedisClient): void => { const options = isCommandOptions(args[0]) && args.shift(), callback = typeof args[args.length - 1] === 'function' && (args.pop() as Function); - this.#modern.sendCommand(args.flat(), options) + this.#v4.sendCommand(args.flat(), options) .then((reply: unknown) => { if (!callback) return; @@ -274,7 +274,7 @@ export default class RedisClient): void { this.sendCommand(name, ...args); }; diff --git a/lib/multi-command.ts b/lib/multi-command.ts index 69a0146cca..8644c81cd9 100644 --- a/lib/multi-command.ts +++ b/lib/multi-command.ts @@ -48,14 +48,14 @@ export default class RedisMultiCommand(); - readonly #modern: Record = {}; + readonly #v4: Record = {}; - get modern(): Record { + get v4(): Record { if (!this.#clientOptions?.legacyMode) { throw new Error('client is not in "legacy mode"'); } - return this.#modern; + return this.#v4; } constructor(executor: RedisMultiExecutor, clientOptions?: RedisClientOptions) { @@ -110,12 +110,12 @@ export default class RedisMultiCommand | undefined { if (!this.#clientOptions?.legacyMode) return; - this.#modern.exec = this.exec.bind(this); - this.#modern.addCommand = this.addCommand.bind(this); + this.#v4.exec = this.exec.bind(this); + this.#v4.addCommand = this.addCommand.bind(this); (this as any).exec = function (...args: Array): void { const callback = typeof args[args.length - 1] === 'function' && args.pop() as Function; - this.#modern.exec() + this.#v4.exec() .then((reply: unknown) => { if (!callback) return; @@ -152,7 +152,7 @@ export default class RedisMultiCommand) {