UNPKG

401 BJavaScriptView Raw
1const getSpeed = require('./getSpeed')
2const getBytesRemaining = require('./getBytesRemaining')
3
4module.exports = function getETA (fileProgress) {
5 if (!fileProgress.bytesUploaded) return 0
6
7 const uploadSpeed = getSpeed(fileProgress)
8 const bytesRemaining = getBytesRemaining(fileProgress)
9 const secondsRemaining = Math.round(bytesRemaining / uploadSpeed * 10) / 10
10
11 return secondsRemaining
12}