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

isotopic-distribution

Package Overview
Dependencies
Maintainers
2
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isotopic-distribution - npm Package Compare versions

Comparing version 1.1.17 to 1.2.0

8

package.json
{
"name": "isotopic-distribution",
"version": "1.1.17",
"version": "1.2.0",
"description": "Calculate the isotopic distribution of a molecular formula",

@@ -22,7 +22,7 @@ "main": "src/index.js",

"chemical-elements": "^1.1.10",
"mf-parser": "^1.3.1",
"mf-utilities": "^1.2.8",
"mf-parser": "^1.3.2",
"mf-utilities": "^1.2.9",
"spectrum-generator": "^4.6.0"
},
"gitHead": "d5a9a9672ccaa6a632ef89c815d42385b7ab36af"
"gitHead": "b01931558f4a134c6e8547a379bada50af8ba8fc"
}

@@ -166,2 +166,12 @@ 'use strict';

it('create distribution of C10 and getXY with sumValue to 1', () => {
let isotopicDistribution = new IsotopicDistribution('C10');
let xy = isotopicDistribution.getXY({ sumValue: 100 });
expect(isotopicDistribution.confidence).toBeGreaterThan(0.99999);
expect(xy.x[0]).toStrictEqual(120);
expect(
xy.y.reduce((previous, current) => previous + current, 0),
).toStrictEqual(100);
});
it('create distribution of Ru5 and getXY', () => {

@@ -168,0 +178,0 @@ let isotopicDistribution = new IsotopicDistribution('Ru5');

@@ -210,12 +210,26 @@ 'use strict';

getSumY(points) {
let sumY = 0;
for (let point of points) {
sumY += point.y;
}
return sumY;
}
/**
* Returns the isotopic distirubtion
* @param {object} [options={}]
* @param {number} [options.maxValue=100]
* @param {number} [options.sumValue] // if sumValue is defined, maxValue is ignored
* @return {XY} an object containing 2 properties: x:[] and y:[]
*/
getXY(options = {}) {
const { maxValue = 100 } = options;
const { maxValue = 100, sumValue } = options;
let points = this.getDistribution().array;
if (points.length === 0) return [];
let factor = 1;
if (maxValue) {
if (sumValue) {
let sumY = this.getSumY(points);
factor = sumY / sumValue;
} else if (maxValue) {
let maxY = this.getMaxY(points);

@@ -222,0 +236,0 @@ factor = maxY / maxValue;

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