MCPcopy
hub / github.com/codedogQBY/ReadAny / createImportDuplicateIndex

Function createImportDuplicateIndex

packages/core/src/import/import-dedupe.ts:50–67  ·  view source on GitHub ↗
(books: Book[])

Source from the content-addressed store, hash-verified

48}
49
50export function createImportDuplicateIndex(books: Book[]): ImportDuplicateIndex {
51 const byHash = new Map<string, Book>();
52 const byName = new Map<string, Book>();
53
54 for (const book of books) {
55 if (book.fileHash) {
56 byHash.set(book.fileHash, book);
57 }
58
59 for (const candidate of buildBookNameCandidates(book)) {
60 if (!byName.has(candidate)) {
61 byName.set(candidate, book);
62 }
63 }
64 }
65
66 return { byHash, byName };
67}
68
69export function findDuplicateBookByHash(
70 index: ImportDuplicateIndex,

Callers 5

library-store.tsFile · 0.90
library-store.tsFile · 0.90

Calls 1

buildBookNameCandidatesFunction · 0.85

Tested by

no test coverage detected