mirror of
https://github.com/transloadit/uppy.git
synced 2026-08-02 06:43:19 +00:00
24 lines
594 B
TypeScript
24 lines
594 B
TypeScript
import throttle from 'lodash/throttle.js'
|
|
import type { UppyFile } from './UppyFile'
|
|
import type { FileProgress } from './FileProgress'
|
|
|
|
function emitSocketProgress(
|
|
uploader: any,
|
|
progressData: FileProgress,
|
|
file: UppyFile<any, any>,
|
|
): void {
|
|
const { progress, bytesUploaded, bytesTotal } = progressData
|
|
if (progress) {
|
|
uploader.uppy.log(`Upload progress: ${progress}`)
|
|
uploader.uppy.emit('upload-progress', file, {
|
|
uploader,
|
|
bytesUploaded,
|
|
bytesTotal,
|
|
})
|
|
}
|
|
}
|
|
|
|
export default throttle(emitSocketProgress, 300, {
|
|
leading: true,
|
|
trailing: true,
|
|
})
|