Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mf-parser

Package Overview
Dependencies
Maintainers
4
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mf-parser - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

19

lib/index.js

@@ -823,8 +823,17 @@ 'use strict';

result.charge = 0;
result.unsaturation = 0;
result.atoms = {};
result.mf = result.parts.map((a) => a.mf).join('.');
result.parts.forEach((a) => {
result.mass += a.mass;
result.monoisotopicMass += a.monoisotopicMass;
result.charge += a.charge;
});
for (const part of result.parts) {
result.mass += part.mass;
result.monoisotopicMass += part.monoisotopicMass;
result.charge += part.charge;
result.unsaturation += part.unsaturation;
for (const atom in part.atoms) {
if (!result.atoms[atom]) {
result.atoms[atom] = 0;
}
result.atoms[atom] += part.atoms[atom];
}
}
return result;

@@ -831,0 +840,0 @@ }

{
"name": "mf-parser",
"version": "2.1.0",
"version": "2.2.0",
"description": "Parse a molecular formula",

@@ -24,5 +24,5 @@ "main": "lib/index.js",

"atom-sorter": "^2.0.0",
"chemical-elements": "^2.0.0",
"chemical-elements": "^2.0.1",
"chemical-groups": "^2.1.0",
"mf-utilities": "^2.0.1"
"mf-utilities": "^2.0.2"
},

@@ -32,3 +32,3 @@ "devDependencies": {

},
"gitHead": "5dbfd516cc7f0aa51bca03f1e2384775b047db8a"
"gitHead": "91eb5af24bbad5cde6f018447f50552140253c2f"
}

@@ -37,2 +37,6 @@ # mf-parser

## Aromaticity index
https://dx.doi.org/10.1002/rcm.2386
## License

@@ -39,0 +43,0 @@

@@ -32,2 +32,49 @@ import { MF } from '..';

it('C.C', () => {
let mf = new MF('C.C');
let parts = mf.toParts();
expect(parts).toStrictEqual([
[{ kind: 'atom', value: 'C', multiplier: 1 }],
[{ kind: 'atom', value: 'C', multiplier: 1 }],
]);
let newMF = mf.toMF();
expect(newMF).toBe('C . C');
mf.canonize();
let html = mf.toHtml();
expect(html).toBe('C • C');
let info = mf.getInfo();
expect(info).toStrictEqual({
parts: [
{
mass: 12.010735896735248,
monoisotopicMass: 12,
charge: 0,
mf: 'C',
atoms: { C: 1 },
unsaturation: 2,
},
{
mass: 12.010735896735248,
monoisotopicMass: 12,
charge: 0,
mf: 'C',
atoms: { C: 1 },
unsaturation: 2,
},
],
monoisotopicMass: 24,
mass: 24.021471793470496,
charge: 0,
unsaturation: 4,
atoms: { C: 2 },
mf: 'C.C',
});
});
it('[11C][11C]', () => {

@@ -162,2 +209,4 @@ let mf = new MF('[11C][11C]');

charge: 0,
unsaturation: 0,
atoms: { C: 6, H: 16, N: 1, Cl: 1 },
mf: 'C6H15N.HCl',

@@ -164,0 +213,0 @@ });

@@ -35,8 +35,17 @@ import {

result.charge = 0;
result.unsaturation = 0;
result.atoms = {};
result.mf = result.parts.map((a) => a.mf).join('.');
result.parts.forEach((a) => {
result.mass += a.mass;
result.monoisotopicMass += a.monoisotopicMass;
result.charge += a.charge;
});
for (const part of result.parts) {
result.mass += part.mass;
result.monoisotopicMass += part.monoisotopicMass;
result.charge += part.charge;
result.unsaturation += part.unsaturation;
for (const atom in part.atoms) {
if (!result.atoms[atom]) {
result.atoms[atom] = 0;
}
result.atoms[atom] += part.atoms[atom];
}
}
return result;

@@ -43,0 +52,0 @@ }

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