UNPKG

@natlibfi/melinda-record-match-validator

Version:

Validates if two records matched by melinda-record-matching can be merged and sets merge priority

31 lines (30 loc) 796 B
function getPublisherFields(record) { return record.fields.filter((field) => isPublisherField(field)); function isPublisherField(field) { if (field.tag === "260") { return true; } return field.tag === "264" && field.ind2 === "1"; } } export function checkPublisher({ record1, record2 }) { const score1 = publisherScore(getPublisherFields(record1)); const score2 = publisherScore(getPublisherFields(record2)); if (score1 > score2) { return "A"; } if (score2 > score1) { return "B"; } return true; function publisherScore(fields) { if (fields.some((field) => field.tag === "264")) { return 2; } if (fields.some((field) => field.tag === "260")) { return 0; } return 0; } } //# sourceMappingURL=compareField26X.js.map