INNER CODE UNIT · TypeScript
filtered
akirarika/milkio · packages/cookbook/src/index.ts:164
const filtered = commands.filter((command) => containsCharsInOrder(input.toLowerCase(), command.name.toLowerCase()));
return uniqWith(filtered, (a, b) => a.value === b.value).sort((a, b) => {
const scoreA = calculateScore(input, a.name);
const scoreB = calculateScore(input, b.name);
if (scoreB.maxContiguous !== scoreA.maxContiguous) {
return scoreB.maxContiguous - scoreA.maxContiguous;
}
return scoreA.firstMatchIndex - scoreB.firstMatchIndex;
});
},
},
{ signal: controller.signal },
);
} catch (err: any) {
clearTimeout(timeoutId);