@natlibfi/marc-record-merge 6.0.0-beta.2 → 6.0.0-beta.6
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/CODEOWNERS +9 -0
- package/.github/dependabot.yml +41 -0
- package/.github/workflows/melinda-node-tests.yml +60 -0
- package/LICENSE +21 -0
- package/README.md +106 -2
- package/dist/index.js +2 -37
- package/dist/index.js.map +1 -1
- package/dist/reducers/copy.js +310 -109
- package/dist/reducers/copy.js.map +1 -1
- package/dist/reducers/copy.spec.js +52 -99
- package/dist/reducers/copy.spec.js.map +1 -1
- package/dist/reducers/index.js +0 -27
- package/dist/reducers/index.js.map +1 -1
- package/dist/reducers/select.js +12 -50
- package/dist/reducers/select.js.map +1 -1
- package/dist/reducers/select.spec.js +49 -83
- package/dist/reducers/select.spec.js.map +1 -1
- package/package.json +30 -27
- package/src/index.js +1 -33
- package/src/reducers/copy.js +306 -115
- package/src/reducers/copy.spec.js +44 -66
- package/src/reducers/index.js +0 -27
- package/src/reducers/select.js +8 -51
- package/src/reducers/select.spec.js +37 -58
- package/test-fixtures/reducers/copy/{01/base.json → 01 - copy/01/base.json } +1 -1
- package/test-fixtures/reducers/copy/{01 → 01 - copy/01}/merged.json +0 -0
- package/test-fixtures/reducers/copy/01 - copy/01/metadata.json +4 -0
- package/test-fixtures/reducers/copy/{01 → 01 - copy/01}/source.json +0 -0
- package/test-fixtures/reducers/copy/{02/source.json → 01 - copy/02/base.json} +0 -0
- package/test-fixtures/reducers/copy/{02 → 01 - copy/02}/merged.json +0 -0
- package/test-fixtures/reducers/copy/01 - copy/02/metadata.json +4 -0
- package/test-fixtures/reducers/copy/{02/base.json → 01 - copy/02/source.json } +1 -1
- package/test-fixtures/reducers/copy/{03/base.json → 01 - copy/03/base.json } +1 -1
- package/test-fixtures/reducers/copy/{03 → 01 - copy/03}/merged.json +0 -0
- package/test-fixtures/reducers/copy/01 - copy/03/metadata.json +4 -0
- package/test-fixtures/reducers/copy/{03 → 01 - copy/03}/source.json +0 -0
- package/test-fixtures/reducers/copy/{05/base.json → 01 - copy/04/base.json } +1 -1
- package/test-fixtures/reducers/copy/{04/merged.json → 01 - copy/04/merged.json } +1 -1
- package/test-fixtures/reducers/copy/01 - copy/04/metadata.json +4 -0
- package/test-fixtures/reducers/copy/{04/source.json → 01 - copy/04/source.json } +1 -1
- package/test-fixtures/reducers/copy/{04/base.json → 01 - copy/05/base.json } +1 -1
- package/test-fixtures/reducers/copy/{05 → 01 - copy/05}/merged.json +0 -0
- package/test-fixtures/reducers/copy/01 - copy/05/metadata.json +4 -0
- package/test-fixtures/reducers/copy/{05 → 01 - copy/05}/source.json +0 -0
- package/test-fixtures/reducers/copy/01 - copy/06/base.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/06/merged.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/06/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/06/source.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/07/base.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/07/merged.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/07/metadata.json +5 -0
- package/test-fixtures/reducers/copy/01 - copy/07/source.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/08/base.json +28 -0
- package/test-fixtures/reducers/copy/01 - copy/08/merged.json +28 -0
- package/test-fixtures/reducers/copy/01 - copy/08/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/08/source.json +24 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/base.json +17 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/merged.json +20 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/source.json +20 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/base.json +9 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/merged.json +20 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/source.json +20 -0
- package/test-fixtures/reducers/copy/{06 → 03 - compareTagsOnly/01}/base.json +0 -0
- package/test-fixtures/reducers/copy/{06 → 03 - compareTagsOnly/01}/merged.json +0 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/{06 → 03 - compareTagsOnly/01}/source.json +0 -0
- package/test-fixtures/reducers/copy/{09 → 03 - compareTagsOnly/02}/base.json +0 -0
- package/test-fixtures/reducers/copy/{09 → 03 - compareTagsOnly/02}/merged.json +0 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/{09 → 03 - compareTagsOnly/02}/source.json +0 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/base.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/source.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/base.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/merged.json +39 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/source.json +24 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/base.json +9 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/source.json +47 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/base.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/merged.json +39 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/base.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/merged.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/base.json +28 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/merged.json +43 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/base.json +28 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/merged.json +28 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/base.json +20 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/merged.json +35 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/base.json +20 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/merged.json +35 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/source.json +24 -0
- package/test-fixtures/reducers/copy/{07 → 07 - excludeSubfields/01}/base.json +0 -0
- package/test-fixtures/reducers/copy/{07 → 07 - excludeSubfields/01}/merged.json +0 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/01/metadata.json +8 -0
- package/test-fixtures/reducers/copy/{07 → 07 - excludeSubfields/01}/source.json +0 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/base.json +39 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/merged.json +58 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/source.json +43 -0
- package/test-fixtures/reducers/copy/{08 → 08 - dropSubfields/01}/base.json +0 -0
- package/test-fixtures/reducers/copy/{08/merged.json → 08 - dropSubfields/01/merged.json } +8 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/{08 → 08 - dropSubfields/01}/source.json +0 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/base.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/merged.json +58 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/source.json +32 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/base.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/merged.json +58 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/source.json +32 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/base.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/merged.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/source.json +32 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/merged.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/source.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/merged.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/source.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/merged.json +31 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/source.json +31 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/merged.json +42 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/source.json +42 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/base.json +17 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/merged.json +28 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/source.json +20 -0
- package/test-fixtures/reducers/metadata.json +4 -0
- package/test-fixtures/reducers/select/01/metadata.json +5 -0
- package/test-fixtures/reducers/select/02/metadata.json +4 -0
- package/test-fixtures/reducers/select/03/metadata.json +4 -0
- package/test-fixtures/reducers/select/04/metadata.json +5 -0
- package/test-fixtures/reducers/select/05/metadata.json +4 -0
- package/test-fixtures/reducers/select/06/metadata.json +4 -0
- package/test-fixtures/reducers/select/07/metadata.json +5 -0
- package/test-fixtures/reducers/select/08/metadata.json +4 -0
- package/test-fixtures/reducers/select/09/metadata.json +4 -0
- package/test-fixtures/reducers/select/10/metadata.json +5 -0
- package/test-fixtures/reducers/select/11/metadata.json +4 -0
- package/test-fixtures/reducers/select/12/metadata.json +5 -0
- package/test-fixtures/reducers/select/13/metadata.json +4 -0
- package/test-fixtures/reducers/select/14/metadata.json +4 -0
- package/.drone.yml +0 -92
- package/.nyc_output/72717fff-b4ac-4aef-a145-37cae88e07f8.json +0 -1
- package/.nyc_output/processinfo/72717fff-b4ac-4aef-a145-37cae88e07f8.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/LICENSE.txt +0 -165
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -79
- package/coverage/copy.js.html +0 -500
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -126
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/copy.js.html +0 -500
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -126
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/select.js.html +0 -539
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov.info +0 -274
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/select.js.html +0 -539
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -170
- package/test-fixtures/reducers/copy/01/tagPattern.txt +0 -1
- package/test-fixtures/reducers/copy/02/tagPattern.txt +0 -1
- package/test-fixtures/reducers/copy/03/tagPattern.txt +0 -1
- package/test-fixtures/reducers/copy/04/tagPattern.txt +0 -1
- package/test-fixtures/reducers/copy/05/tagPattern.txt +0 -1
- package/test-fixtures/reducers/copy/06/compareTagsOnly.txt +0 -1
- package/test-fixtures/reducers/copy/06/tagPattern.txt +0 -1
- package/test-fixtures/reducers/copy/07/excludeSubfields.json +0 -1
- package/test-fixtures/reducers/copy/07/tagPattern.txt +0 -1
- package/test-fixtures/reducers/copy/08/dropSubfields.json +0 -1
- package/test-fixtures/reducers/copy/08/tagPattern.txt +0 -1
- package/test-fixtures/reducers/copy/09/compareTagsOnly.txt +0 -1
- package/test-fixtures/reducers/copy/09/tagPattern.txt +0 -1
- package/test-fixtures/reducers/select/01/expected-error.txt +0 -1
- package/test-fixtures/reducers/select/01/pattern.txt +0 -1
- package/test-fixtures/reducers/select/02/pattern.txt +0 -1
- package/test-fixtures/reducers/select/03/pattern.txt +0 -1
- package/test-fixtures/reducers/select/04/pattern.txt +0 -1
- package/test-fixtures/reducers/select/05/pattern.txt +0 -1
- package/test-fixtures/reducers/select/06/pattern.txt +0 -1
- package/test-fixtures/reducers/select/07/equalityFunction.txt +0 -1
- package/test-fixtures/reducers/select/07/pattern.txt +0 -1
- package/test-fixtures/reducers/select/08/pattern.txt +0 -1
- package/test-fixtures/reducers/select/09/pattern.txt +0 -1
- package/test-fixtures/reducers/select/10/equalityFunction.txt +0 -1
- package/test-fixtures/reducers/select/10/pattern.txt +0 -1
- package/test-fixtures/reducers/select/11/pattern.txt +0 -1
- package/test-fixtures/reducers/select/12/equalityFunction.txt +0 -1
- package/test-fixtures/reducers/select/12/pattern.txt +0 -1
- package/test-fixtures/reducers/select/13/pattern.txt +0 -1
- package/test-fixtures/reducers/select/14/pattern.txt +0 -1
package/coverage/select.js.html
DELETED
|
@@ -1,539 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for select.js</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="index.html">All files</a> select.js</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">98.46% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>64/65</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">96.43% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>27/28</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>20/20</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">98.41% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>62/63</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
</div>
|
|
58
|
-
<div class='status-line high'></div>
|
|
59
|
-
<pre><table class="coverage">
|
|
60
|
-
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
61
|
-
<a name='L2'></a><a href='#L2'>2</a>
|
|
62
|
-
<a name='L3'></a><a href='#L3'>3</a>
|
|
63
|
-
<a name='L4'></a><a href='#L4'>4</a>
|
|
64
|
-
<a name='L5'></a><a href='#L5'>5</a>
|
|
65
|
-
<a name='L6'></a><a href='#L6'>6</a>
|
|
66
|
-
<a name='L7'></a><a href='#L7'>7</a>
|
|
67
|
-
<a name='L8'></a><a href='#L8'>8</a>
|
|
68
|
-
<a name='L9'></a><a href='#L9'>9</a>
|
|
69
|
-
<a name='L10'></a><a href='#L10'>10</a>
|
|
70
|
-
<a name='L11'></a><a href='#L11'>11</a>
|
|
71
|
-
<a name='L12'></a><a href='#L12'>12</a>
|
|
72
|
-
<a name='L13'></a><a href='#L13'>13</a>
|
|
73
|
-
<a name='L14'></a><a href='#L14'>14</a>
|
|
74
|
-
<a name='L15'></a><a href='#L15'>15</a>
|
|
75
|
-
<a name='L16'></a><a href='#L16'>16</a>
|
|
76
|
-
<a name='L17'></a><a href='#L17'>17</a>
|
|
77
|
-
<a name='L18'></a><a href='#L18'>18</a>
|
|
78
|
-
<a name='L19'></a><a href='#L19'>19</a>
|
|
79
|
-
<a name='L20'></a><a href='#L20'>20</a>
|
|
80
|
-
<a name='L21'></a><a href='#L21'>21</a>
|
|
81
|
-
<a name='L22'></a><a href='#L22'>22</a>
|
|
82
|
-
<a name='L23'></a><a href='#L23'>23</a>
|
|
83
|
-
<a name='L24'></a><a href='#L24'>24</a>
|
|
84
|
-
<a name='L25'></a><a href='#L25'>25</a>
|
|
85
|
-
<a name='L26'></a><a href='#L26'>26</a>
|
|
86
|
-
<a name='L27'></a><a href='#L27'>27</a>
|
|
87
|
-
<a name='L28'></a><a href='#L28'>28</a>
|
|
88
|
-
<a name='L29'></a><a href='#L29'>29</a>
|
|
89
|
-
<a name='L30'></a><a href='#L30'>30</a>
|
|
90
|
-
<a name='L31'></a><a href='#L31'>31</a>
|
|
91
|
-
<a name='L32'></a><a href='#L32'>32</a>
|
|
92
|
-
<a name='L33'></a><a href='#L33'>33</a>
|
|
93
|
-
<a name='L34'></a><a href='#L34'>34</a>
|
|
94
|
-
<a name='L35'></a><a href='#L35'>35</a>
|
|
95
|
-
<a name='L36'></a><a href='#L36'>36</a>
|
|
96
|
-
<a name='L37'></a><a href='#L37'>37</a>
|
|
97
|
-
<a name='L38'></a><a href='#L38'>38</a>
|
|
98
|
-
<a name='L39'></a><a href='#L39'>39</a>
|
|
99
|
-
<a name='L40'></a><a href='#L40'>40</a>
|
|
100
|
-
<a name='L41'></a><a href='#L41'>41</a>
|
|
101
|
-
<a name='L42'></a><a href='#L42'>42</a>
|
|
102
|
-
<a name='L43'></a><a href='#L43'>43</a>
|
|
103
|
-
<a name='L44'></a><a href='#L44'>44</a>
|
|
104
|
-
<a name='L45'></a><a href='#L45'>45</a>
|
|
105
|
-
<a name='L46'></a><a href='#L46'>46</a>
|
|
106
|
-
<a name='L47'></a><a href='#L47'>47</a>
|
|
107
|
-
<a name='L48'></a><a href='#L48'>48</a>
|
|
108
|
-
<a name='L49'></a><a href='#L49'>49</a>
|
|
109
|
-
<a name='L50'></a><a href='#L50'>50</a>
|
|
110
|
-
<a name='L51'></a><a href='#L51'>51</a>
|
|
111
|
-
<a name='L52'></a><a href='#L52'>52</a>
|
|
112
|
-
<a name='L53'></a><a href='#L53'>53</a>
|
|
113
|
-
<a name='L54'></a><a href='#L54'>54</a>
|
|
114
|
-
<a name='L55'></a><a href='#L55'>55</a>
|
|
115
|
-
<a name='L56'></a><a href='#L56'>56</a>
|
|
116
|
-
<a name='L57'></a><a href='#L57'>57</a>
|
|
117
|
-
<a name='L58'></a><a href='#L58'>58</a>
|
|
118
|
-
<a name='L59'></a><a href='#L59'>59</a>
|
|
119
|
-
<a name='L60'></a><a href='#L60'>60</a>
|
|
120
|
-
<a name='L61'></a><a href='#L61'>61</a>
|
|
121
|
-
<a name='L62'></a><a href='#L62'>62</a>
|
|
122
|
-
<a name='L63'></a><a href='#L63'>63</a>
|
|
123
|
-
<a name='L64'></a><a href='#L64'>64</a>
|
|
124
|
-
<a name='L65'></a><a href='#L65'>65</a>
|
|
125
|
-
<a name='L66'></a><a href='#L66'>66</a>
|
|
126
|
-
<a name='L67'></a><a href='#L67'>67</a>
|
|
127
|
-
<a name='L68'></a><a href='#L68'>68</a>
|
|
128
|
-
<a name='L69'></a><a href='#L69'>69</a>
|
|
129
|
-
<a name='L70'></a><a href='#L70'>70</a>
|
|
130
|
-
<a name='L71'></a><a href='#L71'>71</a>
|
|
131
|
-
<a name='L72'></a><a href='#L72'>72</a>
|
|
132
|
-
<a name='L73'></a><a href='#L73'>73</a>
|
|
133
|
-
<a name='L74'></a><a href='#L74'>74</a>
|
|
134
|
-
<a name='L75'></a><a href='#L75'>75</a>
|
|
135
|
-
<a name='L76'></a><a href='#L76'>76</a>
|
|
136
|
-
<a name='L77'></a><a href='#L77'>77</a>
|
|
137
|
-
<a name='L78'></a><a href='#L78'>78</a>
|
|
138
|
-
<a name='L79'></a><a href='#L79'>79</a>
|
|
139
|
-
<a name='L80'></a><a href='#L80'>80</a>
|
|
140
|
-
<a name='L81'></a><a href='#L81'>81</a>
|
|
141
|
-
<a name='L82'></a><a href='#L82'>82</a>
|
|
142
|
-
<a name='L83'></a><a href='#L83'>83</a>
|
|
143
|
-
<a name='L84'></a><a href='#L84'>84</a>
|
|
144
|
-
<a name='L85'></a><a href='#L85'>85</a>
|
|
145
|
-
<a name='L86'></a><a href='#L86'>86</a>
|
|
146
|
-
<a name='L87'></a><a href='#L87'>87</a>
|
|
147
|
-
<a name='L88'></a><a href='#L88'>88</a>
|
|
148
|
-
<a name='L89'></a><a href='#L89'>89</a>
|
|
149
|
-
<a name='L90'></a><a href='#L90'>90</a>
|
|
150
|
-
<a name='L91'></a><a href='#L91'>91</a>
|
|
151
|
-
<a name='L92'></a><a href='#L92'>92</a>
|
|
152
|
-
<a name='L93'></a><a href='#L93'>93</a>
|
|
153
|
-
<a name='L94'></a><a href='#L94'>94</a>
|
|
154
|
-
<a name='L95'></a><a href='#L95'>95</a>
|
|
155
|
-
<a name='L96'></a><a href='#L96'>96</a>
|
|
156
|
-
<a name='L97'></a><a href='#L97'>97</a>
|
|
157
|
-
<a name='L98'></a><a href='#L98'>98</a>
|
|
158
|
-
<a name='L99'></a><a href='#L99'>99</a>
|
|
159
|
-
<a name='L100'></a><a href='#L100'>100</a>
|
|
160
|
-
<a name='L101'></a><a href='#L101'>101</a>
|
|
161
|
-
<a name='L102'></a><a href='#L102'>102</a>
|
|
162
|
-
<a name='L103'></a><a href='#L103'>103</a>
|
|
163
|
-
<a name='L104'></a><a href='#L104'>104</a>
|
|
164
|
-
<a name='L105'></a><a href='#L105'>105</a>
|
|
165
|
-
<a name='L106'></a><a href='#L106'>106</a>
|
|
166
|
-
<a name='L107'></a><a href='#L107'>107</a>
|
|
167
|
-
<a name='L108'></a><a href='#L108'>108</a>
|
|
168
|
-
<a name='L109'></a><a href='#L109'>109</a>
|
|
169
|
-
<a name='L110'></a><a href='#L110'>110</a>
|
|
170
|
-
<a name='L111'></a><a href='#L111'>111</a>
|
|
171
|
-
<a name='L112'></a><a href='#L112'>112</a>
|
|
172
|
-
<a name='L113'></a><a href='#L113'>113</a>
|
|
173
|
-
<a name='L114'></a><a href='#L114'>114</a>
|
|
174
|
-
<a name='L115'></a><a href='#L115'>115</a>
|
|
175
|
-
<a name='L116'></a><a href='#L116'>116</a>
|
|
176
|
-
<a name='L117'></a><a href='#L117'>117</a>
|
|
177
|
-
<a name='L118'></a><a href='#L118'>118</a>
|
|
178
|
-
<a name='L119'></a><a href='#L119'>119</a>
|
|
179
|
-
<a name='L120'></a><a href='#L120'>120</a>
|
|
180
|
-
<a name='L121'></a><a href='#L121'>121</a>
|
|
181
|
-
<a name='L122'></a><a href='#L122'>122</a>
|
|
182
|
-
<a name='L123'></a><a href='#L123'>123</a>
|
|
183
|
-
<a name='L124'></a><a href='#L124'>124</a>
|
|
184
|
-
<a name='L125'></a><a href='#L125'>125</a>
|
|
185
|
-
<a name='L126'></a><a href='#L126'>126</a>
|
|
186
|
-
<a name='L127'></a><a href='#L127'>127</a>
|
|
187
|
-
<a name='L128'></a><a href='#L128'>128</a>
|
|
188
|
-
<a name='L129'></a><a href='#L129'>129</a>
|
|
189
|
-
<a name='L130'></a><a href='#L130'>130</a>
|
|
190
|
-
<a name='L131'></a><a href='#L131'>131</a>
|
|
191
|
-
<a name='L132'></a><a href='#L132'>132</a>
|
|
192
|
-
<a name='L133'></a><a href='#L133'>133</a>
|
|
193
|
-
<a name='L134'></a><a href='#L134'>134</a>
|
|
194
|
-
<a name='L135'></a><a href='#L135'>135</a>
|
|
195
|
-
<a name='L136'></a><a href='#L136'>136</a>
|
|
196
|
-
<a name='L137'></a><a href='#L137'>137</a>
|
|
197
|
-
<a name='L138'></a><a href='#L138'>138</a>
|
|
198
|
-
<a name='L139'></a><a href='#L139'>139</a>
|
|
199
|
-
<a name='L140'></a><a href='#L140'>140</a>
|
|
200
|
-
<a name='L141'></a><a href='#L141'>141</a>
|
|
201
|
-
<a name='L142'></a><a href='#L142'>142</a>
|
|
202
|
-
<a name='L143'></a><a href='#L143'>143</a>
|
|
203
|
-
<a name='L144'></a><a href='#L144'>144</a>
|
|
204
|
-
<a name='L145'></a><a href='#L145'>145</a>
|
|
205
|
-
<a name='L146'></a><a href='#L146'>146</a>
|
|
206
|
-
<a name='L147'></a><a href='#L147'>147</a>
|
|
207
|
-
<a name='L148'></a><a href='#L148'>148</a>
|
|
208
|
-
<a name='L149'></a><a href='#L149'>149</a>
|
|
209
|
-
<a name='L150'></a><a href='#L150'>150</a>
|
|
210
|
-
<a name='L151'></a><a href='#L151'>151</a>
|
|
211
|
-
<a name='L152'></a><a href='#L152'>152</a>
|
|
212
|
-
<a name='L153'></a><a href='#L153'>153</a>
|
|
213
|
-
<a name='L154'></a><a href='#L154'>154</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
214
|
-
<span class="cline-any cline-neutral"> </span>
|
|
215
|
-
<span class="cline-any cline-neutral"> </span>
|
|
216
|
-
<span class="cline-any cline-neutral"> </span>
|
|
217
|
-
<span class="cline-any cline-neutral"> </span>
|
|
218
|
-
<span class="cline-any cline-neutral"> </span>
|
|
219
|
-
<span class="cline-any cline-neutral"> </span>
|
|
220
|
-
<span class="cline-any cline-neutral"> </span>
|
|
221
|
-
<span class="cline-any cline-neutral"> </span>
|
|
222
|
-
<span class="cline-any cline-neutral"> </span>
|
|
223
|
-
<span class="cline-any cline-neutral"> </span>
|
|
224
|
-
<span class="cline-any cline-neutral"> </span>
|
|
225
|
-
<span class="cline-any cline-neutral"> </span>
|
|
226
|
-
<span class="cline-any cline-neutral"> </span>
|
|
227
|
-
<span class="cline-any cline-neutral"> </span>
|
|
228
|
-
<span class="cline-any cline-neutral"> </span>
|
|
229
|
-
<span class="cline-any cline-neutral"> </span>
|
|
230
|
-
<span class="cline-any cline-neutral"> </span>
|
|
231
|
-
<span class="cline-any cline-neutral"> </span>
|
|
232
|
-
<span class="cline-any cline-neutral"> </span>
|
|
233
|
-
<span class="cline-any cline-neutral"> </span>
|
|
234
|
-
<span class="cline-any cline-neutral"> </span>
|
|
235
|
-
<span class="cline-any cline-neutral"> </span>
|
|
236
|
-
<span class="cline-any cline-neutral"> </span>
|
|
237
|
-
<span class="cline-any cline-neutral"> </span>
|
|
238
|
-
<span class="cline-any cline-neutral"> </span>
|
|
239
|
-
<span class="cline-any cline-neutral"> </span>
|
|
240
|
-
<span class="cline-any cline-neutral"> </span>
|
|
241
|
-
<span class="cline-any cline-neutral"> </span>
|
|
242
|
-
<span class="cline-any cline-neutral"> </span>
|
|
243
|
-
<span class="cline-any cline-neutral"> </span>
|
|
244
|
-
<span class="cline-any cline-neutral"> </span>
|
|
245
|
-
<span class="cline-any cline-neutral"> </span>
|
|
246
|
-
<span class="cline-any cline-neutral"> </span>
|
|
247
|
-
<span class="cline-any cline-neutral"> </span>
|
|
248
|
-
<span class="cline-any cline-neutral"> </span>
|
|
249
|
-
<span class="cline-any cline-neutral"> </span>
|
|
250
|
-
<span class="cline-any cline-neutral"> </span>
|
|
251
|
-
<span class="cline-any cline-neutral"> </span>
|
|
252
|
-
<span class="cline-any cline-neutral"> </span>
|
|
253
|
-
<span class="cline-any cline-neutral"> </span>
|
|
254
|
-
<span class="cline-any cline-neutral"> </span>
|
|
255
|
-
<span class="cline-any cline-neutral"> </span>
|
|
256
|
-
<span class="cline-any cline-neutral"> </span>
|
|
257
|
-
<span class="cline-any cline-neutral"> </span>
|
|
258
|
-
<span class="cline-any cline-neutral"> </span>
|
|
259
|
-
<span class="cline-any cline-neutral"> </span>
|
|
260
|
-
<span class="cline-any cline-neutral"> </span>
|
|
261
|
-
<span class="cline-any cline-neutral"> </span>
|
|
262
|
-
<span class="cline-any cline-neutral"> </span>
|
|
263
|
-
<span class="cline-any cline-yes">66x</span>
|
|
264
|
-
<span class="cline-any cline-neutral"> </span>
|
|
265
|
-
<span class="cline-any cline-neutral"> </span>
|
|
266
|
-
<span class="cline-any cline-neutral"> </span>
|
|
267
|
-
<span class="cline-any cline-neutral"> </span>
|
|
268
|
-
<span class="cline-any cline-yes">22x</span>
|
|
269
|
-
<span class="cline-any cline-neutral"> </span>
|
|
270
|
-
<span class="cline-any cline-neutral"> </span>
|
|
271
|
-
<span class="cline-any cline-neutral"> </span>
|
|
272
|
-
<span class="cline-any cline-yes">13x</span>
|
|
273
|
-
<span class="cline-any cline-yes">13x</span>
|
|
274
|
-
<span class="cline-any cline-yes">13x</span>
|
|
275
|
-
<span class="cline-any cline-yes">13x</span>
|
|
276
|
-
<span class="cline-any cline-yes">15x</span>
|
|
277
|
-
<span class="cline-any cline-yes">13x</span>
|
|
278
|
-
<span class="cline-any cline-neutral"> </span>
|
|
279
|
-
<span class="cline-any cline-yes">13x</span>
|
|
280
|
-
<span class="cline-any cline-yes">13x</span>
|
|
281
|
-
<span class="cline-any cline-neutral"> </span>
|
|
282
|
-
<span class="cline-any cline-yes">13x</span>
|
|
283
|
-
<span class="cline-any cline-yes">1x</span>
|
|
284
|
-
<span class="cline-any cline-yes">1x</span>
|
|
285
|
-
<span class="cline-any cline-yes">1x</span>
|
|
286
|
-
<span class="cline-any cline-neutral"> </span>
|
|
287
|
-
<span class="cline-any cline-yes">12x</span>
|
|
288
|
-
<span class="cline-any cline-yes">12x</span>
|
|
289
|
-
<span class="cline-any cline-neutral"> </span>
|
|
290
|
-
<span class="cline-any cline-yes">12x</span>
|
|
291
|
-
<span class="cline-any cline-yes">1x</span>
|
|
292
|
-
<span class="cline-any cline-yes">1x</span>
|
|
293
|
-
<span class="cline-any cline-yes">1x</span>
|
|
294
|
-
<span class="cline-any cline-neutral"> </span>
|
|
295
|
-
<span class="cline-any cline-yes">11x</span>
|
|
296
|
-
<span class="cline-any cline-yes">11x</span>
|
|
297
|
-
<span class="cline-any cline-neutral"> </span>
|
|
298
|
-
<span class="cline-any cline-yes">11x</span>
|
|
299
|
-
<span class="cline-any cline-yes">23x</span>
|
|
300
|
-
<span class="cline-any cline-neutral"> </span>
|
|
301
|
-
<span class="cline-any cline-yes">11x</span>
|
|
302
|
-
<span class="cline-any cline-yes">25x</span>
|
|
303
|
-
<span class="cline-any cline-neutral"> </span>
|
|
304
|
-
<span class="cline-any cline-neutral"> </span>
|
|
305
|
-
<span class="cline-any cline-yes">11x</span>
|
|
306
|
-
<span class="cline-any cline-yes">23x</span>
|
|
307
|
-
<span class="cline-any cline-yes">42x</span>
|
|
308
|
-
<span class="cline-any cline-yes">11x</span>
|
|
309
|
-
<span class="cline-any cline-neutral"> </span>
|
|
310
|
-
<span class="cline-any cline-neutral"> </span>
|
|
311
|
-
<span class="cline-any cline-yes">11x</span>
|
|
312
|
-
<span class="cline-any cline-yes">25x</span>
|
|
313
|
-
<span class="cline-any cline-yes">46x</span>
|
|
314
|
-
<span class="cline-any cline-yes">11x</span>
|
|
315
|
-
<span class="cline-any cline-neutral"> </span>
|
|
316
|
-
<span class="cline-any cline-yes">11x</span>
|
|
317
|
-
<span class="cline-any cline-yes">2x</span>
|
|
318
|
-
<span class="cline-any cline-yes">2x</span>
|
|
319
|
-
<span class="cline-any cline-yes">2x</span>
|
|
320
|
-
<span class="cline-any cline-neutral"> </span>
|
|
321
|
-
<span class="cline-any cline-neutral"> </span>
|
|
322
|
-
<span class="cline-any cline-yes">9x</span>
|
|
323
|
-
<span class="cline-any cline-yes">5x</span>
|
|
324
|
-
<span class="cline-any cline-yes">5x</span>
|
|
325
|
-
<span class="cline-any cline-yes">10x</span>
|
|
326
|
-
<span class="cline-any cline-yes">5x</span>
|
|
327
|
-
<span class="cline-any cline-yes">5x</span>
|
|
328
|
-
<span class="cline-any cline-yes">10x</span>
|
|
329
|
-
<span class="cline-any cline-yes">5x</span>
|
|
330
|
-
<span class="cline-any cline-neutral"> </span>
|
|
331
|
-
<span class="cline-any cline-yes">5x</span>
|
|
332
|
-
<span class="cline-any cline-yes">1x</span>
|
|
333
|
-
<span class="cline-any cline-neutral"> </span>
|
|
334
|
-
<span class="cline-any cline-neutral"> </span>
|
|
335
|
-
<span class="cline-any cline-neutral"> </span>
|
|
336
|
-
<span class="cline-any cline-yes">8x</span>
|
|
337
|
-
<span class="cline-any cline-yes">2x</span>
|
|
338
|
-
<span class="cline-any cline-neutral"> </span>
|
|
339
|
-
<span class="cline-any cline-neutral"> </span>
|
|
340
|
-
<span class="cline-any cline-yes">6x</span>
|
|
341
|
-
<span class="cline-any cline-yes">6x</span>
|
|
342
|
-
<span class="cline-any cline-neutral"> </span>
|
|
343
|
-
<span class="cline-any cline-neutral"> </span>
|
|
344
|
-
<span class="cline-any cline-yes">6x</span>
|
|
345
|
-
<span class="cline-any cline-yes">3x</span>
|
|
346
|
-
<span class="cline-any cline-yes">3x</span>
|
|
347
|
-
<span class="cline-any cline-yes">3x</span>
|
|
348
|
-
<span class="cline-any cline-neutral"> </span>
|
|
349
|
-
<span class="cline-any cline-neutral"> </span>
|
|
350
|
-
<span class="cline-any cline-neutral"> </span>
|
|
351
|
-
<span class="cline-any cline-yes">26x</span>
|
|
352
|
-
<span class="cline-any cline-yes">29x</span>
|
|
353
|
-
<span class="cline-any cline-no"> </span>
|
|
354
|
-
<span class="cline-any cline-neutral"> </span>
|
|
355
|
-
<span class="cline-any cline-yes">29x</span>
|
|
356
|
-
<span class="cline-any cline-neutral"> </span>
|
|
357
|
-
<span class="cline-any cline-yes">26x</span>
|
|
358
|
-
<span class="cline-any cline-neutral"> </span>
|
|
359
|
-
<span class="cline-any cline-neutral"> </span>
|
|
360
|
-
<span class="cline-any cline-neutral"> </span>
|
|
361
|
-
<span class="cline-any cline-neutral"> </span>
|
|
362
|
-
<span class="cline-any cline-yes">48x</span>
|
|
363
|
-
<span class="cline-any cline-yes">48x</span>
|
|
364
|
-
<span class="cline-any cline-neutral"> </span>
|
|
365
|
-
<span class="cline-any cline-neutral"> </span>
|
|
366
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/**
|
|
367
|
-
*
|
|
368
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
369
|
-
*
|
|
370
|
-
* Merge MARC records
|
|
371
|
-
*
|
|
372
|
-
* Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
|
|
373
|
-
*
|
|
374
|
-
* This file is part of marc-record-merge-js
|
|
375
|
-
|
|
376
|
-
* marc-record-merge-js program is free software: you can redistribute it and/or modify
|
|
377
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
378
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
379
|
-
* License, or (at your option) any later version.
|
|
380
|
-
*
|
|
381
|
-
* marc-record-merge-js is distributed in the hope that it will be useful,
|
|
382
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
383
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
384
|
-
* GNU Lesser General Public License for more details.
|
|
385
|
-
*
|
|
386
|
-
* You should have received a copy of the GNU Lesser General Public License
|
|
387
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
388
|
-
*
|
|
389
|
-
* @licend The above is the entire license notice
|
|
390
|
-
* for the JavaScript code in this file.
|
|
391
|
-
*
|
|
392
|
-
*/
|
|
393
|
-
/**
|
|
394
|
-
* Test 01: The field is a control field (contains 'value') --> error message
|
|
395
|
-
* Test 02: If there are multiple fields, return base
|
|
396
|
-
* Test 03: Base and source tags are equal for one field --> return base
|
|
397
|
-
* Test 04: Base and source tags are not equal --> return base
|
|
398
|
-
* Note: to test for this, tagPattern has to allow two tags,
|
|
399
|
-
* otherwise the unequal tag does not even pass source.get(tagPattern)
|
|
400
|
-
* Test 05: Normalize subfield values (base and source are equal) --> return base
|
|
401
|
-
* Test 06: Two subfields, both equal --> return base
|
|
402
|
-
* Test 07: Two subfields, same codes, values of source are subsets of values of base --> replaceBasefieldWithSourcefield
|
|
403
|
-
* Test 08: Two subfields, one is a subset, one has a different code --> return base
|
|
404
|
-
* Test 09: Two subfields, same codes, values are not subsets --> return base
|
|
405
|
-
* Test 10: sourceField is a proper superset of baseField (subfields a and b are equal, c is new) --> replaceBasefieldWithSourcefield
|
|
406
|
-
* Test 11: sourceField is not a proper superset of baseField (different values in a and b, also new subfield c) --> return base
|
|
407
|
-
* Test 12: sourceField is a proper superset of baseField (base values a and b are subsets of source values a and b, c is new in source) --> replaceBasefieldWithSourcefield
|
|
408
|
-
* Test 13: Opposite of test 12, baseField is a proper superset of sourceField --> return base
|
|
409
|
-
* Test 14: Normalization test with Cyrillic characters
|
|
410
|
-
*/
|
|
411
|
-
|
|
412
|
-
import {normalizeSync} from 'normalize-diacritics';
|
|
413
|
-
import createDebugLogger from 'debug';
|
|
414
|
-
|
|
415
|
-
export function strictEquality(subfieldA, subfieldB) {
|
|
416
|
-
return subfieldA.code === subfieldB.code &&
|
|
417
|
-
subfieldA.value === subfieldB.value;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
export function subsetEquality(subfieldA, subfieldB) {
|
|
421
|
-
return subfieldA.code === subfieldB.code &&
|
|
422
|
-
(subfieldA.value.indexOf(subfieldB.value) !== -1 || subfieldB.value.indexOf(subfieldA.value) !== -1);
|
|
423
|
-
}
|
|
424
|
-
// EqualityFunction can be either strictEquality or subsetEquality
|
|
425
|
-
export default ({tagPattern, equalityFunction = strictEquality}) => (base, source) => {
|
|
426
|
-
const debug = createDebugLogger('@natlibfi/marc-record-merge');
|
|
427
|
-
const baseFields = base.get(tagPattern);
|
|
428
|
-
const sourceFields = source.get(tagPattern);
|
|
429
|
-
const fieldTag = sourceFields.map(field => field.tag);
|
|
430
|
-
debug(`Comparing field ${fieldTag}`);
|
|
431
|
-
|
|
432
|
-
checkFieldType(baseFields);
|
|
433
|
-
checkFieldType(sourceFields);
|
|
434
|
-
|
|
435
|
-
if (baseFields.length > 1 || sourceFields.length > 1) {
|
|
436
|
-
debug(`Multiple fields in base or source`);
|
|
437
|
-
debug(`No changes to base`);
|
|
438
|
-
return base;
|
|
439
|
-
}
|
|
440
|
-
const [baseField] = baseFields;
|
|
441
|
-
const [sourceField] = sourceFields;
|
|
442
|
-
|
|
443
|
-
if (baseField.tag === sourceField.tag === false) {
|
|
444
|
-
debug(`Base tag ${baseField.tag} is not equal to source tag ${sourceField.tag}`);
|
|
445
|
-
debug(`No changes to base`);
|
|
446
|
-
return base;
|
|
447
|
-
}
|
|
448
|
-
const baseSubs = baseField.subfields;
|
|
449
|
-
const sourceSubs = sourceField.subfields;
|
|
450
|
-
|
|
451
|
-
const baseSubsNormalized = baseSubs
|
|
452
|
-
.map(({code, value}) => ({code, value: normalizeSubfieldValue(value)}));
|
|
453
|
-
|
|
454
|
-
const sourceSubsNormalized = sourceSubs
|
|
455
|
-
.map(({code, value}) => ({code, value: normalizeSubfieldValue(value)}));
|
|
456
|
-
|
|
457
|
-
// Returns the base subfields for which a matching source subfield is found
|
|
458
|
-
const equalSubfieldsBase = baseSubsNormalized
|
|
459
|
-
.filter(baseSubfield => sourceSubsNormalized
|
|
460
|
-
.some(sourceSubfield => equalityFunction(baseSubfield, sourceSubfield)));
|
|
461
|
-
debug(`equalSubfieldsBase: ${JSON.stringify(equalSubfieldsBase, undefined, 2)}`);
|
|
462
|
-
|
|
463
|
-
// Returns the source subfields for which a matching base subfield is found
|
|
464
|
-
const equalSubfieldsSource = sourceSubsNormalized
|
|
465
|
-
.filter(sourceSubfield => baseSubsNormalized
|
|
466
|
-
.some(baseSubfield => equalityFunction(sourceSubfield, baseSubfield)));
|
|
467
|
-
debug(`equalSubfieldsSource: ${JSON.stringify(equalSubfieldsSource, undefined, 2)}`);
|
|
468
|
-
|
|
469
|
-
if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length < baseSubs.length) {
|
|
470
|
-
debug(`Base and source subfields are not equal`);
|
|
471
|
-
debug(`No changes to base`);
|
|
472
|
-
return base;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length === equalSubfieldsSource.length) {
|
|
476
|
-
debug(`Checking subfield equality`);
|
|
477
|
-
const totalSubfieldLengthBase = baseSubsNormalized
|
|
478
|
-
.map(({value}) => value.length)
|
|
479
|
-
.reduce((acc, value) => acc + value);
|
|
480
|
-
const totalSubfieldLengthSource = sourceSubsNormalized
|
|
481
|
-
.map(({value}) => value.length)
|
|
482
|
-
.reduce((acc, value) => acc + value);
|
|
483
|
-
|
|
484
|
-
if (totalSubfieldLengthSource > totalSubfieldLengthBase) {
|
|
485
|
-
return replaceBasefieldWithSourcefield(base);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
if (sourceSubs.length > baseSubs.length && equalSubfieldsBase.length === baseSubs.length) {
|
|
490
|
-
return replaceBasefieldWithSourcefield(base);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
debug(`No changes to base`);
|
|
494
|
-
return base;
|
|
495
|
-
|
|
496
|
-
function replaceBasefieldWithSourcefield(base) {
|
|
497
|
-
const index = base.fields.findIndex(field => field === baseField);
|
|
498
|
-
base.fields.splice(index, 1, sourceField); // eslint-disable-line functional/immutable-data
|
|
499
|
-
debug(`Source field is longer, replacing base with source`);
|
|
500
|
-
return base;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function checkFieldType(fields) {
|
|
504
|
-
const checkedFields = fields.map(field => {
|
|
505
|
-
<span class="missing-if-branch" title="if path not taken" >I</span>if ('value' in field) { // eslint-disable-line functional/no-conditional-statement
|
|
506
|
-
<span class="cstat-no" title="statement not covered" > throw new Error('Invalid control field, expected data field');</span>
|
|
507
|
-
}
|
|
508
|
-
return field;
|
|
509
|
-
});
|
|
510
|
-
return checkedFields;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
function normalizeSubfieldValue(value) {
|
|
514
|
-
// Regexp options: g: global search, u: unicode
|
|
515
|
-
const punctuation = /[.,\-/#!?$%^&*;:{}=_`~()[\]]/gu;
|
|
516
|
-
return normalizeSync(value).toLowerCase().replace(punctuation, '', 'u').replace(/\s+/gu, ' ').trim();
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
</pre></td></tr></table></pre>
|
|
520
|
-
|
|
521
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
522
|
-
</div><!-- /wrapper -->
|
|
523
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
524
|
-
Code coverage generated by
|
|
525
|
-
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
526
|
-
at Thu Jun 17 2021 11:16:46 GMT+0000 (Coordinated Universal Time)
|
|
527
|
-
</div>
|
|
528
|
-
</div>
|
|
529
|
-
<script src="prettify.js"></script>
|
|
530
|
-
<script>
|
|
531
|
-
window.onload = function () {
|
|
532
|
-
prettyPrint();
|
|
533
|
-
};
|
|
534
|
-
</script>
|
|
535
|
-
<script src="sorter.js"></script>
|
|
536
|
-
<script src="block-navigation.js"></script>
|
|
537
|
-
</body>
|
|
538
|
-
</html>
|
|
539
|
-
|
|
Binary file
|