New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aurelia-files

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aurelia-files - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

LICENSE

117

dist/amd/handlers/file-handler.js

@@ -8,83 +8,70 @@ define(["exports", "../helpers/file-reader-helper"], function (exports, _helpersFileReaderHelper) {

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var FileHandler = (function () {
function FileHandler(onLoaded, onProgress, onError, fileFilter, maxFileSize, readAs, hoverClass) {
_classCallCheck(this, FileHandler);
var FileHandler = function FileHandler(onLoaded, onProgress, onError, fileFilter, maxFileSize, readAs, hoverClass) {
var _this = this;
this.__initializeProperties();
_classCallCheck(this, FileHandler);
this.onLoaded = onLoaded;
this.onProgress = onProgress;
this.onError = onError;
this.fileFilter = fileFilter;
this.maxFileSize = maxFileSize;
this.readAs = readAs;
this.hoverClass = hoverClass || "file-hover";
}
this.readFile = function (file) {
var reader = _helpersFileReaderHelper.FileReaderHelper.createReader(file, _this.onLoaded, _this.onProgress, _this.onError);
_createClass(FileHandler, [{
key: "__initializeProperties",
value: function __initializeProperties() {
var _this = this;
if (_this.readAs == "text") {
reader.readAsText(file);
} else if (_this.readAs == "array") {
reader.readAsArrayBuffer(file);
} else if (_this.readAs == "binary") {
reader.readAsBinaryString(file);
} else {
reader.readAsDataURL(file);
}
};
this.readFile = function (file) {
var reader = _helpersFileReaderHelper.FileReaderHelper.createReader(file, _this.onLoaded, _this.onProgress, _this.onError);
this.handleFileDrag = function (fileDragEvent) {
fileDragEvent.stopPropagation();
fileDragEvent.preventDefault();
if (_this.readAs == "text") {
reader.readAsText(file);
} else if (_this.readAs == "array") {
reader.readAsArrayBuffer(file);
} else if (_this.readAs == "binary") {
reader.readAsBinaryString(file);
} else {
reader.readAsDataURL(file);
}
};
if (fileDragEvent.type == "dragover") {
fileDragEvent.target.classList.add(_this.hoverClass);
} else {
fileDragEvent.target.classList.remove(_this.hoverClass);
}
};
this.handleFileDrag = function (fileDragEvent) {
fileDragEvent.stopPropagation();
fileDragEvent.preventDefault();
this.handleDrop = function (fileDropEvent) {
_this.handleFileDrag(fileDropEvent);
_this.handleFileSelected(fileDropEvent);
};
if (fileDragEvent.type == "dragover") {
fileDragEvent.target.classList.add(_this.hoverClass);
} else {
fileDragEvent.target.classList.remove(_this.hoverClass);
this.handleFileSelected = function (fileSelectionEvent) {
var files = fileSelectionEvent.target.files || fileSelectionEvent.dataTransfer.files;
for (var i = 0, f = undefined; f = files[i]; i++) {
if (_this.fileFilter && !f.type.match(_this.fileFilter)) {
if (_this.onError) {
_this.onError(f, "File type does not match filter");
}
};
continue;
}
this.handleDrop = function (fileDropEvent) {
_this.handleFileDrag(fileDropEvent);
_this.handleFileSelected(fileDropEvent);
};
if (_this.maxFileSize && f.size >= _this.maxFileSize) {
if (_this.onError) {
_this.onError(f, "File exceeds file size limit");
}
continue;
}
this.handleFileSelected = function (fileSelectionEvent) {
var files = fileSelectionEvent.target.files || fileSelectionEvent.dataTransfer.files;
for (var i = 0, f = undefined; f = files[i]; i++) {
if (_this.fileFilter && !f.type.match(_this.fileFilter)) {
if (_this.onError) {
_this.onError(f, "File type does not match filter");
}
continue;
}
if (_this.maxFileSize && f.size >= _this.maxFileSize) {
if (onError) {
_this.onError(f, "File exceeds file size limit");
}
continue;
}
_this.readFile(f);
}
};
_this.readFile(f);
}
}]);
};
return FileHandler;
})();
this.onLoaded = onLoaded;
this.onProgress = onProgress;
this.onError = onError;
this.fileFilter = fileFilter;
this.maxFileSize = maxFileSize;
this.readAs = readAs;
this.hoverClass = hoverClass || "file-hover";
};
exports.FileHandler = FileHandler;
});

@@ -7,4 +7,2 @@ "use strict";

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -14,78 +12,67 @@

var FileHandler = (function () {
function FileHandler(onLoaded, onProgress, onError, fileFilter, maxFileSize, readAs, hoverClass) {
_classCallCheck(this, FileHandler);
var FileHandler = function FileHandler(onLoaded, onProgress, onError, fileFilter, maxFileSize, readAs, hoverClass) {
var _this = this;
this.__initializeProperties();
_classCallCheck(this, FileHandler);
this.onLoaded = onLoaded;
this.onProgress = onProgress;
this.onError = onError;
this.fileFilter = fileFilter;
this.maxFileSize = maxFileSize;
this.readAs = readAs;
this.hoverClass = hoverClass || "file-hover";
}
this.readFile = function (file) {
var reader = _helpersFileReaderHelper.FileReaderHelper.createReader(file, _this.onLoaded, _this.onProgress, _this.onError);
_createClass(FileHandler, [{
key: "__initializeProperties",
value: function __initializeProperties() {
var _this = this;
if (_this.readAs == "text") {
reader.readAsText(file);
} else if (_this.readAs == "array") {
reader.readAsArrayBuffer(file);
} else if (_this.readAs == "binary") {
reader.readAsBinaryString(file);
} else {
reader.readAsDataURL(file);
}
};
this.readFile = function (file) {
var reader = _helpersFileReaderHelper.FileReaderHelper.createReader(file, _this.onLoaded, _this.onProgress, _this.onError);
this.handleFileDrag = function (fileDragEvent) {
fileDragEvent.stopPropagation();
fileDragEvent.preventDefault();
if (_this.readAs == "text") {
reader.readAsText(file);
} else if (_this.readAs == "array") {
reader.readAsArrayBuffer(file);
} else if (_this.readAs == "binary") {
reader.readAsBinaryString(file);
} else {
reader.readAsDataURL(file);
}
};
if (fileDragEvent.type == "dragover") {
fileDragEvent.target.classList.add(_this.hoverClass);
} else {
fileDragEvent.target.classList.remove(_this.hoverClass);
}
};
this.handleFileDrag = function (fileDragEvent) {
fileDragEvent.stopPropagation();
fileDragEvent.preventDefault();
this.handleDrop = function (fileDropEvent) {
_this.handleFileDrag(fileDropEvent);
_this.handleFileSelected(fileDropEvent);
};
if (fileDragEvent.type == "dragover") {
fileDragEvent.target.classList.add(_this.hoverClass);
} else {
fileDragEvent.target.classList.remove(_this.hoverClass);
this.handleFileSelected = function (fileSelectionEvent) {
var files = fileSelectionEvent.target.files || fileSelectionEvent.dataTransfer.files;
for (var i = 0, f = undefined; f = files[i]; i++) {
if (_this.fileFilter && !f.type.match(_this.fileFilter)) {
if (_this.onError) {
_this.onError(f, "File type does not match filter");
}
};
continue;
}
this.handleDrop = function (fileDropEvent) {
_this.handleFileDrag(fileDropEvent);
_this.handleFileSelected(fileDropEvent);
};
if (_this.maxFileSize && f.size >= _this.maxFileSize) {
if (_this.onError) {
_this.onError(f, "File exceeds file size limit");
}
continue;
}
this.handleFileSelected = function (fileSelectionEvent) {
var files = fileSelectionEvent.target.files || fileSelectionEvent.dataTransfer.files;
for (var i = 0, f = undefined; f = files[i]; i++) {
if (_this.fileFilter && !f.type.match(_this.fileFilter)) {
if (_this.onError) {
_this.onError(f, "File type does not match filter");
}
continue;
}
if (_this.maxFileSize && f.size >= _this.maxFileSize) {
if (onError) {
_this.onError(f, "File exceeds file size limit");
}
continue;
}
_this.readFile(f);
}
};
_this.readFile(f);
}
}]);
};
return FileHandler;
})();
this.onLoaded = onLoaded;
this.onProgress = onProgress;
this.onError = onError;
this.fileFilter = fileFilter;
this.maxFileSize = maxFileSize;
this.readAs = readAs;
this.hoverClass = hoverClass || "file-hover";
};
exports.FileHandler = FileHandler;

@@ -59,3 +59,3 @@ import {FileReaderHelper} from "../helpers/file-reader-helper"

{
if(onError)
if(this.onError)
{ this.onError(f, "File exceeds file size limit"); }

@@ -62,0 +62,0 @@ continue;

@@ -6,4 +6,2 @@ System.register(["../helpers/file-reader-helper"], function (_export) {

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -16,77 +14,66 @@

execute: function () {
FileHandler = (function () {
function FileHandler(onLoaded, onProgress, onError, fileFilter, maxFileSize, readAs, hoverClass) {
_classCallCheck(this, FileHandler);
FileHandler = function FileHandler(onLoaded, onProgress, onError, fileFilter, maxFileSize, readAs, hoverClass) {
var _this = this;
this.__initializeProperties();
_classCallCheck(this, FileHandler);
this.onLoaded = onLoaded;
this.onProgress = onProgress;
this.onError = onError;
this.fileFilter = fileFilter;
this.maxFileSize = maxFileSize;
this.readAs = readAs;
this.hoverClass = hoverClass || "file-hover";
}
this.readFile = function (file) {
var reader = FileReaderHelper.createReader(file, _this.onLoaded, _this.onProgress, _this.onError);
_createClass(FileHandler, [{
key: "__initializeProperties",
value: function __initializeProperties() {
var _this = this;
if (_this.readAs == "text") {
reader.readAsText(file);
} else if (_this.readAs == "array") {
reader.readAsArrayBuffer(file);
} else if (_this.readAs == "binary") {
reader.readAsBinaryString(file);
} else {
reader.readAsDataURL(file);
}
};
this.readFile = function (file) {
var reader = FileReaderHelper.createReader(file, _this.onLoaded, _this.onProgress, _this.onError);
this.handleFileDrag = function (fileDragEvent) {
fileDragEvent.stopPropagation();
fileDragEvent.preventDefault();
if (_this.readAs == "text") {
reader.readAsText(file);
} else if (_this.readAs == "array") {
reader.readAsArrayBuffer(file);
} else if (_this.readAs == "binary") {
reader.readAsBinaryString(file);
} else {
reader.readAsDataURL(file);
}
};
if (fileDragEvent.type == "dragover") {
fileDragEvent.target.classList.add(_this.hoverClass);
} else {
fileDragEvent.target.classList.remove(_this.hoverClass);
}
};
this.handleFileDrag = function (fileDragEvent) {
fileDragEvent.stopPropagation();
fileDragEvent.preventDefault();
this.handleDrop = function (fileDropEvent) {
_this.handleFileDrag(fileDropEvent);
_this.handleFileSelected(fileDropEvent);
};
if (fileDragEvent.type == "dragover") {
fileDragEvent.target.classList.add(_this.hoverClass);
} else {
fileDragEvent.target.classList.remove(_this.hoverClass);
this.handleFileSelected = function (fileSelectionEvent) {
var files = fileSelectionEvent.target.files || fileSelectionEvent.dataTransfer.files;
for (var i = 0, f = undefined; f = files[i]; i++) {
if (_this.fileFilter && !f.type.match(_this.fileFilter)) {
if (_this.onError) {
_this.onError(f, "File type does not match filter");
}
};
continue;
}
this.handleDrop = function (fileDropEvent) {
_this.handleFileDrag(fileDropEvent);
_this.handleFileSelected(fileDropEvent);
};
if (_this.maxFileSize && f.size >= _this.maxFileSize) {
if (_this.onError) {
_this.onError(f, "File exceeds file size limit");
}
continue;
}
this.handleFileSelected = function (fileSelectionEvent) {
var files = fileSelectionEvent.target.files || fileSelectionEvent.dataTransfer.files;
for (var i = 0, f = undefined; f = files[i]; i++) {
if (_this.fileFilter && !f.type.match(_this.fileFilter)) {
if (_this.onError) {
_this.onError(f, "File type does not match filter");
}
continue;
}
if (_this.maxFileSize && f.size >= _this.maxFileSize) {
if (onError) {
_this.onError(f, "File exceeds file size limit");
}
continue;
}
_this.readFile(f);
}
};
_this.readFile(f);
}
}]);
};
return FileHandler;
})();
this.onLoaded = onLoaded;
this.onProgress = onProgress;
this.onError = onError;
this.fileFilter = fileFilter;
this.maxFileSize = maxFileSize;
this.readAs = readAs;
this.hoverClass = hoverClass || "file-hover";
};

@@ -93,0 +80,0 @@ _export("FileHandler", FileHandler);

{
"name": "aurelia-files",
"version": "0.1.1",
"version": "0.1.2",
"registry": "jspm",

@@ -5,0 +5,0 @@ "description": "A simple attribute plugin for Aurelia to simplify loading files with the HTML5 FileReader",

@@ -59,3 +59,3 @@ import {FileReaderHelper} from "../helpers/file-reader-helper"

{
if(onError)
if(this.onError)
{ this.onError(f, "File exceeds file size limit"); }

@@ -62,0 +62,0 @@ continue;

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