uppy/packages/@uppy/utils/src/getETA.js
2021-08-10 16:06:49 +02:00

12 lines
403 B
JavaScript

const getSpeed = require('./getSpeed')
const getBytesRemaining = require('./getBytesRemaining')
module.exports = function getETA (fileProgress) {
if (!fileProgress.bytesUploaded) return 0
const uploadSpeed = getSpeed(fileProgress)
const bytesRemaining = getBytesRemaining(fileProgress)
const secondsRemaining = Math.round((bytesRemaining / uploadSpeed) * 10) / 10
return secondsRemaining
}