Skip to content

Commit 1f2aa15

Browse files
authored
Merge pull request #81 from NatLibFi/next
Simplify type of record rules
2 parents 98a6160 + 8dcf37e commit 1f2aa15

File tree

9 files changed

+992
-927
lines changed

9 files changed

+992
-927
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,6 @@ To serialize and unserialize MARC records, see [marc-record-serializers](https:/
345345
346346
Copyright (c) 2014-2017 **Pasi Tuominen <[email protected]>**
347347
348-
Copyright (c) 2018-2023 **University Of Helsinki (The National Library Of Finland)**
348+
Copyright (c) 2018-2024 **University Of Helsinki (The National Library Of Finland)**
349349
350350
This project's source code is licensed under the terms of **MIT License** or any later version.

package-lock.json

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

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"url": "[email protected]:natlibfi/marc-record-js.git"
2626
},
2727
"license": "MIT",
28-
"version": "8.1.0",
28+
"version": "8.1.1-alpha.1",
2929
"main": "./dist/index.js",
3030
"engines": {
3131
"node": ">=14"
@@ -51,21 +51,21 @@
5151
"jsonschema": "^1.4.1"
5252
},
5353
"devDependencies": {
54-
"@babel/cli": "^7.23.0",
55-
"@babel/core": "^7.23.7",
56-
"@babel/node": "^7.22.19",
57-
"@babel/plugin-transform-runtime": "^7.23.7",
58-
"@babel/preset-env": "^7.23.8",
54+
"@babel/cli": "^7.24.1",
55+
"@babel/core": "^7.24.4",
56+
"@babel/node": "^7.23.9",
57+
"@babel/plugin-transform-runtime": "^7.24.3",
58+
"@babel/preset-env": "^7.24.4",
5959
"@babel/register": "^7.23.7",
60-
"@natlibfi/eslint-config-melinda-backend": "^3.0.2",
60+
"@natlibfi/eslint-config-melinda-backend": "^3.0.4",
6161
"@natlibfi/fixugen": "^2.0.4",
6262
"@natlibfi/fixura": "^3.0.4",
6363
"babel-plugin-istanbul": "^6.1.1",
64-
"chai": "^4.4.0",
64+
"chai": "^4.4.1",
6565
"cross-env": "^7.0.3",
66-
"eslint": "^8.56.0",
67-
"mocha": "^10.2.0",
68-
"nodemon": "^3.0.1",
66+
"eslint": "^8.57.0",
67+
"mocha": "^10.4.0",
68+
"nodemon": "^3.1.0",
6969
"nyc": "^15.1.0"
7070
},
7171
"eslintConfig": {

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)