From 6085cd863efa8aeacbe9e9041580d089c35586ab Mon Sep 17 00:00:00 2001 From: Guian Gumpac Date: Thu, 25 Jul 2024 15:45:29 -0700 Subject: [PATCH] Addressed PR comments Signed-off-by: Guian Gumpac --- node/src/BaseClient.ts | 10 +++++----- node/src/Transaction.ts | 6 ++++-- node/tests/SharedTests.ts | 5 +++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/node/src/BaseClient.ts b/node/src/BaseClient.ts index 0669c04bc0..bef12ff90a 100644 --- a/node/src/BaseClient.ts +++ b/node/src/BaseClient.ts @@ -3551,7 +3551,7 @@ export class BaseClient { * @param keys - The keys of the sorted sets. * @param modifier - The element pop criteria - either {@link ScoreFilter.MIN} or * {@link ScoreFilter.MAX} to pop the member with the lowest/highest score accordingly. - * @param count - The number of elements to pop. + * @param count - (Optional) The number of elements to pop. If not supplied, only one element will be popped. * @returns A two-element `array` containing the key name of the set from which the element * was popped, and a member-score `Record` of the popped element. * If no member could be popped, returns `null`. @@ -3566,7 +3566,7 @@ export class BaseClient { * // Output: [ "zSet1", { three: 3, two: 2 } ] - "three" with score 3 and "two" with score 2 were popped from "zSet1". * ``` */ - public zmpop( + public async zmpop( keys: string[], modifier: ScoreFilter, count?: number, @@ -3583,14 +3583,14 @@ export class BaseClient { * * @remarks * 1. When in cluster mode, all `keys` must map to the same hash slot. - * 2. `BZMPOP` is a client blocking command, see https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands + * 2. `BZMPOP` is a client blocking command, see {@link https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands | the wiki} * for more details and best practices. * @param keys - The keys of the sorted sets. * @param modifier - The element pop criteria - either {@link ScoreFilter.MIN} or * {@link ScoreFilter.MAX} to pop the member with the lowest/highest score accordingly. - * @param count - The number of elements to pop. * @param timeout - The number of seconds to wait for a blocking operation to complete. * A value of 0 will block indefinitely. + * @param count - (Optional) The number of elements to pop. If not supplied, only one element will be popped. * @returns A two-element `array` containing the key name of the set from which the element * was popped, and a member-score `Record` of the popped element. * If no member could be popped, returns `null`. @@ -3605,7 +3605,7 @@ export class BaseClient { * // Output: [ "zSet1", { three: 3, two: 2 } ] - "three" with score 3 and "two" with score 2 were popped from "zSet1". * ``` */ - public bzmpop( + public async bzmpop( keys: string[], modifier: ScoreFilter, timeout: number, diff --git a/node/src/Transaction.ts b/node/src/Transaction.ts index 9bc4aa1516..9a754a71c3 100644 --- a/node/src/Transaction.ts +++ b/node/src/Transaction.ts @@ -2086,7 +2086,7 @@ export class BaseTransaction> { * @param keys - The keys of the sorted sets. * @param modifier - The element pop criteria - either {@link ScoreFilter.MIN} or * {@link ScoreFilter.MAX} to pop the member with the lowest/highest score accordingly. - * @param count - The number of elements to pop. + * @param count - (Optional) The number of elements to pop. If not supplied, only one element will be popped. * * Command Response - A two-element `array` containing the key name of the set from which the * element was popped, and a member-score `Record` of the popped element. @@ -2102,15 +2102,17 @@ export class BaseTransaction> { * Pops a member-score pair from the first non-empty sorted set, with the given `keys` being * checked in the order they are provided. Blocks the connection when there are no members * to pop from any of the given sorted sets. `BZMPOP` is the blocking variant of `ZMPOP`. + * `BZMPOP` is a client blocking command, see {@link https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands | the wiki} + * for more details and best practices. * * See https://valkey.io/commands/bzmpop/ for more details. * * @param keys - The keys of the sorted sets. * @param modifier - The element pop criteria - either {@link ScoreFilter.MIN} or * {@link ScoreFilter.MAX} to pop the member with the lowest/highest score accordingly. - * @param count - The number of elements to pop. * @param timeout - The number of seconds to wait for a blocking operation to complete. * A value of 0 will block indefinitely. + * @param count - (Optional) The number of elements to pop. If not supplied, only one element will be popped. * * Command Response - A two-element `array` containing the key name of the set from which the element * was popped, and a member-score `Record` of the popped element. diff --git a/node/tests/SharedTests.ts b/node/tests/SharedTests.ts index f038f439d2..527b155614 100644 --- a/node/tests/SharedTests.ts +++ b/node/tests/SharedTests.ts @@ -4788,6 +4788,11 @@ export function runBaseTests(config: { client.bzmpop([key1], ScoreFilter.MAX, 0.1, 0), ).rejects.toThrow(RequestError); + // incorrect argument: timeout can not be a negative number + await expect( + client.bzmpop([key1], ScoreFilter.MAX, -1, 10), + ).rejects.toThrow(RequestError); + // check that order of entries in the response is preserved const entries: Record = {};