Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
reader.onload = function(evt) {
const content = evt.target.result;
anyToJson(
content,
async result => {
// TODO maybe handle import errors/warnings better
const failed = !result[0].success;
const messages = result[0].messages;
if (messages && messages.length) {
messages.forEach(msg => {
const type = msg
.substr(0, 20)
.toLowerCase()
.includes("error")
? failed
? "error"
: "warning"
: "info";
window.toastr[type](msg);
reader.onload = function(evt: Object) {
const content: string = evt.target.result;
anyToJson(
content,
result => {
updateSequenceData(result[0].parsedSequence);
},
{ fileName: file.name, acceptParts: true }
);
};
reader.onerror = function() {
flatMap(files, async file => {
const results = await anyToJson(file.originalFileObj, {
fileName: file.name,
acceptParts: true
});
return results.forEach(result => {
if (result.success) {
array.push("addedSequences", result.parsedSequence);
} else {
return window.toastr.warning("Error parsing file: ", file.name);
}
});
});
onChange([]);