authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 01:20:09-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 01:20:09-07:00
log86f079964b9c3d2a087907d2ef8273c3dbcb960b
tree140b807bc8e462cc440c1753029085d58e6e1178
parentf5d9d12026d98b2b4b975f1944e7503d6c2c9eb3
signature Signed by PGP key B5690EEEBB952194

refactor(shared): keep search ranking comparator private (#10031)


2 files changed, 1 insertions(+), 3 deletions(-)

packages/shared/src/searchRanking.test.ts-2
...@@ -1,7 +1,6 @@...@@ -1,7 +1,6 @@
1import { describe, expect, it } from "vite-plus/test";1import { describe, expect, it } from "vite-plus/test";
22
3import {3import {
4 compareRankedSearchResults,
5 insertRankedSearchResult,4 insertRankedSearchResult,
6 normalizeSearchQuery,5 normalizeSearchQuery,
7 scoreQueryMatch,6 scoreQueryMatch,
...@@ -90,6 +89,5 @@ describe("insertRankedSearchResult", () => {...@@ -90,6 +89,5 @@ describe("insertRankedSearchResult", () => {
90 insertRankedSearchResult(ranked, { item: "c", score: 30, tieBreaker: "c" }, 2);89 insertRankedSearchResult(ranked, { item: "c", score: 30, tieBreaker: "c" }, 2);
9190
92 expect(ranked.map((entry) => entry.item)).toEqual(["a", "b"]);91 expect(ranked.map((entry) => entry.item)).toEqual(["a", "b"]);
93 expect(compareRankedSearchResults(ranked[0]!, ranked[1]!)).toBeLessThan(0);
94 });92 });
95});93});
packages/shared/src/searchRanking.ts+1-1
...@@ -135,7 +135,7 @@ export function scoreQueryMatch(input: {...@@ -135,7 +135,7 @@ export function scoreQueryMatch(input: {
135 return null;135 return null;
136}136}
137137
138export function compareRankedSearchResults<T>(138function compareRankedSearchResults<T>(
139 left: RankedSearchResult<T>,139 left: RankedSearchResult<T>,
140 right: RankedSearchResult<T>,140 right: RankedSearchResult<T>,
141): number {141): number {