23 lines
622 B
JavaScript
23 lines
622 B
JavaScript
import fs from 'fs'
|
|
import msgpack from '@msgpack/msgpack'
|
|
|
|
/**
|
|
* This module parses the msgpack provided by DDNet...
|
|
* @module libs/database/sqlite2mongo/decodeMsgpack
|
|
*/
|
|
export default function decodeMsgpack() {
|
|
const data = fs.readFileSync('players.msgpack')
|
|
const decoded = msgpack.decodeMulti(data, {wrap: true})
|
|
const order = ['categories', 'maps', 'totalPoints', 'pointsRanks', 'pointsThisWeek', 'pointsThisMonth', 'teamRankPoints', 'rankPoints', 'serverRanks']
|
|
let final = {}
|
|
|
|
let i = 0
|
|
for (const part of decoded) {
|
|
final[order[i]] = part
|
|
++i
|
|
}
|
|
|
|
return final
|
|
}
|
|
|