Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new Promise((resolve, reject) => {
// util reject function that will be triggered if any fields fail
const rejectJBEI = errType =>
reject(new Error(`Failed on JBEI file; ${errType}`));
// weird edge case with directed quotation characters
const fileString = JBEI.replace(/“|”/g, '"');
xml2js.parseString(
fileString,
{
xmlns: true,
attrkey: "xml_tag",
tagNameProcessors: [processors.stripPrefix]
},
(err, parsedJBEI) => {
if (err) rejectJBEI(err);
// destructure the paramaeters from JBEI
const { seq } = parsedJBEI;
const { name, sequence, features, circular } = seq;
// attempt to get the name out of the JBEI
let parsedName = "Unnamed";
if (name && name[0] && name[0]._) {
parsedName = name[0]._;
}
// attempt to get the sequence. fail if it's not findable
let parsedSeq = "";
new Promise((resolve, reject) => {
// util reject function that will be triggered if any fields fail
const rejectSBOL = errType =>
reject(new Error(`Failed on SBOLv2 file: ${errType}`));
// weird edge case with directed quotation characters
const fileString = sbol.replace(/“|”/g, '"');
xml2js.parseString(
fileString,
{
xmlns: true,
attrkey: "xml_tag",
tagNameProcessors: [processors.stripPrefix]
},
(err, parsedSBOL) => {
if (err) {
rejectSBOL(err);
}
let RDF = null;
if (parsedSBOL.RDF) {
({ RDF } = parsedSBOL);
}
if (!RDF) {
reject(new Error("No root RDF document"));
}
// check if anything is defined, return if not
client[ewsFunction](ewsArgs, function(err, result, body) {
if(err) {
cb(err);
} else {
// parse body xml
parseString(body, {
tagNameProcessors: [processors.stripPrefix],
attrNameProcessors: [processors.stripPrefix],
valueProcessors: [processors.stripPrefix],
attrValueProcessors: [processors.stripPrefix]
}, function(err, result){
if(err) {
cb(err, null);
} else {
cb(err, result);
}
});
}
});
reject(new Error("Took to long to parse SBOL"));
}, 2000);
// util reject function that will be triggered if any fields fail
const rejectSBOL = errType =>
reject(new Error(`Failed on SBOL file; ${errType}`));
// weird edge case with directed quotation characters
const fileString = sbol.replace(/“|”/g, '"');
xml2js.parseString(
fileString,
{
xmlns: true,
attrkey: "xml_tag",
tagNameProcessors: [processors.stripPrefix]
},
(err, parsedSBOL) => {
if (err) rejectSBOL(err);
let RDF = null;
if (parsedSBOL.RDF) ({ RDF } = parsedSBOL);
if (!RDF) reject(new Error("No root RDF document"));
const { Collection, DnaComponent } = RDF;
if (Collection && Collection.length) {
// it's a collection of DnaComponents, parse each to a part
const partList = [];
Collection.forEach(({ component }) => {
if (component && component.length) {
component.forEach(({ DnaComponent: nestedDnaComponent }) => {
partList.push(
dnaComponentToPart(nestedDnaComponent[0], {
let parsedData = await async.wrap(cb => new Parser({tagNameProcessors: [processors.stripPrefix]}).parseString(data, cb));
return await this.actionHandler(action, parsedData['Envelope']['Body'][0][action][0]);