@@ -8,16 +8,14 @@ function Net(sparkline) {
88 this . netData = [ Array ( 61 ) . fill ( 0 ) , Array ( 61 ) . fill ( 0 ) ] ;
99
1010 si . networkInterfaceDefault ( iface => {
11- this . defaultIface = iface ;
12- si . networkStats ( iface , data => {
13- this . updateData ( data ) ;
14- } ) ;
15-
16- this . interval = setInterval ( ( ) => {
11+ var that = this ;
12+ var updater = function ( ) {
1713 si . networkStats ( iface , data => {
18- this . updateData ( data ) ;
19- } )
20- } , 1000 ) ;
14+ that . updateData ( data [ 0 ] ) ;
15+ } ) ;
16+ }
17+ updater ( ) ;
18+ this . interval = setInterval ( updater , 1000 ) ;
2119 } )
2220}
2321
@@ -35,12 +33,12 @@ Net.prototype.updateData = function(data) {
3533 rx_label = 'Receiving: ' +
3634 utils . humanFileSize ( rx_sec ) +
3735 '/s \nTotal received: ' +
38- utils . humanFileSize ( data [ 'rx ' ] ) ;
36+ utils . humanFileSize ( data [ 'rx_bytes ' ] ) ;
3937
4038 tx_label = 'Transferring: ' +
4139 utils . humanFileSize ( tx_sec ) +
4240 '/s \nTotal transferred: ' +
43- utils . humanFileSize ( data [ 'tx ' ] ) ;
41+ utils . humanFileSize ( data [ 'tx_bytes ' ] ) ;
4442
4543 this . sparkline . setData ( [ rx_label , tx_label ] , this . netData ) ;
4644 this . sparkline . screen . render ( ) ;
0 commit comments