Skip to content

Commit

Permalink
Node: add missing asyncs and exports (#2184)
Browse files Browse the repository at this point in the history
Fixes.

Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand authored Aug 22, 2024
1 parent 29a6920 commit 20f8868
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
16 changes: 14 additions & 2 deletions node/npm/glide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function loadNativeBinding() {
function initialize() {
const nativeBinding = loadNativeBinding();
const {
AggregationType,
BaseScanOptions,
BitEncoding,
BitFieldGet,
Expand All @@ -98,6 +99,7 @@ function initialize() {
GeoCircleShape,
GeoSearchShape,
GeoSearchResultOptions,
GeoSearchStoreResultOptions,
SortOrder,
GeoUnit,
GeospatialData,
Expand All @@ -120,15 +122,18 @@ function initialize() {
PeriodicChecksManualInterval,
PeriodicChecks,
Logger,
Limit,
LolwutOptions,
LPosOptions,
ListDirection,
ExpireOptions,
FlushMode,
InfoOptions,
InsertPosition,
SetOptions,
ZaddOptions,
ZAddOptions,
InfBoundary,
KeyWeight,
Boundary,
UpdateOptions,
ProtocolVersion,
Expand Down Expand Up @@ -164,6 +169,7 @@ function initialize() {
ScoreFilter,
SignedEncoding,
UnsignedEncoding,
UpdateByScore,
createLeakedArray,
createLeakedAttribute,
createLeakedBigint,
Expand All @@ -174,6 +180,7 @@ function initialize() {
} = nativeBinding;

module.exports = {
AggregationType,
BaseScanOptions,
BitEncoding,
BitFieldGet,
Expand All @@ -198,6 +205,7 @@ function initialize() {
GeoCircleShape,
GeoSearchShape,
GeoSearchResultOptions,
GeoSearchStoreResultOptions,
SortOrder,
GeoUnit,
GeospatialData,
Expand All @@ -221,15 +229,18 @@ function initialize() {
PeriodicChecksManualInterval,
PeriodicChecks,
Logger,
LolwutOptions,
Limit,
LPosOptions,
ListDirection,
ExpireOptions,
FlushMode,
InfoOptions,
InsertPosition,
SetOptions,
ZaddOptions,
ZAddOptions,
InfBoundary,
KeyWeight,
Boundary,
UpdateOptions,
ProtocolVersion,
Expand Down Expand Up @@ -263,6 +274,7 @@ function initialize() {
ScoreFilter,
SignedEncoding,
UnsignedEncoding,
UpdateByScore,
createLeakedArray,
createLeakedAttribute,
createLeakedBigint,
Expand Down
14 changes: 7 additions & 7 deletions node/src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ import {
createXGroupCreateConsumer,
createXGroupDelConsumer,
createXGroupDestroy,
createXGroupSetid,
createXInfoConsumers,
createXInfoGroups,
createXInfoStream,
Expand Down Expand Up @@ -220,7 +221,6 @@ import {
createZScore,
createZUnion,
createZUnionStore,
createXGroupSetid,
} from "./Commands";
import {
ClosingError,
Expand Down Expand Up @@ -1650,7 +1650,7 @@ export class BaseClient {
* console.log(result); // Output: ["field1", "field2", "field3"] - Returns all the field names stored in the hash "my_hash".
* ```
*/
public hkeys(key: string): Promise<string[]> {
public async hkeys(key: string): Promise<string[]> {
return this.createWritePromise(createHKeys(key));
}

Expand Down Expand Up @@ -3913,7 +3913,7 @@ export class BaseClient {
* console.log(result); // Output: ['member1']
* ```
*/
public zinter(keys: string[]): Promise<string[]> {
public async zinter(keys: string[]): Promise<string[]> {
return this.createWritePromise(createZInter(keys));
}

Expand Down Expand Up @@ -3945,7 +3945,7 @@ export class BaseClient {
* console.log(result2); // Output: {'member1': 10.5} - "member1" with score of 10.5 is the result.
* ```
*/
public zinterWithScores(
public async zinterWithScores(
keys: string[] | KeyWeight[],
aggregationType?: AggregationType,
): Promise<Record<string, number>> {
Expand Down Expand Up @@ -3977,7 +3977,7 @@ export class BaseClient {
* console.log(result); // Output: ['member1', 'member2']
* ```
*/
public zunion(keys: string[]): Promise<string[]> {
public async zunion(keys: string[]): Promise<string[]> {
return this.createWritePromise(createZUnion(keys));
}

Expand Down Expand Up @@ -4008,7 +4008,7 @@ export class BaseClient {
* console.log(result2); // {'member1': 10.5, 'member2': 8.2}
* ```
*/
public zunionWithScores(
public async zunionWithScores(
keys: string[] | KeyWeight[],
aggregationType?: AggregationType,
): Promise<Record<string, number>> {
Expand Down Expand Up @@ -4668,7 +4668,7 @@ export class BaseClient {
* // }
* ```
*/
public xreadgroup(
public async xreadgroup(
group: string,
consumer: string,
keys_and_ids: Record<string, string>,
Expand Down
21 changes: 17 additions & 4 deletions node/src/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,7 @@ export function createZLexCount(
return createCommand(RequestType.ZLexCount, args);
}

/** @internal */
export function createZRank(
key: string,
member: string,
Expand Down Expand Up @@ -3356,13 +3357,25 @@ function convertGeoSearchOptionsToArgs(
}

if (resultOptions) {
if ("withCoord" in resultOptions && resultOptions.withCoord)
if (
"withCoord" in resultOptions &&
(resultOptions as GeoSearchResultOptions).withCoord
)
args.push("WITHCOORD");
if ("withDist" in resultOptions && resultOptions.withDist)
if (
"withDist" in resultOptions &&
(resultOptions as GeoSearchResultOptions).withDist
)
args.push("WITHDIST");
if ("withHash" in resultOptions && resultOptions.withHash)
if (
"withHash" in resultOptions &&
(resultOptions as GeoSearchResultOptions).withHash
)
args.push("WITHHASH");
if ("storeDist" in resultOptions && resultOptions.storeDist)
if (
"storeDist" in resultOptions &&
(resultOptions as GeoSearchStoreResultOptions).storeDist
)
args.push("STOREDIST");

if (resultOptions.count) {
Expand Down

0 comments on commit 20f8868

Please sign in to comment.