| 193 | } |
| 194 | |
| 195 | export function _deduplicateInOrder(hashedDocuments: HashedDocumentInterface[]): HashedDocumentInterface[] { |
| 196 | const seen = new Set<string>() |
| 197 | const deduplicated: HashedDocumentInterface[] = [] |
| 198 | |
| 199 | for (const hashedDoc of hashedDocuments) { |
| 200 | if (!hashedDoc.hash_) { |
| 201 | throw new Error('Hashed document does not have a hash') |
| 202 | } |
| 203 | |
| 204 | if (!seen.has(hashedDoc.hash_)) { |
| 205 | seen.add(hashedDoc.hash_) |
| 206 | deduplicated.push(hashedDoc) |
| 207 | } |
| 208 | } |
| 209 | return deduplicated |
| 210 | } |
| 211 | |
| 212 | export function _getSourceIdAssigner(sourceIdKey: StringOrDocFunc | null): (doc: DocumentInterface) => string | null { |
| 213 | if (sourceIdKey === null) { |