emitSocketProgress.js 482 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. const throttle = require("lodash.throttle");
  3. function emitSocketProgress(uploader, progressData, file) {
  4. const {
  5. progress,
  6. bytesUploaded,
  7. bytesTotal
  8. } = progressData;
  9. if (progress) {
  10. uploader.uppy.log(`Upload progress: ${progress}`);
  11. uploader.uppy.emit('upload-progress', file, {
  12. uploader,
  13. bytesUploaded,
  14. bytesTotal
  15. });
  16. }
  17. }
  18. module.exports = throttle(emitSocketProgress, 300, {
  19. leading: true,
  20. trailing: true
  21. });