use a single, shared timestamps array between all pings
This commit is contained in:
23
lib/time.js
Normal file
23
lib/time.js
Normal file
@ -0,0 +1,23 @@
|
||||
class TimeTracker {
|
||||
constructor () {
|
||||
this._points = []
|
||||
}
|
||||
|
||||
newTimestamp () {
|
||||
const timestamp = new Date().getTime()
|
||||
|
||||
this._points.push(timestamp)
|
||||
|
||||
if (this._points.length > 72) {
|
||||
this._points.shift()
|
||||
}
|
||||
|
||||
return timestamp
|
||||
}
|
||||
|
||||
getPoints () {
|
||||
return this._points
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TimeTracker
|
Reference in New Issue
Block a user