diff --git a/packages/client/lib/client/commands.ts b/packages/client/lib/client/commands.ts index 1e2e5274c0a..50034209d79 100644 --- a/packages/client/lib/client/commands.ts +++ b/packages/client/lib/client/commands.ts @@ -118,6 +118,7 @@ import * as SWAPDB from '../commands/SWAPDB'; import * as TIME from '../commands/TIME'; import * as UNWATCH from '../commands/UNWATCH'; import * as WAIT from '../commands/WAIT'; +import * as WAITAOF from '../commands/WAITAOF'; export default { ...CLUSTER_COMMANDS, @@ -358,5 +359,7 @@ export default { UNWATCH, unwatch: UNWATCH, WAIT, - wait: WAIT + wait: WAIT, + WAITAOF, + waitAOF: WAITAOF }; diff --git a/packages/client/lib/commands/WAITAOF.spec.ts b/packages/client/lib/commands/WAITAOF.spec.ts new file mode 100644 index 00000000000..3083cf954b4 --- /dev/null +++ b/packages/client/lib/commands/WAITAOF.spec.ts @@ -0,0 +1,23 @@ +import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; +import { transformArguments } from './WAITAOF'; + +describe('WAITAOF', () => { + testUtils.isVersionGreaterThanHook([7, 2]); + + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + transformArguments(1, 0, 0), + ['WAITAOF', '1', '0', '0'] + ); + }); + }); + + testUtils.testWithClient('client.wait', async client => { + assert.equal( + await client.waitAOF(1, 0, 0), + [1, 0] + ); + }, GLOBAL.SERVERS.OPEN); +}); diff --git a/packages/client/lib/commands/WAITAOF.ts b/packages/client/lib/commands/WAITAOF.ts new file mode 100644 index 00000000000..080d2f251ca --- /dev/null +++ b/packages/client/lib/commands/WAITAOF.ts @@ -0,0 +1,16 @@ +import { RedisCommandArguments } from '.'; + +export function transformArguments( + numlocal: number, + numreplicas: number, + timeout: number +): RedisCommandArguments { + return [ + 'WAITAOF', + numlocal.toString(), + numreplicas.toString(), + timeout.toString() + ]; +} + +export declare function transformReply(): Array<[number, number]>;