Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uppy/utils

Package Overview
Dependencies
Maintainers
6
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/utils - npm Package Compare versions

Comparing version 5.4.3 to 5.5.0

7

CHANGELOG.md
# @uppy/utils
## 5.5.0
Released: 2023-09-05
Included in: Uppy v3.15.0
- @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/companion-client,@uppy/core,@uppy/tus,@uppy/utils,@uppy/xhr-upload: Move remote file upload logic into companion-client (Merlijn Vos / #4573)
## 5.4.3

@@ -4,0 +11,0 @@

64

lib/EventManager.js
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
var id = 0;
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
var _emitter = /*#__PURE__*/_classPrivateFieldLooseKey("emitter");
var _uppy = /*#__PURE__*/_classPrivateFieldLooseKey("uppy");
var _events = /*#__PURE__*/_classPrivateFieldLooseKey("events");

@@ -11,4 +11,4 @@ /**

export default class EventManager {
constructor(emitter) {
Object.defineProperty(this, _emitter, {
constructor(uppy) {
Object.defineProperty(this, _uppy, {
writable: true,

@@ -21,13 +21,65 @@ value: void 0

});
_classPrivateFieldLooseBase(this, _emitter)[_emitter] = emitter;
_classPrivateFieldLooseBase(this, _uppy)[_uppy] = uppy;
}
on(event, fn) {
_classPrivateFieldLooseBase(this, _events)[_events].push([event, fn]);
return _classPrivateFieldLooseBase(this, _emitter)[_emitter].on(event, fn);
return _classPrivateFieldLooseBase(this, _uppy)[_uppy].on(event, fn);
}
remove() {
for (const [event, fn] of _classPrivateFieldLooseBase(this, _events)[_events].splice(0)) {
_classPrivateFieldLooseBase(this, _emitter)[_emitter].off(event, fn);
_classPrivateFieldLooseBase(this, _uppy)[_uppy].off(event, fn);
}
}
onFilePause(fileID, cb) {
this.on('upload-pause', (targetFileID, isPaused) => {
if (fileID === targetFileID) {
cb(isPaused);
}
});
}
onFileRemove(fileID, cb) {
this.on('file-removed', file => {
if (fileID === file.id) cb(file.id);
});
}
onPause(fileID, cb) {
this.on('upload-pause', (targetFileID, isPaused) => {
if (fileID === targetFileID) {
// const isPaused = this.#uppy.pauseResume(fileID)
cb(isPaused);
}
});
}
onRetry(fileID, cb) {
this.on('upload-retry', targetFileID => {
if (fileID === targetFileID) {
cb();
}
});
}
onRetryAll(fileID, cb) {
this.on('retry-all', () => {
if (!_classPrivateFieldLooseBase(this, _uppy)[_uppy].getFile(fileID)) return;
cb();
});
}
onPauseAll(fileID, cb) {
this.on('pause-all', () => {
if (!_classPrivateFieldLooseBase(this, _uppy)[_uppy].getFile(fileID)) return;
cb();
});
}
onCancelAll(fileID, eventHandler) {
var _this = this;
this.on('cancel-all', function () {
if (!_classPrivateFieldLooseBase(_this, _uppy)[_uppy].getFile(fileID)) return;
eventHandler(...arguments);
});
}
onResumeAll(fileID, cb) {
this.on('resume-all', () => {
if (!_classPrivateFieldLooseBase(this, _uppy)[_uppy].getFile(fileID)) return;
cb();
});
}
}

2

package.json
{
"name": "@uppy/utils",
"description": "Shared utility functions for Uppy Core and plugins maintained by the Uppy team.",
"version": "5.4.3",
"version": "5.5.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "types": "types/index.d.ts",

@@ -6,8 +6,8 @@ /**

export default class EventManager {
#emitter
#uppy
#events = []
constructor (emitter) {
this.#emitter = emitter
constructor (uppy) {
this.#uppy = uppy
}

@@ -17,3 +17,3 @@

this.#events.push([event, fn])
return this.#emitter.on(event, fn)
return this.#uppy.on(event, fn)
}

@@ -23,5 +23,64 @@

for (const [event, fn] of this.#events.splice(0)) {
this.#emitter.off(event, fn)
this.#uppy.off(event, fn)
}
}
onFilePause (fileID, cb) {
this.on('upload-pause', (targetFileID, isPaused) => {
if (fileID === targetFileID) {
cb(isPaused)
}
})
}
onFileRemove (fileID, cb) {
this.on('file-removed', (file) => {
if (fileID === file.id) cb(file.id)
})
}
onPause (fileID, cb) {
this.on('upload-pause', (targetFileID, isPaused) => {
if (fileID === targetFileID) {
// const isPaused = this.#uppy.pauseResume(fileID)
cb(isPaused)
}
})
}
onRetry (fileID, cb) {
this.on('upload-retry', (targetFileID) => {
if (fileID === targetFileID) {
cb()
}
})
}
onRetryAll (fileID, cb) {
this.on('retry-all', () => {
if (!this.#uppy.getFile(fileID)) return
cb()
})
}
onPauseAll (fileID, cb) {
this.on('pause-all', () => {
if (!this.#uppy.getFile(fileID)) return
cb()
})
}
onCancelAll (fileID, eventHandler) {
this.on('cancel-all', (...args) => {
if (!this.#uppy.getFile(fileID)) return
eventHandler(...args)
})
}
onResumeAll (fileID, cb) {
this.on('resume-all', () => {
if (!this.#uppy.getFile(fileID)) return
cb()
})
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc