Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@filerobot/core / lib / utils / calculateTotalEta.js
Size: Mime:
import getBytesRemaining from '@filerobot/utils/lib/getBytesRemaining';
import getSpeed from '@filerobot/utils/lib/getSpeed';
var getTotalSpeed = function getTotalSpeed(files) {
  return files.reduce(function (total, file) {
    return total + getSpeed(file.progress);
  }, 0);
};

// Eta (ETA) = Estimated Time of Arrival to finish operations in seconds
// TODO: add ETA also for Download and Transformation operations when they are ready
var calculateTotalEta = function calculateTotalEta(files) {
  var totalSpeed = getTotalSpeed(files);
  if (totalSpeed === 0) {
    return 0;
  }
  var totalBytesRemaining = getBytesRemaining(files);
  if (totalBytesRemaining && totalSpeed) {
    // ETA = Distance/Speed
    return Math.round(totalBytesRemaining / totalSpeed * 10) / 10;
  }
};
export default calculateTotalEta;