Skip to content

Commit

Permalink
Support type of material checks, such as isBK(), isCF()...
Browse files Browse the repository at this point in the history
  • Loading branch information
nvolk committed Jan 9, 2024
1 parent 03e3a01 commit a43ae73
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,83 @@ export class MarcRecord {
return this.getFields(tag, query).length > 0;
}

getTypeOfRecord() {
return this.leader[6];
}

getBibliograpicLevel() {
return this.leader[7];
}

isBK() {
return ['a', 't'].includes(this.getTypeOfRecord()) && !this._bibliographicLevelIsBis();
}

isCF() {
if (this.getTypeOfRecord() !== 'm') {
return false;
}
if (!this._bibliographicLevelIsBis()) {
return true;
}

return this._containsField006FormOfMaterialS();
}

isCR() {
return ['a', 't'].includes(this.getTypeOfRecord()) && this._bibliographicLevelIsBis();
}

isMP() {
if (!['e', 'f'].includes(this.getTypeOfRecord())) {
return false;
}
if (!this._bibliographicLevelIsBis()) {
return true;
}
return this._containsField006FormOfMaterialS();
}

isMU() {
if (!['c', 'd', 'i', 'j'].includes(this.getTypeOfRecord())) {
return false;
}
if (!this._bibliographicLevelIsBis()) {
return true;
}
return this._containsField006FormOfMaterialS();
}

isMX() {
if (this.getTypeOfRecord() !== 'p') {
return false;
}
if (!this._bibliographicLevelIsBis(this)) {
return true;
}
return this._containsField006FormOfMaterialS();
}

isVM() {
if (!['g', 'k', 'o', 'r'].includes(this.getTypeOfRecord())) {
return false;
}

if (!this._bibliographicLevelIsBis()) {
return true;
}
return this._containsField006FormOfMaterialS();
}

_bibliographicLevelIsBis() {
return ['b', 'i', 's'].includes(this.getBibliograpicLevel());
}

_containsField006FormOfMaterialS() {
const fields006 = this.get('006');
return fields006.some(field => field.value[0] === 's');
}

equalsTo(record) {
return MarcRecord.isEqual(this, record);
}
Expand Down

0 comments on commit a43ae73

Please sign in to comment.