uppy/packages/@uppy/utils/src/getSpeed.js

7 lines
254 B
JavaScript

module.exports = function getSpeed (fileProgress) {
if (!fileProgress.bytesUploaded) return 0
const timeElapsed = Date.now() - fileProgress.uploadStarted
const uploadSpeed = fileProgress.bytesUploaded / (timeElapsed / 1000)
return uploadSpeed
}