@vbarbarosh/node-helpers 3.4.0 → 3.4.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/eta.js +12 -0
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Vladimir Barbarosh <vladimir.barbarosh@gmail.com>",
3
3
  "license": "MIT",
4
4
  "name": "@vbarbarosh/node-helpers",
5
- "version": "3.4.0",
5
+ "version": "3.4.1",
6
6
  "description": "A set of helpers for JavaScript/Node.js",
7
7
  "files": [
8
8
  "src"
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;