getETA.js 435 B

123456789101112131415
  1. "use strict";
  2. const getSpeed = require("./getSpeed.js");
  3. const getBytesRemaining = require("./getBytesRemaining.js");
  4. function getETA(fileProgress) {
  5. if (!fileProgress.bytesUploaded) return 0;
  6. const uploadSpeed = getSpeed(fileProgress);
  7. const bytesRemaining = getBytesRemaining(fileProgress);
  8. const secondsRemaining = Math.round(bytesRemaining / uploadSpeed * 10) / 10;
  9. return secondsRemaining;
  10. }
  11. module.exports = getETA;