Minetrack/lib/time.js
2020-05-08 01:27:21 -05:00

26 lines
451 B
JavaScript

const SERVER_GRAPH_DATA_MAX_LENGTH = require('./servers').SERVER_GRAPH_DATA_MAX_LENGTH
class TimeTracker {
constructor () {
this._points = []
}
newTimestamp () {
const timestamp = new Date().getTime()
this._points.push(timestamp)
if (this._points.length > SERVER_GRAPH_DATA_MAX_LENGTH) {
this._points.shift()
}
return timestamp
}
getPoints () {
return this._points
}
}
module.exports = TimeTracker