Repository URL to install this package:
|
Version:
3.12.11 ▾
|
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;