Created
November 19, 2020 22:18
-
-
Save kleberksms/50e0a61bc8117c8926a1576c7c7c515e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MAX_LENGHT_FILE = 7; | |
const MAX_UPLOAD_SIZE = 5000000; | |
const temporaryFileList = []; | |
const dangerToast = (text) => { | |
console.error(text); | |
}; | |
const maxLenghtFilesIsValid = (files = []) => { | |
if (!Array.isArray(files)) { | |
throw Error('only array') | |
} | |
return files.length <= MAX_LENGHT_FILE; | |
} | |
const getFileSize = (files) => { | |
/** | |
* ... code | |
*/ | |
return 0; | |
} | |
const getDropSize = (files) => { | |
/** | |
* code | |
*/ | |
return 0; | |
} | |
const fillTemporaryArray = (files) => { | |
if (!maxLenghtFilesIsValid(files)) { | |
dangerToast('Limite atingido'); | |
return; | |
} | |
if ((getDropSize(files) + getFileSize(files)) >= MAX_UPLOAD_SIZE ) { //just a joke | |
dangerToast('Limite de tamanho') | |
return; | |
} | |
files.forEach(el => { | |
temporaryFileList.push(el); | |
}); | |
} | |
const f = ['foo', 'bar']; | |
fillTemporaryArray(f); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment