Socket
Socket
Sign inDemoInstall

react-dropzone

Package Overview
Dependencies
Maintainers
3
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dropzone - npm Package Compare versions

Comparing version 10.2.0 to 10.2.1

4

dist/es/index.js

@@ -605,3 +605,3 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

files.forEach(function (file) {
if (fileAccepted(file, accept) && fileMatchSize(file, maxSize, minSize)) {
if (fileAccepted(file, accept) && fileMatchSize(file, minSize, maxSize)) {
acceptedFiles.push(file);

@@ -715,3 +715,3 @@ } else {

var isMultipleAllowed = multiple || fileCount <= 1;
var isDragAccept = fileCount > 0 && allFilesAccepted(draggedFiles, accept, maxSize, minSize);
var isDragAccept = fileCount > 0 && allFilesAccepted(draggedFiles, accept, minSize, maxSize);
var isDragReject = fileCount > 0 && (!isDragAccept || !isMultipleAllowed);

@@ -718,0 +718,0 @@ return _objectSpread({}, state, {

@@ -9,8 +9,17 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

}
export function fileMatchSize(file, maxSize, minSize) {
return file.size <= maxSize && file.size >= minSize;
export function fileMatchSize(file, minSize, maxSize) {
if (isDefined(file.size)) {
if (isDefined(minSize) && isDefined(maxSize)) return file.size >= minSize && file.size <= maxSize;else if (isDefined(minSize)) return file.size >= minSize;else if (isDefined(maxSize)) return file.size <= maxSize;
}
return true;
}
export function allFilesAccepted(files, accept, maxSize, minSize) {
function isDefined(value) {
return value !== undefined && value !== null;
}
export function allFilesAccepted(files, accept, minSize, maxSize) {
return files.every(function (file) {
return fileAccepted(file, accept) && fileMatchSize(file, maxSize, minSize);
return fileAccepted(file, accept) && fileMatchSize(file, minSize, maxSize);
});

@@ -17,0 +26,0 @@ } // React's synthetic events has event.isPropagationStopped,

@@ -168,3 +168,3 @@ {

},
"version": "10.2.0",
"version": "10.2.1",
"engines": {

@@ -171,0 +171,0 @@ "node": ">= 8"

@@ -584,3 +584,3 @@ /* eslint prefer-template: 0 */

files.forEach(file => {
if (fileAccepted(file, accept) && fileMatchSize(file, maxSize, minSize)) {
if (fileAccepted(file, accept) && fileMatchSize(file, minSize, maxSize)) {
acceptedFiles.push(file)

@@ -716,3 +716,3 @@ } else {

const isMultipleAllowed = multiple || fileCount <= 1
const isDragAccept = fileCount > 0 && allFilesAccepted(draggedFiles, accept, maxSize, minSize)
const isDragAccept = fileCount > 0 && allFilesAccepted(draggedFiles, accept, minSize, maxSize)
const isDragReject = fileCount > 0 && (!isDragAccept || !isMultipleAllowed)

@@ -719,0 +719,0 @@

@@ -9,9 +9,21 @@ import accepts from 'attr-accept'

export function fileMatchSize(file, maxSize, minSize) {
return file.size <= maxSize && file.size >= minSize
export function fileMatchSize(file, minSize, maxSize) {
if (isDefined(file.size)) {
if (isDefined(minSize) && isDefined(maxSize))
return file.size >= minSize && file.size <= maxSize
else if (isDefined(minSize))
return file.size >= minSize
else if (isDefined(maxSize))
return file.size <= maxSize
}
return true
}
export function allFilesAccepted(files, accept, maxSize, minSize) {
function isDefined(value) {
return value !== undefined && value !== null
}
export function allFilesAccepted(files, accept, minSize, maxSize) {
return files.every(file => {
return fileAccepted(file, accept) && fileMatchSize(file, maxSize, minSize)
return fileAccepted(file, accept) && fileMatchSize(file, minSize, maxSize)
})

@@ -18,0 +30,0 @@ }

@@ -5,2 +5,40 @@ beforeEach(() => {

describe('fileMatchSize()', () => {
let utils
beforeEach(async done => {
utils = await import('./index')
done()
})
it('should return true if the file object doesn\'t have a {size} property', () => {
expect(utils.fileMatchSize({})).toBe(true)
expect(utils.fileMatchSize({size: null})).toBe(true)
})
it('should return true if the minSize and maxSize were not provided', () => {
expect(utils.fileMatchSize({size: 100})).toBe(true)
expect(utils.fileMatchSize({size: 100}, undefined, undefined)).toBe(true)
expect(utils.fileMatchSize({size: 100}, null, null)).toBe(true)
})
it('should return true if the file {size} is within the [minSize, maxSize] range', () => {
expect(utils.fileMatchSize({size: 100}, 10, 200)).toBe(true)
expect(utils.fileMatchSize({size: 100}, 10, 99)).toBe(false)
expect(utils.fileMatchSize({size: 100}, 101, 200)).toBe(false)
})
it('should return true if the file {size} is more than minSize', () => {
expect(utils.fileMatchSize({size: 100}, 100)).toBe(true)
expect(utils.fileMatchSize({size: 100}, 101)).toBe(false)
})
it('should return true if the file {size} is less than maxSize', () => {
expect(utils.fileMatchSize({size: 100}, undefined, 100)).toBe(true)
expect(utils.fileMatchSize({size: 100}, null, 100)).toBe(true)
expect(utils.fileMatchSize({size: 100}, undefined, 99)).toBe(false)
expect(utils.fileMatchSize({size: 100}, null, 99)).toBe(false)
})
})
describe('isIeOrEdge', () => {

@@ -7,0 +45,0 @@ let utils

Sorry, the diff of this file is too big to display

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