You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
use dockers for tests, use npm workspaces, add rejson & redisearch modules, fix some bugs
This commit is contained in:
29
packages/search/lib/commands/SUGGET_WITHSCORES.ts
Normal file
29
packages/search/lib/commands/SUGGET_WITHSCORES.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { SugGetOptions, transformArguments as transformSugGetArguments } from './SUGGET';
|
||||
|
||||
export { IS_READ_ONLY } from './SUGGET';
|
||||
|
||||
export function transformArguments(key: string, prefix: string, options?: SugGetOptions): Array<string> {
|
||||
return [
|
||||
...transformSugGetArguments(key, prefix, options),
|
||||
'WITHSCORES'
|
||||
];
|
||||
}
|
||||
|
||||
export interface SuggestionWithScores {
|
||||
suggestion: string;
|
||||
score: number;
|
||||
}
|
||||
|
||||
export function transformReply(rawReply: Array<string> | null): Array<SuggestionWithScores> | null {
|
||||
if (rawReply === null) return null;
|
||||
|
||||
const transformedReply = [];
|
||||
for (let i = 0; i < rawReply.length; i += 2) {
|
||||
transformedReply.push({
|
||||
suggestion: rawReply[i],
|
||||
score: Number(rawReply[i + 1])
|
||||
});
|
||||
}
|
||||
|
||||
return transformedReply;
|
||||
}
|
Reference in New Issue
Block a user