(books: Book[])
| 48 | } |
| 49 | |
| 50 | export 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 | |
| 69 | export function findDuplicateBookByHash( |
| 70 | index: ImportDuplicateIndex, |
no test coverage detected