mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-16 15:40:49 +00:00
fix: metrics stats and moving averages types (#915)
* fix: give stats initial values Otherwise the compiler cannot derive the type and thinks `stats.snapshot` returns `{}` * fix: add type shape to moving averages as well
This commit is contained in:
parent
55ee332907
commit
3d0a79eff3
@ -2,7 +2,7 @@
|
||||
'use strict'
|
||||
|
||||
const EventEmitter = require('events')
|
||||
const Big = require('bignumber.js')
|
||||
const { BigNumber: Big } = require('bignumber.js')
|
||||
const MovingAverage = require('moving-average')
|
||||
const retimer = require('retimer')
|
||||
|
||||
@ -19,11 +19,17 @@ class Stats extends EventEmitter {
|
||||
|
||||
this._options = options
|
||||
this._queue = []
|
||||
this._stats = {}
|
||||
|
||||
/** @type {{ dataReceived: Big, dataSent: Big }} */
|
||||
this._stats = {
|
||||
dataReceived: Big(0),
|
||||
dataSent: Big(0)
|
||||
}
|
||||
|
||||
this._frequencyLastTime = Date.now()
|
||||
this._frequencyAccumulators = {}
|
||||
|
||||
/** @type {{ dataReceived: MovingAverage[], dataSent: MovingAverage[] }} */
|
||||
this._movingAverages = {}
|
||||
|
||||
this._update = this._update.bind(this)
|
||||
|
Loading…
x
Reference in New Issue
Block a user