You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
30 lines
816 B
TypeScript
30 lines
816 B
TypeScript
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;
|
|
}
|