Skip to content

Commit 47bfe6e

Browse files
authored
Merge pull request #78 from NatLibFi/simplifyTypeOfMaterialRules
Simplify type of material rules
2 parents 98a6160 + 11eaa75 commit 47bfe6e

File tree

7 files changed

+968
-903
lines changed

7 files changed

+968
-903
lines changed

package-lock.json

+961-790
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

+5-42
Original file line numberDiff line numberDiff line change
@@ -213,59 +213,27 @@ export class MarcRecord {
213213
}
214214

215215
isCF() {
216-
if (this.getTypeOfRecord() !== 'm') {
217-
return false;
218-
}
219-
if (!this._bibliographicLevelIsBis()) {
220-
return true;
221-
}
222-
223-
return this._containsField006FormOfMaterialS();
216+
return this.getTypeOfRecord() === 'm';
224217
}
225218

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

230223
isMP() {
231-
if (!['e', 'f'].includes(this.getTypeOfRecord())) {
232-
return false;
233-
}
234-
if (!this._bibliographicLevelIsBis()) {
235-
return true;
236-
}
237-
return this._containsField006FormOfMaterialS();
224+
return ['e', 'f'].includes(this.getTypeOfRecord());
238225
}
239226

240227
isMU() {
241-
if (!['c', 'd', 'i', 'j'].includes(this.getTypeOfRecord())) {
242-
return false;
243-
}
244-
if (!this._bibliographicLevelIsBis()) {
245-
return true;
246-
}
247-
return this._containsField006FormOfMaterialS();
228+
return ['c', 'd', 'i', 'j'].includes(this.getTypeOfRecord());
248229
}
249230

250231
isMX() {
251-
if (this.getTypeOfRecord() !== 'p') {
252-
return false;
253-
}
254-
if (!this._bibliographicLevelIsBis(this)) {
255-
return true;
256-
}
257-
return this._containsField006FormOfMaterialS();
232+
return this.getTypeOfRecord() === 'p';
258233
}
259234

260235
isVM() {
261-
if (!['g', 'k', 'o', 'r'].includes(this.getTypeOfRecord())) {
262-
return false;
263-
}
264-
265-
if (!this._bibliographicLevelIsBis()) {
266-
return true;
267-
}
268-
return this._containsField006FormOfMaterialS();
236+
return ['g', 'k', 'o', 'r'].includes(this.getTypeOfRecord());
269237
}
270238

271239
getTypeOfMaterial() {
@@ -297,11 +265,6 @@ export class MarcRecord {
297265
return ['b', 'i', 's'].includes(this.getBibliograpicLevel());
298266
}
299267

300-
_containsField006FormOfMaterialS() {
301-
const fields006 = this.get('006');
302-
return fields006.some(field => field.value[0] === 's');
303-
}
304-
305268
equalsTo(record) {
306269
return MarcRecord.isEqual(this, record);
307270
}

test-fixtures/index/getTypeOfMaterial/02/metadata.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"description": "fail to determine the type of material (LDR/07+006/00 combo)",
2+
"description": "fail to determine the type of material (Illegal LDR/06)",
33
"skip": false,
44
"input": {
5-
"leader": "01234cki a22005894i 4500",
5+
"leader": "01234cbi a22005894i 4500",
66
"fields":
77
[
88
{"tag": "001", "value": "bar"},

test-fixtures/index/isMP/02/metadata.json

-17
This file was deleted.

test-fixtures/index/isMU/02/metadata.json

-17
This file was deleted.

test-fixtures/index/isMX/02/metadata.json

-17
This file was deleted.

test-fixtures/index/isVM/02/metadata.json

-18
This file was deleted.

0 commit comments

Comments
 (0)