Added points merge utility.
This commit is contained in:
parent
aeb405967b
commit
69bc1c9e6e
|
@ -0,0 +1,25 @@
|
|||
const path = require('path');
|
||||
const args = require('yargs').argv;
|
||||
|
||||
function init() {
|
||||
const scoresA = require(path.resolve(__dirname, args.a));
|
||||
const scoresB = require(path.resolve(__dirname, args.b));
|
||||
|
||||
const sum = {};
|
||||
|
||||
[scoresA, scoresB].forEach((record) => {
|
||||
Object.entries(record).forEach(([game, scores]) => {
|
||||
if (!sum[game]) {
|
||||
sum[game] = {};
|
||||
}
|
||||
|
||||
Object.entries(scores).forEach(([id, score]) => {
|
||||
sum[game][id] = (sum[game][id] || 0) + score;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
console.log(JSON.stringify(sum, null, 4));
|
||||
}
|
||||
|
||||
init();
|
Loading…
Reference in New Issue