getSpeed.js 281 B

12345678910
  1. "use strict";
  2. function getSpeed(fileProgress) {
  3. if (!fileProgress.bytesUploaded) return 0;
  4. const timeElapsed = Date.now() - fileProgress.uploadStarted;
  5. const uploadSpeed = fileProgress.bytesUploaded / (timeElapsed / 1000);
  6. return uploadSpeed;
  7. }
  8. module.exports = getSpeed;