Added user point merging utility.

This commit is contained in:
ThePendulum
2024-03-08 00:49:37 +01:00
parent d510caa123
commit bad5dc52f7
2 changed files with 35 additions and 0 deletions

View File

@@ -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();