New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mf-from-google-sheet

Package Overview
Dependencies
Maintainers
0
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mf-from-google-sheet - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

lib/src/index.d.ts

13

package.json
{
"name": "mf-from-google-sheet",
"version": "3.1.0",
"version": "3.1.1",
"description": "Retrieve and format molecular formula from google sheet",
"main": "lib/index.js",
"main": "lib/src/index.js",
"module": "src/index.js",

@@ -23,9 +23,8 @@ "files": [

"dependencies": {
"cross-fetch": "^4.0.0",
"mf-generator": "^3.3.0",
"mf-parser": "^3.2.0",
"mf-utilities": "^3.2.0",
"mf-generator": "^3.3.1",
"mf-parser": "^3.2.1",
"mf-utilities": "^3.2.1",
"papaparse": "^5.4.1"
},
"gitHead": "28dae91d3b42556a23097ee08acfe4061f276ed0"
"gitHead": "838f98a30846d4b1721b8ed7aa94a55e854d7521"
}

@@ -17,97 +17,96 @@ import { generateMFs } from 'mf-generator';

}
}
async function parse(tsv, tsvReferences) {
let parsed = Papa.parse(tsv, {
async function parse(tsv, tsvReferences) {
let parsed = Papa.parse(tsv, {
delimiter: '\t',
header: true,
});
let fields = parsed.meta.fields;
let infoFields = fields.filter(
(a) => !['mf', 'modif', 'ESI', 'MALDI', 'positive', 'negative'].includes(a),
);
let formulas = parsed.data;
let references = {};
if (tsvReferences) {
let referencesArray = Papa.parse(tsvReferences, {
delimiter: '\t',
header: true,
});
let fields = parsed.meta.fields;
let infoFields = fields.filter(
(a) =>
!['mf', 'modif', 'ESI', 'MALDI', 'positive', 'negative'].includes(a),
);
let formulas = parsed.data;
let references = {};
if (tsvReferences) {
let referencesArray = Papa.parse(tsvReferences, {
delimiter: '\t',
header: true,
}).data;
}).data;
referencesArray.forEach((r) => {
references[r.label] = r;
});
for (const r of referencesArray) {
references[r.label] = r;
}
}
let results = [];
for (let formula of formulas) {
if (tsvReferences) {
// we add references
let refs = formula.references.split(/[ ,]+/);
formula.references = [];
for (let ref of refs) {
formula.references.push(references[ref]);
}
let results = [];
for (let formula of formulas) {
if (tsvReferences) {
// we add references
let refs = formula.references.split(/[ ,]+/);
formula.references = [];
for (let ref of refs) {
formula.references.push(references[ref]);
}
// we need to calculate all the possibilities
try {
let mfs = await generateMFs([formula.mf], {
ionizations: formula.modif,
});
for (let mf of mfs) {
mf.info = {};
for (let infoField of infoFields) {
mf.info[infoField] = formula[infoField];
}
if (
!formula.ESI &&
!formula.MALDI &&
!formula.positive &&
!formula.negative
) {
mf.filter = {
ESI: true,
MALDI: true,
positive: true,
negative: true,
};
} else {
mf.filter = {
ESI: formula.ESI === 'X',
MALDI: formula.MALDI === 'X',
positive: formula.positive === 'X',
negative: formula.negative === 'X',
};
}
mf.mf = new MF(mf.mf).toMF();
results.push(mf);
}
// we need to calculate all the possibilities
try {
let mfs = await generateMFs([formula.mf], {
ionizations: formula.modif,
});
for (let mf of mfs) {
mf.info = {};
for (let infoField of infoFields) {
mf.info[infoField] = formula[infoField];
}
} catch (e) {
// eslint-disable-next-line no-console
console.warn(
'Non parsable molecular formula: ',
formula.mf,
formula.modif,
e.toString(),
);
if (
!formula.ESI &&
!formula.MALDI &&
!formula.positive &&
!formula.negative
) {
mf.filter = {
ESI: true,
MALDI: true,
positive: true,
negative: true,
};
} else {
mf.filter = {
ESI: formula.ESI === 'X',
MALDI: formula.MALDI === 'X',
positive: formula.positive === 'X',
negative: formula.negative === 'X',
};
}
mf.mf = new MF(mf.mf).toMF();
results.push(mf);
}
} catch (error) {
// eslint-disable-next-line no-console
console.warn(
'Non parsable molecular formula:',
formula.mf,
formula.modif,
error.toString(),
);
}
}
results = results.filter((a) => {
return a.ms.em !== 0;
});
results = results.filter((a) => {
return a.ms.em !== 0;
});
results.sort((a, b) => {
return a.ms.em - b.ms.em;
});
results.sort((a, b) => {
return a.ms.em - b.ms.em;
});
let uniqueResults = [results[0]];
for (let i = 1; i < results.length; i++) {
if (results[i - 1].ms.em !== results[i].ms.em) {
uniqueResults.push(results[i]);
}
let uniqueResults = [results[0]];
for (let i = 1; i < results.length; i++) {
if (results[i - 1].ms.em !== results[i].ms.em) {
uniqueResults.push(results[i]);
}
}
return uniqueResults;
}
return uniqueResults;
}

@@ -1,5 +0,3 @@

import crossFetch from 'cross-fetch';
export async function fetchText(url) {
const result = await crossFetch(url);
const result = await fetch(url);
if (result.status !== 200) {

@@ -6,0 +4,0 @@ throw new Error(String(result.status));

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