-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontentcodes.js
More file actions
52 lines (44 loc) · 967 Bytes
/
contentcodes.js
File metadata and controls
52 lines (44 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* eslint-disable no-console */
const fs = require('fs');
const contentCodes = require('./contentcodes.json');
const req = JSON.parse(fs.readFileSync('./test/data/content-codes.json', 'utf8'));
const noName = [];
Object.keys(contentCodes).forEach((code) => {
if (!contentCodes[code].name) {
noName.push(code);
}
});
if (noName.length) {
console.log(
`- name missing
${noName.join(', ')}
`
);
}
const add = {};
const notInCC = [];
req.mccr.mdcl.forEach((info) => {
if (info.mcnm === '\u0000\u0000\u0000\u0000') {
return;
}
if (!contentCodes[info.mcnm]) {
notInCC.push(info.mcnm);
add[info.mcnm] = {
name: info.mcna,
type: info.mcty,
};
}
});
if (notInCC.length) {
console.log(
`- not in contentcodes.json
${notInCC.join(', ')}
`
);
let a = Object.assign({}, add, contentCodes);
a = Object.keys(a).sort().reduce((memo, code) => {
memo[code] = a[code];
return memo;
}, {});
console.log(JSON.stringify(a, null, '\t'));
}