csstats-reader
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "csstats-reader", | ||
"displayName": "csstats-reader", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Node.js package for parse AMX Mod X Stats File.", | ||
@@ -6,0 +6,0 @@ "author": "Giovani de Oliveira <giovanioliveira@outlook.com.br>", |
@@ -18,4 +18,15 @@ const { CSStatsService } = require('../services'); | ||
} | ||
/** | ||
* Parse csstats.dat and return top 10 | ||
* | ||
* @param {string} path csstats.dat path | ||
* | ||
* @returns {Promise} return Promise | ||
*/ | ||
async top(path) { | ||
return this._service.top(path); | ||
} | ||
} | ||
module.exports = CSStatsController; |
@@ -56,4 +56,13 @@ const fs = require('fs'); | ||
} | ||
async top(path) { | ||
const stats = await this.parse(path); | ||
const players = stats.sort((a, b) => ((a.kills < b.kills) ? 1 : -1)); | ||
const length = players.length >= 10 ? 9 : players.length; | ||
return players.slice(0, length); | ||
} | ||
} | ||
module.exports = CSStats; |
41840
125