Skip to content

Commit

Permalink
Addressed PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
  • Loading branch information
GumpacG committed Jul 17, 2024
1 parent aedf324 commit 9ab309d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions node/src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2850,18 +2850,18 @@ export class BaseClient {
/**
* Returns the index of the first occurrence of `element` inside the list specified by `key`. If no
* match is found, `null` is returned. If the `count` option is specified, then the function returns
* an `array` of indices of matching elements within a list.
* an `array` of indices of matching elements within the list.
*
* See https://valkey.io/commands/lpos/ for more details.
*
* since - Valkey version 6.0.6.
*
* @param key - The name of the list.
* @param element - The value to search for within the list.
* @param options - The LPOS options.
* @returns The index of `element`, or `null` if `element` is not in the list. If the `count` option
* is specified, then the function returns an `array` of indices of matching elements within the list.
*
* since - Valkey version 6.0.6.
*
* @example
* ```typescript
* await client.rpush("myList", ["a", "b", "c", "d", "e", "e"]);
Expand Down
6 changes: 3 additions & 3 deletions node/src/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1687,18 +1687,18 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
/**
* Returns the index of the first occurrence of `element` inside the list specified by `key`. If no
* match is found, `null` is returned. If the `count` option is specified, then the function returns
* an `array` of indices of matching elements within a list.
* an `array` of indices of matching elements within the list.
*
* See https://valkey.io/commands/lpos/ for more details.
*
* since - Valkey version 6.0.6.
*
* @param key - The name of the list.
* @param element - The value to search for within the list.
* @param options - The LPOS options.
*
* Command Response - The index of `element`, or `null` if `element` is not in the list. If the `count`
* option is specified, then the function returns an `array` of indices of matching elements within the list.
*
* since - Valkey version 6.0.6.
*/
public lpos(key: string, element: string, options?: LPosOptions): T {
return this.addAndReturn(createLPos(key, element, options));
Expand Down
1 change: 0 additions & 1 deletion node/src/command-options/LPosOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class LPosOptions {
/** Redis API keyword used to extract specific number of matching indices from a list. */
public static COUNT_REDIS_API = "COUNT";
/** Redis API keyword used to determine the maximum number of list items to compare. */

public static MAXLEN_REDIS_API = "MAXLEN";
/** The rank of the match to return. */
private rank?: number;
Expand Down
33 changes: 17 additions & 16 deletions node/tests/TestUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export async function transactionTest(
const key13 = "{key}" + uuidv4();
const key14 = "{key}" + uuidv4(); // sorted set
const key15 = "{key}" + uuidv4(); // list
const key16 = "{key}" + uuidv4(); // list
const field = uuidv4();
const value = uuidv4();
const args: ReturnType[] = [];
Expand Down Expand Up @@ -396,6 +397,22 @@ export async function transactionTest(
args.push(0);
baseTransaction.lpushx(key15, ["_"]);
args.push(0);
baseTransaction.rpush(key16, [
field + "1",
field + "1",
field + "2",
field + "3",
field + "3",
]);
args.push(5);
baseTransaction.lpos(key16, field + "1", new LPosOptions({ rank: 2 }));
args.push(1);
baseTransaction.lpos(
key16,
field + "1",
new LPosOptions({ rank: 2, count: 0 }),
);
args.push([1]);
baseTransaction.sadd(key7, ["bar", "foo"]);
args.push(2);
baseTransaction.sunionstore(key7, [key7, key7]);
Expand Down Expand Up @@ -537,21 +554,5 @@ export async function transactionTest(
args.push(1);
baseTransaction.pfcount([key11]);
args.push(3);
baseTransaction.rpush(key15, [
field + "1",
field + "1",
field + "2",
field + "3",
field + "3",
]);
args.push(5);
baseTransaction.lpos(key15, field + "1", new LPosOptions({ rank: 2 }));
args.push(1);
baseTransaction.lpos(
key15,
field + "1",
new LPosOptions({ rank: 2, count: 0 }),
);
args.push([1]);
return args;
}

0 comments on commit 9ab309d

Please sign in to comment.