Skip to content

Commit

Permalink
Signed-off-by: Yury-Fridlyand <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
Yury-Fridlyand committed Sep 12, 2024
1 parent da46464 commit a6a95bc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 47 deletions.
13 changes: 4 additions & 9 deletions node/src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1754,11 +1754,6 @@ export class BaseClient {
* The offset can also be a negative number indicating an offset starting at the end of the list, with `-1` being
* the last byte of the list, `-2` being the penultimate, and so on.
*
* If you are using Valkey 7.0.0 or above, the optional `indexType` can also be provided to specify whether the
* `start` and `end` offsets specify BIT or BYTE offsets. If `indexType` is not provided, BYTE offsets
* are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is
* specified, `start=0` and `end=2` means to look at the first three bytes.
*
* @see {@link https://valkey.io/commands/bitpos/|valkey.io} for details.
*
* @param key - The key of the string.
Expand All @@ -1774,14 +1769,14 @@ export class BaseClient {
* const result1 = await client.bitpos("key1", 1);
* console.log(result1); // Output: 1 - The first occurrence of bit value 1 in the string stored at "key1" is at the second position.
*
* const result2 = await client.bitpos("key1", 1, -1);
* const result2 = await client.bitpos("key1", 1, { start: -1 });
* console.log(result2); // Output: 10 - The first occurrence of bit value 1, starting at the last byte in the string stored at "key1", is at the eleventh position.
*
* await client.set("key1", "A12"); // "A12" has binary value 01000001 00110001 00110010
* const result3 = await client.bitpos("key1", 1, {start: 1, end: -1});
* const result3 = await client.bitpos("key1", 1, { start: 1, end: -1 });
* console.log(result3); // Output: 10 - The first occurrence of bit value 1 in the second byte to the last byte of the string stored at "key1" is at the eleventh position.
*
* const result4 = await client.bitpos("key1", 1, {start: 2, end: 9, indexType: BitmapIndexType.BIT});
* const result4 = await client.bitpos("key1", 1, { start: 2, end: 9, indexType: BitmapIndexType.BIT });
* console.log(result4); // Output: 7 - The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1" is at the eighth position.
* ```
*/
Expand Down Expand Up @@ -6400,7 +6395,7 @@ export class BaseClient {
* @see {@link https://valkey.io/commands/bitcount/|valkey.io} for more details.
*
* @param key - The key for the string to count the set bits of.
* @param options - The offset options.
* @param options - The offset options - see {@link BitOffsetOptions}.
* @returns If `options` is provided, returns the number of set bits in the string interval specified by `options`.
* If `options` is not provided, returns the number of set bits in the string stored at `key`.
* Otherwise, if `key` is missing, returns `0` as it is treated as an empty string.
Expand Down
73 changes: 41 additions & 32 deletions node/src/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ export interface SetOptions {
* `KEEPTTL` in the Valkey API.
*/
| "keepExisting"
| {
type: TimeUnit;
count: number;
};
| {
type: TimeUnit;
count: number;
};
}

/**
Expand Down Expand Up @@ -1436,7 +1436,7 @@ export function createZAdd(
if (options.conditionalChange) {
if (
options.conditionalChange ===
ConditionalChange.ONLY_IF_DOES_NOT_EXIST &&
ConditionalChange.ONLY_IF_DOES_NOT_EXIST &&
options.updateOptions
) {
throw new Error(
Expand Down Expand Up @@ -1699,15 +1699,15 @@ export type Boundary<T> =
* Represents a specific boundary.
*/
| {
/**
* The comparison value.
*/
value: T;
/**
* Whether the value is inclusive. Defaults to `true`.
*/
isInclusive?: boolean;
};
/**
* The comparison value.
*/
value: T;
/**
* Whether the value is inclusive. Defaults to `true`.
*/
isInclusive?: boolean;
};

/**
* Represents a range by index (rank) in a sorted set.
Expand Down Expand Up @@ -2074,21 +2074,21 @@ export function createZRank(

export type StreamTrimOptions = (
| {
/**
* Trim the stream according to entry ID.
* Equivalent to `MINID` in the Valkey API.
*/
method: "minid";
threshold: GlideString;
}
/**
* Trim the stream according to entry ID.
* Equivalent to `MINID` in the Valkey API.
*/
method: "minid";
threshold: GlideString;
}
| {
/**
* Trim the stream according to length.
* Equivalent to `MAXLEN` in the Valkey API.
*/
method: "maxlen";
threshold: number;
}
/**
* Trim the stream according to length.
* Equivalent to `MAXLEN` in the Valkey API.
*/
method: "maxlen";
threshold: number;
}
) & {
/**
* If `true`, the stream will be trimmed exactly. Equivalent to `=` in the
Expand Down Expand Up @@ -2475,12 +2475,17 @@ export function createFunctionRestore(
}

/**
* Represents offsets specifying a string interval to analyze in the {@link BaseClient.bitcount|bitcount and @link BaseClient.bitpos} command. The offsets are
* zero-based indexes, with `0` being the first index of the string, `1` being the next index and so on.
* Represents offsets specifying a string interval to analyze in the {@link BaseClient.bitcount | bitcount} and {@link BaseClient.bitpos | bitpos} commands.
* The offsets are zero-based indexes, with `0` being the first index of the string, `1` being the next index and so on.
* The offsets can also be negative numbers indicating offsets starting at the end of the string, with `-1` being
* the last index of the string, `-2` being the penultimate, and so on.
*
* See https://valkey.io/commands/bitcount/ for more details.
* If you are using Valkey 7.0.0 or above, the optional `indexType` can also be provided to specify whether the
* `start` and `end` offsets specify `BIT` or `BYTE` offsets. If `indexType` is not provided, `BYTE` offsets
* are assumed. If `BIT` is specified, `start=0` and `end=2` means to look at the first three bits. If `BYTE` is
* specified, `start=0` and `end=2` means to look at the first three bytes.
*
* @see {@link https://valkey.io/commands/bitcount/ | bitcount} and {@link https://valkey.io/commands/bitpos/ | bitpos} for more details.
*/
export interface BitOffsetOptions {
/** The starting offset index. */
Expand Down Expand Up @@ -2553,7 +2558,11 @@ export function createBitPos(
bit: number,
options?: BitOffsetOptions,
): command_request.Command {
const args: GlideString[] = [key, bit.toString(), ...convertBitOptionsToArgs(options)];
const args: GlideString[] = [
key,
bit.toString(),
...convertBitOptionsToArgs(options),
];

return createCommand(RequestType.BitPos, args);
}
Expand Down
7 changes: 1 addition & 6 deletions node/src/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,6 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
* The offset can also be a negative number indicating an offset starting at the end of the list, with `-1` being
* the last byte of the list, `-2` being the penultimate, and so on.
*
* If you are using Valkey 7.0.0 or above, the optional `indexType` can also be provided to specify whether the
* `start` and `end` offsets specify BIT or BYTE offsets. If `indexType` is not provided, BYTE offsets
* are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is
* specified, `start=0` and `end=2` means to look at the first three bytes.
*
* @see {@link https://valkey.io/commands/bitpos/|valkey.io} for details.
*
* @param key - The key of the string.
Expand Down Expand Up @@ -3459,7 +3454,7 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
* @see {@link https://valkey.io/commands/bitcount/|valkey.io} for more details.
*
* @param key - The key for the string to count the set bits of.
* @param options - The offset options.
* @param options - The offset options - see {@link BitOffsetOptions}.
*
* Command Response - If `options` is provided, returns the number of set bits in the string interval specified by `options`.
* If `options` is not provided, returns the number of set bits in the string stored at `key`.
Expand Down

0 comments on commit a6a95bc

Please sign in to comment.