@vbarbarosh/node-helpers 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/eta.js +12 -0
- package/src/http_get_stream.js +8 -0
package/package.json
CHANGED
package/src/eta.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const format_seconds = require('./format_seconds');
|
|
2
|
+
|
|
3
|
+
function eta(time0, total, done, resumed = 0)
|
|
4
|
+
{
|
|
5
|
+
const seconds = (Date.now() - time0)/1000;
|
|
6
|
+
const xdone = done - resumed;
|
|
7
|
+
const xtotal = total - resumed;
|
|
8
|
+
const bps = xdone/seconds;
|
|
9
|
+
return format_seconds(xtotal/bps);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = eta;
|