@natlibfi/marc-record-validators-melinda 11.6.6 → 11.6.7-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/melinda-node-tests.yml +1 -1
- package/dist/access-rights.js +1 -5
- package/dist/access-rights.js.map +1 -1
- package/dist/addMissingField336.js +1 -1
- package/dist/addMissingField336.js.map +1 -1
- package/dist/cyrillux-usemarcon-replacement.js +41 -45
- package/dist/cyrillux-usemarcon-replacement.js.map +1 -1
- package/dist/cyrillux.js +13 -17
- package/dist/cyrillux.js.map +1 -1
- package/dist/disambiguateSeriesStatements.js +3 -4
- package/dist/disambiguateSeriesStatements.js.map +1 -1
- package/dist/double-commas.js +2 -1
- package/dist/double-commas.js.map +1 -1
- package/dist/duplicates-ind1.js +1 -1
- package/dist/duplicates-ind1.js.map +1 -1
- package/dist/empty-fields.js +0 -4
- package/dist/empty-fields.js.map +1 -1
- package/dist/ending-punctuation.js +21 -49
- package/dist/ending-punctuation.js.map +1 -1
- package/dist/ending-whitespace.js +0 -4
- package/dist/ending-whitespace.js.map +1 -1
- package/dist/field-008-18-34-character-groups.js +4 -5
- package/dist/field-008-18-34-character-groups.js.map +1 -1
- package/dist/field-505-separators.js +8 -6
- package/dist/field-505-separators.js.map +1 -1
- package/dist/field-521-fix.js +5 -6
- package/dist/field-521-fix.js.map +1 -1
- package/dist/field-exclusion.js +5 -12
- package/dist/field-exclusion.js.map +1 -1
- package/dist/field-exclusion.spec.js +3 -5
- package/dist/field-exclusion.spec.js.map +1 -1
- package/dist/field-structure.js +2 -5
- package/dist/field-structure.js.map +1 -1
- package/dist/fields-present.js +1 -1
- package/dist/fields-present.js.map +1 -1
- package/dist/fields-present.spec.js +1 -1
- package/dist/fields-present.spec.js.map +1 -1
- package/dist/fix-33X.js +5 -6
- package/dist/fix-33X.js.map +1 -1
- package/dist/fix-country-codes.js +3 -4
- package/dist/fix-country-codes.js.map +1 -1
- package/dist/fix-language-codes.js +12 -9
- package/dist/fix-language-codes.js.map +1 -1
- package/dist/fixRelatorTerms.js +8 -8
- package/dist/fixRelatorTerms.js.map +1 -1
- package/dist/fixed-fields.js +1 -4
- package/dist/fixed-fields.js.map +1 -1
- package/dist/identical-fields.js +2 -3
- package/dist/identical-fields.js.map +1 -1
- package/dist/indicator-fixes.js +14 -15
- package/dist/indicator-fixes.js.map +1 -1
- package/dist/isbn-issn.js +8 -11
- package/dist/isbn-issn.js.map +1 -1
- package/dist/item-language.js +5 -12
- package/dist/item-language.js.map +1 -1
- package/dist/merge-fields/counterpartField.js +6 -8
- package/dist/merge-fields/counterpartField.js.map +1 -1
- package/dist/merge-fields/index.js +3 -3
- package/dist/merge-fields/index.js.map +1 -1
- package/dist/merge-fields/mergeConstraints.js +0 -1
- package/dist/merge-fields/mergeConstraints.js.map +1 -1
- package/dist/merge-fields/mergeField.js +12 -18
- package/dist/merge-fields/mergeField.js.map +1 -1
- package/dist/merge-fields/mergeIndicator.js +5 -5
- package/dist/merge-fields/mergeIndicator.js.map +1 -1
- package/dist/merge-fields/mergeOrAddPostprocess.js +6 -9
- package/dist/merge-fields/mergeOrAddPostprocess.js.map +1 -1
- package/dist/merge-fields/mergeOrAddSubfield.js +6 -8
- package/dist/merge-fields/mergeOrAddSubfield.js.map +1 -1
- package/dist/merge-fields/mergeSubfield.js +8 -8
- package/dist/merge-fields/mergeSubfield.js.map +1 -1
- package/dist/merge-fields/removeDuplicateSubfields.js +1 -2
- package/dist/merge-fields/removeDuplicateSubfields.js.map +1 -1
- package/dist/merge-fields/worldKnowledge.js +1 -1
- package/dist/merge-fields/worldKnowledge.js.map +1 -1
- package/dist/mergeField500Lisapainokset.js +0 -3
- package/dist/mergeField500Lisapainokset.js.map +1 -1
- package/dist/mergeRelatorTermFields.js +3 -3
- package/dist/mergeRelatorTermFields.js.map +1 -1
- package/dist/modernize-502.js +6 -6
- package/dist/modernize-502.js.map +1 -1
- package/dist/multiple-subfield-0.js +4 -4
- package/dist/multiple-subfield-0.js.map +1 -1
- package/dist/non-breaking-space.js +0 -4
- package/dist/non-breaking-space.js.map +1 -1
- package/dist/normalize-dashes.js +5 -4
- package/dist/normalize-dashes.js.map +1 -1
- package/dist/normalize-identifiers.js +6 -6
- package/dist/normalize-identifiers.js.map +1 -1
- package/dist/normalize-qualifying-information.js +4 -4
- package/dist/normalize-qualifying-information.js.map +1 -1
- package/dist/normalize-utf8-diacritics.js +7 -7
- package/dist/normalize-utf8-diacritics.js.map +1 -1
- package/dist/normalizeFieldForComparison.js +21 -20
- package/dist/normalizeFieldForComparison.js.map +1 -1
- package/dist/normalizeSubfieldValueForComparison.js +1 -2
- package/dist/normalizeSubfieldValueForComparison.js.map +1 -1
- package/dist/prepublicationUtils.js +3 -3
- package/dist/prepublicationUtils.js.map +1 -1
- package/dist/punctuation/index.js +14 -31
- package/dist/punctuation/index.js.map +1 -1
- package/dist/punctuation2.js +9 -10
- package/dist/punctuation2.js.map +1 -1
- package/dist/reindexSubfield6OccurenceNumbers.js +8 -9
- package/dist/reindexSubfield6OccurenceNumbers.js.map +1 -1
- package/dist/removeDuplicateDataFields.js +18 -20
- package/dist/removeDuplicateDataFields.js.map +1 -1
- package/dist/removeInferiorDataFields.js +16 -19
- package/dist/removeInferiorDataFields.js.map +1 -1
- package/dist/resolvable-ext-references-melinda.js +4 -8
- package/dist/resolvable-ext-references-melinda.js.map +1 -1
- package/dist/resolveOrphanedSubfield6s.js +9 -9
- package/dist/resolveOrphanedSubfield6s.js.map +1 -1
- package/dist/sanitize-vocabulary-source-codes.js +9 -9
- package/dist/sanitize-vocabulary-source-codes.js.map +1 -1
- package/dist/sort-tags.js +2 -2
- package/dist/sort-tags.js.map +1 -1
- package/dist/sortFields.js +4 -9
- package/dist/sortFields.js.map +1 -1
- package/dist/sortRelatorTerms.js +4 -5
- package/dist/sortRelatorTerms.js.map +1 -1
- package/dist/sortSubfields.js +5 -6
- package/dist/sortSubfields.js.map +1 -1
- package/dist/stripPunctuation.js +2 -2
- package/dist/stripPunctuation.js.map +1 -1
- package/dist/subfield-exclusion.js +4 -11
- package/dist/subfield-exclusion.js.map +1 -1
- package/dist/subfield6Utils.js +12 -11
- package/dist/subfield6Utils.js.map +1 -1
- package/dist/subfield8Utils.js +8 -9
- package/dist/subfield8Utils.js.map +1 -1
- package/dist/subfieldValueNormalizations.js +5 -8
- package/dist/subfieldValueNormalizations.js.map +1 -1
- package/dist/sync-007-and-300.js +8 -8
- package/dist/sync-007-and-300.js.map +1 -1
- package/dist/translate-terms.js +5 -6
- package/dist/translate-terms.js.map +1 -1
- package/dist/typeOfDate-008.js +3 -4
- package/dist/typeOfDate-008.js.map +1 -1
- package/dist/unicode-decomposition.js +1 -1
- package/dist/unicode-decomposition.js.map +1 -1
- package/dist/update-field-540.js +5 -6
- package/dist/update-field-540.js.map +1 -1
- package/dist/urn.js +4 -9
- package/dist/urn.js.map +1 -1
- package/dist/utils.js +5 -9
- package/dist/utils.js.map +1 -1
- package/eslint.config.mjs +53 -0
- package/package.json +12 -13
- package/src/access-rights.js +4 -4
- package/src/addMissingField336.js +1 -1
- package/src/cyrillux-usemarcon-replacement.js +38 -38
- package/src/cyrillux.js +14 -14
- package/src/disambiguateSeriesStatements.js +3 -3
- package/src/double-commas.js +2 -2
- package/src/duplicates-ind1.js +1 -1
- package/src/empty-fields.js +4 -4
- package/src/ending-punctuation.js +46 -49
- package/src/ending-whitespace.js +0 -2
- package/src/field-008-18-34-character-groups.js +5 -5
- package/src/field-505-separators.js +6 -6
- package/src/field-521-fix.js +6 -6
- package/src/field-exclusion.js +12 -12
- package/src/field-exclusion.spec.js +4 -4
- package/src/field-structure.js +5 -5
- package/src/fields-present.js +1 -1
- package/src/fields-present.spec.js +1 -1
- package/src/fix-33X.js +5 -5
- package/src/fix-country-codes.js +3 -3
- package/src/fix-language-codes.js +10 -9
- package/src/fixRelatorTerms.js +8 -8
- package/src/fixed-fields.js +3 -3
- package/src/identical-fields.js +3 -3
- package/src/indicator-fixes.js +15 -15
- package/src/isbn-issn.js +11 -11
- package/src/item-language.js +10 -10
- package/src/merge-fields/counterpartField.js +7 -7
- package/src/merge-fields/index.js +3 -3
- package/src/merge-fields/mergeConstraints.js +1 -1
- package/src/merge-fields/mergeField.js +16 -17
- package/src/merge-fields/mergeIndicator.js +5 -5
- package/src/merge-fields/mergeOrAddPostprocess.js +9 -9
- package/src/merge-fields/mergeOrAddSubfield.js +6 -6
- package/src/merge-fields/mergeSubfield.js +8 -8
- package/src/merge-fields/removeDuplicateSubfields.js +1 -2
- package/src/merge-fields/worldKnowledge.js +1 -1
- package/src/mergeField500Lisapainokset.js +0 -2
- package/src/mergeRelatorTermFields.js +3 -3
- package/src/modernize-502.js +6 -6
- package/src/multiple-subfield-0.js +4 -4
- package/src/non-breaking-space.js +0 -2
- package/src/normalize-dashes.js +4 -4
- package/src/normalize-identifiers.js +6 -6
- package/src/normalize-qualifying-information.js +4 -4
- package/src/normalize-utf8-diacritics.js +7 -7
- package/src/normalizeFieldForComparison.js +20 -20
- package/src/normalizeSubfieldValueForComparison.js +1 -1
- package/src/prepublicationUtils.js +3 -3
- package/src/punctuation/index.js +29 -29
- package/src/punctuation2.js +10 -10
- package/src/reindexSubfield6OccurenceNumbers.js +9 -9
- package/src/removeDuplicateDataFields.js +21 -23
- package/src/removeInferiorDataFields.js +19 -19
- package/src/resolvable-ext-references-melinda.js +8 -8
- package/src/resolveOrphanedSubfield6s.js +9 -9
- package/src/sanitize-vocabulary-source-codes.js +8 -8
- package/src/sort-tags.js +2 -2
- package/src/sortFields.js +6 -6
- package/src/sortRelatorTerms.js +5 -5
- package/src/sortSubfields.js +6 -6
- package/src/stripPunctuation.js +2 -2
- package/src/subfield-exclusion.js +11 -11
- package/src/subfield6Utils.js +11 -11
- package/src/subfield8Utils.js +6 -9
- package/src/subfieldValueNormalizations.js +5 -7
- package/src/sync-007-and-300.js +8 -8
- package/src/translate-terms.js +3 -5
- package/src/typeOfDate-008.js +3 -3
- package/src/unicode-decomposition.js +1 -1
- package/src/update-field-540.js +6 -6
- package/src/urn.js +8 -6
- package/src/utils.js +8 -8
- package/.eslintignore +0 -1
|
@@ -28,10 +28,10 @@ export function isEnnakkotietoSubfieldG(subfield) {
|
|
|
28
28
|
function debugFieldComparison(oldField, newField) { // NB: Debug-only function!
|
|
29
29
|
/*
|
|
30
30
|
// We may drop certain subfields:
|
|
31
|
-
if (oldField.subfields.length === newField.subfields.length) {
|
|
31
|
+
if (oldField.subfields.length === newField.subfields.length) {
|
|
32
32
|
oldField.subfields.forEach((subfield, index) => {
|
|
33
33
|
const newValue = newField.subfields[index].value;
|
|
34
|
-
if (subfield.value !== newValue) {
|
|
34
|
+
if (subfield.value !== newValue) {
|
|
35
35
|
nvdebug(`NORMALIZE SUBFIELD: '${subfield.value}' => '${newValue}'`, debugDev);
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -116,7 +116,7 @@ function subfieldValueLowercase(value, subfieldCode, tag) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
function subfieldLowercase(sf, tag) {
|
|
119
|
-
sf.value = subfieldValueLowercase(sf.value, sf.code, tag);
|
|
119
|
+
sf.value = subfieldValueLowercase(sf.value, sf.code, tag);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
function fieldLowercase(field) {
|
|
@@ -124,7 +124,7 @@ function fieldLowercase(field) {
|
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
field.subfields.forEach(sf => subfieldLowercase(sf, field.tag));
|
|
127
|
+
field.subfields.forEach(sf => subfieldLowercase(sf, field.tag)); // eslint-disable-line array-callback-return
|
|
128
128
|
|
|
129
129
|
function skipFieldLowercase(field) {
|
|
130
130
|
if (skipAllFieldNormalizations(field.tag)) {
|
|
@@ -144,7 +144,7 @@ function hack490SubfieldA(field) {
|
|
|
144
144
|
if (field.tag !== '490') {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
field.subfields.forEach(sf => removeSarja(sf));
|
|
147
|
+
field.subfields.forEach(sf => removeSarja(sf)); // eslint-disable-line array-callback-return
|
|
148
148
|
|
|
149
149
|
// NB! This won't work, if the punctuation has not been stripped beforehand!
|
|
150
150
|
function removeSarja(subfield) {
|
|
@@ -153,7 +153,7 @@ function hack490SubfieldA(field) {
|
|
|
153
153
|
}
|
|
154
154
|
const tmp = subfield.value.replace(/ ?-(?:[a-z]|ä|ö)*sarja$/u, '');
|
|
155
155
|
if (tmp.length > 0) {
|
|
156
|
-
subfield.value = tmp;
|
|
156
|
+
subfield.value = tmp;
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -185,12 +185,12 @@ function normalizeISBN(field) {
|
|
|
185
185
|
|
|
186
186
|
//nvdebug(`ISBN-field? ${fieldToString(field)}`);
|
|
187
187
|
const relevantSubfields = field.subfields.filter(sf => tagAndSubfieldCodeReferToIsbn(field.tag, sf.code) && looksLikeIsbn(sf.value));
|
|
188
|
-
relevantSubfields.forEach(sf => normalizeIsbnSubfield(sf));
|
|
188
|
+
relevantSubfields.forEach(sf => normalizeIsbnSubfield(sf)); // eslint-disable-line array-callback-return
|
|
189
189
|
|
|
190
190
|
function normalizeIsbnSubfield(sf) {
|
|
191
191
|
//nvdebug(` ISBN-subfield? ${subfieldToString(sf)}`);
|
|
192
|
-
sf.value = sf.value.replace(/-/ug, '');
|
|
193
|
-
sf.value = sf.value.replace(/x/u, 'X');
|
|
192
|
+
sf.value = sf.value.replace(/-/ug, '');
|
|
193
|
+
sf.value = sf.value.replace(/x/u, 'X');
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
}
|
|
@@ -202,9 +202,9 @@ function fieldSpecificHacks(field) {
|
|
|
202
202
|
|
|
203
203
|
export function fieldTrimSubfieldValues(field) {
|
|
204
204
|
field.subfields?.forEach((sf) => {
|
|
205
|
-
sf.value = sf.value.replace(/^[ \t\n]+/u, '');
|
|
206
|
-
sf.value = sf.value.replace(/[ \t\n]+$/u, '');
|
|
207
|
-
sf.value = sf.value.replace(/[ \t\n]+/gu, ' ');
|
|
205
|
+
sf.value = sf.value.replace(/^[ \t\n]+/u, '');
|
|
206
|
+
sf.value = sf.value.replace(/[ \t\n]+$/u, '');
|
|
207
|
+
sf.value = sf.value.replace(/[ \t\n]+/gu, ' ');
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -212,7 +212,7 @@ function fieldRemoveDecomposedDiacritics(field) {
|
|
|
212
212
|
// Raison d'être/motivation: "Sirén" and diacriticless "Siren" might refer to a same surname, so this normalization
|
|
213
213
|
// allows us to compare authors and avoid duplicate fields.
|
|
214
214
|
field.subfields.forEach((sf) => {
|
|
215
|
-
sf.value = removeDecomposedDiacritics(sf.value);
|
|
215
|
+
sf.value = removeDecomposedDiacritics(sf.value);
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
|
|
@@ -230,7 +230,7 @@ function normalizeSubfieldValue(value, subfieldCode, tag) {
|
|
|
230
230
|
|
|
231
231
|
// Normalize: s. = sivut = pp.
|
|
232
232
|
value = normalizePartData(value, subfieldCode, tag);
|
|
233
|
-
value = value.replace(/^\[([^[\]]+)\]/gu, '$1'); // eslint-disable-line functional/immutable-data
|
|
233
|
+
value = value.replace(/^\[([^[\]]+)\]/gu, '$1'); // eslint-disable-line functional/immutable-data
|
|
234
234
|
|
|
235
235
|
if (['130', '730'].includes(tag) && subfieldCode === 'a') {
|
|
236
236
|
value = value.replace(' : ', ', '); // "Halloween ends (elokuva, 2022)" vs "Halloween ends (elokuva : 2023)"
|
|
@@ -268,7 +268,7 @@ function removeCharsThatDontCarryMeaning(value, tag, subfieldCode) {
|
|
|
268
268
|
if (tag === '080') {
|
|
269
269
|
return value;
|
|
270
270
|
}
|
|
271
|
-
|
|
271
|
+
|
|
272
272
|
// 3" refers to inches, but as this is for comparison only we don't mind...
|
|
273
273
|
value = value.replace(/['‘’"„“”«»]/gu, ''); // MET-570 et al. Subset of https://hexdocs.pm/ex_unicode/Unicode.Category.QuoteMarks.html
|
|
274
274
|
// MRA-273: Handle X00$a name initials.
|
|
@@ -277,12 +277,12 @@ function removeCharsThatDontCarryMeaning(value, tag, subfieldCode) {
|
|
|
277
277
|
if (subfieldCode === 'a' && ['100', '400', '600', '700', '800'].includes(tag)) { // 400 is used in auth records. It's not a bib field at all.
|
|
278
278
|
value = value.replace(/([A-Z]|Å|Ä|Ö)\. +/ugi, '$1.');
|
|
279
279
|
}
|
|
280
|
-
|
|
280
|
+
|
|
281
281
|
return value;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
function normalizeField(field) {
|
|
285
|
-
//sf.value = removeDecomposedDiacritics(sf.value);
|
|
285
|
+
//sf.value = removeDecomposedDiacritics(sf.value);
|
|
286
286
|
fieldStripPunctuation(field);
|
|
287
287
|
fieldLowercase(field);
|
|
288
288
|
fieldNormalizeControlNumbers(field); // FIN11 vs FI-MELINDA etc.
|
|
@@ -297,11 +297,11 @@ export function cloneAndNormalizeFieldForComparison(field) {
|
|
|
297
297
|
return clonedField;
|
|
298
298
|
}
|
|
299
299
|
clonedField.subfields.forEach((sf) => { // Do this for all fields or some fields?
|
|
300
|
-
sf.value = normalizeSubfieldValue(sf.value, sf.code, field.tag);
|
|
301
|
-
sf.value = removeCharsThatDontCarryMeaning(sf.value, field.tag, sf.code)
|
|
300
|
+
sf.value = normalizeSubfieldValue(sf.value, sf.code, field.tag);
|
|
301
|
+
sf.value = removeCharsThatDontCarryMeaning(sf.value, field.tag, sf.code);
|
|
302
302
|
});
|
|
303
303
|
|
|
304
|
-
normalizeField(clonedField);
|
|
304
|
+
normalizeField(clonedField);
|
|
305
305
|
fieldRemoveDecomposedDiacritics(clonedField);
|
|
306
306
|
fieldSpecificHacks(clonedField);
|
|
307
307
|
fieldTrimSubfieldValues(clonedField);
|
|
@@ -21,7 +21,7 @@ export function subfieldContainsPartData(tag, subfieldCode) {
|
|
|
21
21
|
function splitPartData(originalValue) {
|
|
22
22
|
// This a very hacky function, but cand really help it, as the the data is very iffy as well...
|
|
23
23
|
// Remove punctuation and brackets:
|
|
24
|
-
const value = originalValue.replace(/[-.,:; ]+$/ui, '').replace(/^\[([0-9]+)\]$/ui, '$1');
|
|
24
|
+
const value = originalValue.replace(/[-.,:; ]+$/ui, '').replace(/^\[([0-9]+)\]$/ui, '$1');
|
|
25
25
|
|
|
26
26
|
const [year, rest] = extractYear(value);
|
|
27
27
|
|
|
@@ -178,7 +178,7 @@ export function deleteAllPrepublicationNotesFromField500InNonPubRecord(record) {
|
|
|
178
178
|
|
|
179
179
|
|
|
180
180
|
nvdebug(`Delete all ${f500.length} instance(s) of field 500`, debugDev);
|
|
181
|
-
f500.forEach(field => record.removeField(field));
|
|
181
|
+
f500.forEach(field => record.removeField(field)); // eslint-disable-line array-callback-return
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
|
|
@@ -188,7 +188,7 @@ export function removeWorsePrepubField500s(record) {
|
|
|
188
188
|
nvdebugFieldArray(fields, ' Candidates for non-best 500 b4 filtering: ', debugDev);
|
|
189
189
|
const nonBest = fields.filter(field => fields.some(field2 => firstFieldHasBetterPrepubEncodingLevel(field2, field)));
|
|
190
190
|
nvdebugFieldArray(nonBest, ' Remove non-best 500: ', debugDev);
|
|
191
|
-
nonBest.forEach(field => record.removeField(field));
|
|
191
|
+
nonBest.forEach(field => record.removeField(field)); // eslint-disable-line array-callback-return
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
|
|
@@ -198,7 +198,7 @@ export function removeWorsePrepubField594s(record) {
|
|
|
198
198
|
nvdebugFieldArray(fields594, ' Candidates for non-best 594 b4 filtering: ', debugDev);
|
|
199
199
|
const nonBest = fields594.filter(field => fields594.some(field2 => firstFieldHasBetterPrepubEncodingLevel(field2, field)));
|
|
200
200
|
nvdebugFieldArray(nonBest, ' Remove non-best 594: ', debugDev);
|
|
201
|
-
nonBest.forEach(field => record.removeField(field));
|
|
201
|
+
nonBest.forEach(field => record.removeField(field)); // eslint-disable-line array-callback-return
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
|
package/src/punctuation/index.js
CHANGED
|
@@ -75,16 +75,16 @@ export default function () {
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
let currentPortion;
|
|
79
|
-
let preceedingField;
|
|
80
|
-
let inNamePortion = true;
|
|
78
|
+
let currentPortion;
|
|
79
|
+
let preceedingField;
|
|
80
|
+
let inNamePortion = true;
|
|
81
81
|
|
|
82
82
|
debug(`Field subfields: ${field.subfields.map(sub => sub.code)}`);
|
|
83
83
|
debug(`Field portions: ${field.subfields.map(sub => getPortion(sub, rulesForField))}`);
|
|
84
84
|
|
|
85
85
|
field.subfields.forEach(subfield => {
|
|
86
86
|
debug(`Handling subfield ${subfield.code}`);
|
|
87
|
-
let portion = getPortion(subfield, rulesForField);
|
|
87
|
+
let portion = getPortion(subfield, rulesForField);
|
|
88
88
|
|
|
89
89
|
if (portion === false) {
|
|
90
90
|
return;
|
|
@@ -94,28 +94,28 @@ export default function () {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
if (inNamePortion && portion.includes('T', 'S')) {
|
|
97
|
+
if (inNamePortion && portion.includes('T', 'S')) {
|
|
98
98
|
debug(`Portion changed to ${portion}. Not in name portion anymore`);
|
|
99
99
|
inNamePortion = false;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
if (inNamePortion && portion === 'NT') {
|
|
102
|
+
if (inNamePortion && portion === 'NT') {
|
|
103
103
|
portion = 'N';
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
if (!inNamePortion && portion === 'NT') {
|
|
106
|
+
if (!inNamePortion && portion === 'NT') {
|
|
107
107
|
portion = 'T';
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
debug(`Current portion is ${portion}.`);
|
|
111
111
|
|
|
112
112
|
if (currentPortion) {
|
|
113
|
-
if (currentPortion === portion) {
|
|
113
|
+
if (currentPortion === portion) {
|
|
114
114
|
debug(`Current stayed as ${portion}. Adding punctuation for subfield.`);
|
|
115
115
|
addSubfieldPunctuation(preceedingField, subfield, rulesForField);
|
|
116
116
|
} else {
|
|
117
117
|
debug(`Current portion changed to ${portion}.`);
|
|
118
|
-
if (portion !== 'S') {
|
|
118
|
+
if (portion !== 'S') {
|
|
119
119
|
debug('Adding punctuation for portion.');
|
|
120
120
|
addNamePortionPunctuation(preceedingField);
|
|
121
121
|
}
|
|
@@ -126,7 +126,7 @@ export default function () {
|
|
|
126
126
|
preceedingField = subfield;
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
if (recordType !== 'z') {
|
|
129
|
+
if (recordType !== 'z') {
|
|
130
130
|
addNamePortionPunctuation(preceedingField);
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -152,10 +152,10 @@ export default function () {
|
|
|
152
152
|
|
|
153
153
|
function addNamePortionPunctuation(preceedingSubfield) {
|
|
154
154
|
const subfieldContainsPunctuation = (/[?")\].\-!,]$/u).test(preceedingSubfield.value);
|
|
155
|
-
if (!subfieldContainsPunctuation) {
|
|
155
|
+
if (!subfieldContainsPunctuation) {
|
|
156
156
|
const nextValue = `${preceedingSubfield.value}.`;
|
|
157
157
|
debug(`Updated subfield ${preceedingSubfield.code} from '${preceedingSubfield.value}' to '${nextValue}'`);
|
|
158
|
-
preceedingSubfield.value = nextValue;
|
|
158
|
+
preceedingSubfield.value = nextValue;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -173,41 +173,41 @@ export default function () {
|
|
|
173
173
|
debug(`addSubfieldPunctuation -- punctType: ${punctType} endsInPunctuation: ${endsInPunctuation}`);
|
|
174
174
|
|
|
175
175
|
if (!endsInPunctuation) {
|
|
176
|
-
if (punctType === 'PERIOD' && !(/\.$/u).test(preceedingSubfield.value)) {
|
|
176
|
+
if (punctType === 'PERIOD' && !(/\.$/u).test(preceedingSubfield.value)) {
|
|
177
177
|
const nextValue = `${preceedingSubfield.value}.`;
|
|
178
178
|
debug(`Updated subfield ${preceedingSubfield.code} from '${preceedingSubfield.value}' to '${nextValue}'`);
|
|
179
|
-
preceedingSubfield.value = nextValue;
|
|
179
|
+
preceedingSubfield.value = nextValue;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
if (punctType === 'COMMA') {
|
|
184
184
|
if (!(/,$/u).test(preceedingSubfield.value)) {
|
|
185
|
-
if (!(/^[[(]/u).test(currentSubfield.value)) {
|
|
185
|
+
if (!(/^[[(]/u).test(currentSubfield.value)) {
|
|
186
186
|
const nextValue = `${preceedingSubfield.value},`;
|
|
187
187
|
debug(`Updated subfield ${preceedingSubfield.code} from '${preceedingSubfield.value}' to '${nextValue}'`);
|
|
188
|
-
preceedingSubfield.value = nextValue;
|
|
188
|
+
preceedingSubfield.value = nextValue;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
if (punctType === 'COND_COMMA') {
|
|
194
|
-
if (!(/[-,]$/u).test(preceedingSubfield.value)) {
|
|
194
|
+
if (!(/[-,]$/u).test(preceedingSubfield.value)) {
|
|
195
195
|
const nextValue = `${preceedingSubfield.value},`;
|
|
196
196
|
debug(`Updated subfield ${preceedingSubfield.code} from '${preceedingSubfield.value}' to '${nextValue}'`);
|
|
197
|
-
preceedingSubfield.value = nextValue;
|
|
197
|
+
preceedingSubfield.value = nextValue;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
if (punctType === 'SPACECOLON') {
|
|
202
|
-
if (!(/:$/u).test(preceedingSubfield.value)) {
|
|
202
|
+
if (!(/:$/u).test(preceedingSubfield.value)) {
|
|
203
203
|
const nextValue = `${preceedingSubfield.value} :`;
|
|
204
204
|
debug(`Updated subfield ${preceedingSubfield.code} from '${preceedingSubfield.value}' to '${nextValue}'`);
|
|
205
|
-
preceedingSubfield.value = nextValue;
|
|
205
|
+
preceedingSubfield.value = nextValue;
|
|
206
206
|
}
|
|
207
|
-
if ((/[^ ]:$/u).test(preceedingSubfield.value)) {
|
|
207
|
+
if ((/[^ ]:$/u).test(preceedingSubfield.value)) {
|
|
208
208
|
const nextValue = `${preceedingSubfield.value.slice(0, -1)} :`;
|
|
209
209
|
debug(`Updated subfield ${preceedingSubfield.code} from '${preceedingSubfield.value}' to '${nextValue}'`);
|
|
210
|
-
preceedingSubfield.value = nextValue;
|
|
210
|
+
preceedingSubfield.value = nextValue;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
}
|
|
@@ -240,12 +240,12 @@ export default function () {
|
|
|
240
240
|
const exceptionFuncs = [];
|
|
241
241
|
|
|
242
242
|
exceptionRules.forEach(exceptionRule => {
|
|
243
|
-
const match = (/- (.*) if preceded by (.*)/u).exec(exceptionRule);
|
|
244
|
-
if (match) {
|
|
243
|
+
const match = (/- (.*) if preceded by (.*)/u).exec(exceptionRule);
|
|
244
|
+
if (match) {
|
|
245
245
|
const [, type, preceededCode] = match;
|
|
246
246
|
const normalizedType = type.trim().toUpperCase().trim();
|
|
247
247
|
const normalizedCode = preceededCode.replace(/\$/ug, '').trim();
|
|
248
|
-
exceptionFuncs.push(ifPrecededByException(normalizedCode, normalizedType));
|
|
248
|
+
exceptionFuncs.push(ifPrecededByException(normalizedCode, normalizedType));
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
251
|
|
|
@@ -256,16 +256,16 @@ export default function () {
|
|
|
256
256
|
return preceedingSubfield => {
|
|
257
257
|
if (code === preceedingSubfield.code) {
|
|
258
258
|
debug(`Adding ${type} to ${preceedingSubfield.code}`);
|
|
259
|
-
if (type === 'SEMICOLON' && !(/;$/u).test(preceedingSubfield.value)) {
|
|
259
|
+
if (type === 'SEMICOLON' && !(/;$/u).test(preceedingSubfield.value)) {
|
|
260
260
|
const nextValue = `${preceedingSubfield.value} ;`;
|
|
261
261
|
debug(`Updated subfield ${preceedingSubfield.code} from '${preceedingSubfield.value}' to '${nextValue}'`);
|
|
262
|
-
preceedingSubfield.value = nextValue;
|
|
262
|
+
preceedingSubfield.value = nextValue;
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
if (type === 'COLON' && !(/:$/u).test(preceedingSubfield.value)) {
|
|
265
|
+
if (type === 'COLON' && !(/:$/u).test(preceedingSubfield.value)) {
|
|
266
266
|
const nextValue = `${preceedingSubfield.value} :`;
|
|
267
267
|
debug(`Updated subfield ${preceedingSubfield.code} from '${preceedingSubfield.value}' to '${nextValue}'`);
|
|
268
|
-
preceedingSubfield.value = nextValue;
|
|
268
|
+
preceedingSubfield.value = nextValue;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
return true;
|
package/src/punctuation2.js
CHANGED
|
@@ -27,7 +27,7 @@ export default function () {
|
|
|
27
27
|
function fix(record) {
|
|
28
28
|
nvdebug(`${descriptionString}: fixer`);
|
|
29
29
|
const res = {message: [], fix: [], valid: true};
|
|
30
|
-
record.fields.forEach(f => fieldFixPunctuation(f));
|
|
30
|
+
record.fields.forEach(f => fieldFixPunctuation(f)); // eslint-disable-line array-callback-return
|
|
31
31
|
return res;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -44,7 +44,7 @@ export default function () {
|
|
|
44
44
|
|
|
45
45
|
const res = {message: messages};
|
|
46
46
|
|
|
47
|
-
res.valid = res.message.length < 1;
|
|
47
|
+
res.valid = res.message.length < 1;
|
|
48
48
|
return res;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -390,13 +390,13 @@ function debugRule(rule) {
|
|
|
390
390
|
//nvdebug('');
|
|
391
391
|
nvdebug(`NAME ${rule.name ? rule.name : '<unnamed>'}`);
|
|
392
392
|
nvdebug(`SUBFIELD CODE '${rule.code}' FOLLOWED BY SUBFIELD CODE '${rule.followedBy}'`);
|
|
393
|
-
if ('add' in rule) {
|
|
393
|
+
if ('add' in rule) {
|
|
394
394
|
nvdebug(`ADD '${rule.add}'`);
|
|
395
395
|
}
|
|
396
|
-
if ('remove' in rule) {
|
|
396
|
+
if ('remove' in rule) {
|
|
397
397
|
nvdebug(`REMOVE '${rule.remove}'`);
|
|
398
398
|
}
|
|
399
|
-
if ('context' in rule) {
|
|
399
|
+
if ('context' in rule) {
|
|
400
400
|
nvdebug(`CONTEXT '${rule.context.toString()}'`);
|
|
401
401
|
}
|
|
402
402
|
//nvdebug('');
|
|
@@ -517,19 +517,19 @@ function applyPunctuationRules(field, subfield1, subfield2, ruleArray = null, op
|
|
|
517
517
|
//const originalValue = subfield1.value;
|
|
518
518
|
if (rule.remove && [REMOVE, REMOVE_AND_ADD].includes(operation) && subfield1.value.match(rule.remove)) {
|
|
519
519
|
//nvdebug(` PUNC REMOVAL TO BE PERFORMED FOR $${subfield1.code} '${subfield1.value}'`, debug);
|
|
520
|
-
subfield1.value = subfield1.value.replace(rule.remove, '');
|
|
520
|
+
subfield1.value = subfield1.value.replace(rule.remove, '');
|
|
521
521
|
//nvdebug(` PUNC REMOVAL PERFORMED FOR '${subfield1.value}'`);
|
|
522
522
|
return false;
|
|
523
523
|
}
|
|
524
524
|
if (rule.add && [ADD, REMOVE_AND_ADD].includes(operation)) {
|
|
525
|
-
subfield1.value += rule.add;
|
|
525
|
+
subfield1.value += rule.add;
|
|
526
526
|
//nvdebug(` ADDED '${rule.add}' TO FORM '${subfield1.value}' USING RULE ${rule.name}`);
|
|
527
527
|
return false;
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
/*
|
|
531
|
-
if (subfield1.value !== originalValue) {
|
|
532
|
-
nvdebug(` PROCESS PUNC: '‡${subfield1.code} ${originalValue}' => '‡${subfield1.code} ${subfield1.value}'`, debug);
|
|
531
|
+
if (subfield1.value !== originalValue) {
|
|
532
|
+
nvdebug(` PROCESS PUNC: '‡${subfield1.code} ${originalValue}' => '‡${subfield1.code} ${subfield1.value}'`, debug);
|
|
533
533
|
}
|
|
534
534
|
*/
|
|
535
535
|
|
|
@@ -579,7 +579,7 @@ export function fieldFixPunctuation(field) {
|
|
|
579
579
|
});
|
|
580
580
|
|
|
581
581
|
// Use shared code for final punctuation (sadly this does not fix intermediate punc):
|
|
582
|
-
if (field.useExternalEndPunctuation) {
|
|
582
|
+
if (field.useExternalEndPunctuation) {
|
|
583
583
|
// addFinalPunctuation(field); // local version. use shared code instead.
|
|
584
584
|
validateSingleField(field, false, true); // NB! Don't use field.tag as second argument! It's a string, not an int. 3rd arg must be true (=fix)
|
|
585
585
|
}
|
|
@@ -22,14 +22,14 @@ export default function () {
|
|
|
22
22
|
function fix(record) {
|
|
23
23
|
nvdebug('Fix SF6 occurrence numbers', debug);
|
|
24
24
|
const res = {message: [], fix: [], valid: true};
|
|
25
|
-
//message.fix = [];
|
|
25
|
+
//message.fix = [];
|
|
26
26
|
|
|
27
27
|
// This can not really fail...
|
|
28
28
|
|
|
29
29
|
recordDisambiguateSharedSubfield6OccurrenceNumbers(record);
|
|
30
30
|
recordResetSubfield6OccurrenceNumbers(record);
|
|
31
31
|
|
|
32
|
-
// message.valid = !(message.message.length >= 1);
|
|
32
|
+
// message.valid = !(message.message.length >= 1);
|
|
33
33
|
return res;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -37,8 +37,8 @@ export default function () {
|
|
|
37
37
|
const res = {message: []};
|
|
38
38
|
|
|
39
39
|
nvdebug('Validate SF6 occurrence number multiuses', debug);
|
|
40
|
-
if (recordGetSharedOccurrenceNumbers(record).length) {
|
|
41
|
-
res.message.push(`Multi-use of occurrence number(s) detected`);
|
|
40
|
+
if (recordGetSharedOccurrenceNumbers(record).length) {
|
|
41
|
+
res.message.push(`Multi-use of occurrence number(s) detected`);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// Check max, and check number of different indexes
|
|
@@ -47,10 +47,10 @@ export default function () {
|
|
|
47
47
|
const size = recordGetNumberOfUniqueSubfield6OccurrenceNumbers(record);
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
if (max !== size) {
|
|
51
|
-
res.message.push(`Gaps detected in occurrence numbers: found ${size}, seen max ${max}`);
|
|
50
|
+
if (max !== size) {
|
|
51
|
+
res.message.push(`Gaps detected in occurrence numbers: found ${size}, seen max ${max}`);
|
|
52
52
|
}
|
|
53
|
-
res.valid = res.message.length < 1;
|
|
53
|
+
res.valid = res.message.length < 1;
|
|
54
54
|
return res;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -91,7 +91,7 @@ function recordDisambiguateSharedSubfield6OccurrenceNumbers(record) {
|
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
nvdebug(`Disambiguate occurrence numbers (N=${sharedOccurrenceNumberFields.length}) in...`, debug);
|
|
94
|
-
sharedOccurrenceNumberFields.forEach(field => disambiguateOccurrenceNumber(field));
|
|
94
|
+
sharedOccurrenceNumberFields.forEach(field => disambiguateOccurrenceNumber(field)); // eslint-disable-line array-callback-return
|
|
95
95
|
|
|
96
96
|
function disambiguateable(field) {
|
|
97
97
|
if (field.tag === '880') { // Not needed, already filtered...
|
|
@@ -131,7 +131,7 @@ function recordDisambiguateSharedSubfield6OccurrenceNumbers(record) {
|
|
|
131
131
|
nvdebug(` Reindex '${fieldToString(field)}' occurrence number and it's ${pairedFields.length} pair(s) using '${newOccurrenceNumber}'`, debug);
|
|
132
132
|
|
|
133
133
|
fieldResetOccurrenceNumber(field, newOccurrenceNumber, occurrenceNumber);
|
|
134
|
-
pairedFields.forEach(pairedField => fieldResetOccurrenceNumber(pairedField, newOccurrenceNumber, occurrenceNumber));
|
|
134
|
+
pairedFields.forEach(pairedField => fieldResetOccurrenceNumber(pairedField, newOccurrenceNumber, occurrenceNumber)); // eslint-disable-line array-callback-return
|
|
135
135
|
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -37,11 +37,11 @@ export default function () {
|
|
|
37
37
|
const res = {message: duplicates};
|
|
38
38
|
|
|
39
39
|
/*
|
|
40
|
-
if (orphanedFields.length > 0) {
|
|
41
|
-
res.message = [`${orphanedFields.length} orphaned occurrence number field(s) detected`];
|
|
40
|
+
if (orphanedFields.length > 0) {
|
|
41
|
+
res.message = [`${orphanedFields.length} orphaned occurrence number field(s) detected`];
|
|
42
42
|
}
|
|
43
43
|
*/
|
|
44
|
-
res.valid = res.message.length < 1;
|
|
44
|
+
res.valid = res.message.length < 1;
|
|
45
45
|
return res;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -56,7 +56,7 @@ function numberOfLinkageSubfields(field) {
|
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
58
|
function removeLinkNotes(record) {
|
|
59
|
-
record.fields.forEach(f => delete f.linkNote); // eslint-disable-line
|
|
59
|
+
record.fields.forEach(f => delete f.linkNote); // eslint-disable-line array-callback-return
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
|
|
@@ -109,19 +109,19 @@ function recordRemoveFieldOrSubfield8(record, field, currLinkingNumber) {
|
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
const subfields = field.subfields.filter(sf => getSubfield8LinkingNumber(sf) === currLinkingNumber);
|
|
112
|
-
subfields.forEach(sf => record.removeSubfield(sf, field));
|
|
112
|
+
subfields.forEach(sf => record.removeSubfield(sf, field)); // eslint-disable-line array-callback-return
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function newRecordRemoveFieldOrSubfield8(record, field, currLinkingNumber, fix) {
|
|
116
116
|
const eights = field.subfields.filter(sf => sf.code === '8');
|
|
117
117
|
if (eights.length < 2) {
|
|
118
|
-
field.deleted = 1;
|
|
118
|
+
field.deleted = 1;
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
const subfields = field.subfields.filter(sf => getSubfield8LinkingNumber(sf) === currLinkingNumber);
|
|
122
122
|
subfields.forEach(sf => {
|
|
123
|
-
field.modified = 1;
|
|
124
|
-
if (fix) {
|
|
123
|
+
field.modified = 1;
|
|
124
|
+
if (fix) {
|
|
125
125
|
record.removeSubfield(sf, field);
|
|
126
126
|
}
|
|
127
127
|
});
|
|
@@ -232,7 +232,7 @@ function markIdenticalSubfield6Chains(chain, record) {
|
|
|
232
232
|
const chainAsString = fieldsToNormalizedString(chain, 0, normalizeOccurrenceNumber, normalizeTag);
|
|
233
233
|
|
|
234
234
|
nvdebug(`markIdenticalSubfield6Chains: ${chainAsString}`);
|
|
235
|
-
record.fields.forEach(f => compareWithChain(f));
|
|
235
|
+
record.fields.forEach(f => compareWithChain(f)); // eslint-disable-line array-callback-return
|
|
236
236
|
|
|
237
237
|
|
|
238
238
|
function compareWithChain(f) {
|
|
@@ -248,7 +248,7 @@ function markIdenticalSubfield6Chains(chain, record) {
|
|
|
248
248
|
if (chainAsString === otherChainAsString) {
|
|
249
249
|
otherChain.forEach(f => {
|
|
250
250
|
nvdebug(` mark ${fieldToString(f)} as deleted ($6-chain)...`);
|
|
251
|
-
f.deleted = 1;
|
|
251
|
+
f.deleted = 1;
|
|
252
252
|
});
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
@@ -269,7 +269,7 @@ function markIdenticalLoneFieldsAsDeletable(field, record) {
|
|
|
269
269
|
// Mark fields as deleted:
|
|
270
270
|
identicalLoneFields.forEach(f => {
|
|
271
271
|
nvdebug(` mark ${fieldToString(f)} as deleted (lone field)...`);
|
|
272
|
-
f.deleted = 1;
|
|
272
|
+
f.deleted = 1;
|
|
273
273
|
});
|
|
274
274
|
|
|
275
275
|
}
|
|
@@ -324,11 +324,9 @@ function acceptFieldsWithSubfield8(fieldsWithSubfield8, requireSingleTag = false
|
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
export function sameField(field1, field2) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
delete field1.tmpMyId;
|
|
331
|
-
/* eslint-enable */
|
|
327
|
+
field1.tmpMyId = 666;
|
|
328
|
+
const result = field2.tmpMyId === 666 ? true : false;
|
|
329
|
+
delete field1.tmpMyId;
|
|
332
330
|
return result;
|
|
333
331
|
}
|
|
334
332
|
|
|
@@ -423,24 +421,24 @@ export function removeDuplicateDatafields(record, fix = true) {
|
|
|
423
421
|
|
|
424
422
|
const dataFields = record.fields.filter(f => f.subfields !== undefined);
|
|
425
423
|
|
|
426
|
-
dataFields.forEach(f => fieldHandleDuplicateDatafields(f, record));
|
|
424
|
+
dataFields.forEach(f => fieldHandleDuplicateDatafields(f, record)); // eslint-disable-line array-callback-return
|
|
427
425
|
|
|
428
426
|
const deletableFields = dataFields.filter(f => f.deleted);
|
|
429
427
|
const modifiedFields = dataFields.filter(f => f.modified && !f.deleted);
|
|
430
428
|
|
|
431
429
|
const result = deletableFields.map(f => `DEL: ${fieldToString(f)}`);
|
|
432
|
-
if (modifiedFields.length) {
|
|
433
|
-
modifiedFields.forEach(f => delete f.modified); // eslint-disable-line
|
|
434
|
-
result.push(modifiedFields.map(f => `MOD: ${fieldToString(f)}`));
|
|
430
|
+
if (modifiedFields.length) {
|
|
431
|
+
modifiedFields.forEach(f => delete f.modified); // eslint-disable-line array-callback-return
|
|
432
|
+
result.push(modifiedFields.map(f => `MOD: ${fieldToString(f)}`));
|
|
435
433
|
}
|
|
436
434
|
|
|
437
435
|
if (fix) {
|
|
438
|
-
deletableFields.forEach(f => record.removeField(f));
|
|
436
|
+
deletableFields.forEach(f => record.removeField(f)); // eslint-disable-line array-callback-return
|
|
439
437
|
return result;
|
|
440
438
|
}
|
|
441
439
|
|
|
442
|
-
deletableFields.forEach(f => delete f.deleted); // eslint-disable-line
|
|
443
|
-
deletableFields.forEach(f => delete f.modified); // eslint-disable-line
|
|
440
|
+
deletableFields.forEach(f => delete f.deleted); // eslint-disable-line array-callback-return
|
|
441
|
+
deletableFields.forEach(f => delete f.modified); // eslint-disable-line array-callback-return
|
|
444
442
|
|
|
445
443
|
|
|
446
444
|
return result;
|