Skip to content

Instantly share code, notes, and snippets.

@kleberksms
Created November 19, 2020 22:18
Show Gist options
  • Save kleberksms/50e0a61bc8117c8926a1576c7c7c515e to your computer and use it in GitHub Desktop.
Save kleberksms/50e0a61bc8117c8926a1576c7c7c515e to your computer and use it in GitHub Desktop.
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