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

mf-matcher

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mf-matcher - npm Package Compare versions

Comparing version 0.5.0 to 0.5.2

src/__tests__/generalMatcher.js

7

package.json
{
"name": "mf-matcher",
"version": "0.5.0",
"version": "0.5.2",
"description": "Returns true / false for an object using mw, em, msem, unsaturation and atoms",

@@ -19,3 +19,6 @@ "main": "src/index.js",

},
"homepage": "https://github.com/cheminfo-js/molecular-formula/tree/master/packages/mf-matcher#readme"
"homepage": "https://github.com/cheminfo-js/molecular-formula/tree/master/packages/mf-matcher#readme",
"dependencies": {
"mf-utilities": "^0.5.2"
}
}
'use strict';
/**
* Returns a very important number
* @return {boolean}
*/
module.exports = function mfFilter(entry, options = {}) {
const {
minMW = 0,
maxMW = +Infinity,
minEM = 0,
maxEM = +Infinity,
minMSEM = 0,
maxMSEM = +Infinity,
minCharge = -Infinity,
maxCharge = +Infinity,
minUnsaturation = -Infinity,
maxUnsaturation = +Infinity,
onlyIntegerUnsaturation,
onlyNonIntegerUnsaturation,
atoms
} = options;
if (entry.mw !== undefined) {
if ((entry.mw < minMW) || (entry.mw > maxMW)) return false;
}
if (entry.em !== undefined) {
if ((entry.em < minEM) || (entry.em > maxEM)) return false;
}
if (entry.msem !== undefined) {
if ((entry.msem < minMSEM) || (entry.msem > maxMSEM)) return false;
}
if (entry.charge !== undefined) {
if ((entry.charge < minCharge) || (entry.charge > maxCharge)) return false;
}
if (entry.unsaturation !== undefined) {
if (entry.unsaturation < minUnsaturation || entry.unsaturation > maxUnsaturation) return false;
if (onlyIntegerUnsaturation && !Number.isInteger(entry.unsaturation)) return false;
if (onlyNonIntegerUnsaturation && Number.isInteger(entry.unsaturation)) return false;
}
if (entry.atoms !== undefined && atoms) {
// all the atoms of the entry must fit in the range
for (let atom of Object.keys(entry.atoms)) {
if (!atoms[atom]) return false;
if (entry.atoms[atom] < atoms[atom].min) return false;
if (entry.atoms[atom] > atoms[atom].max) return false;
}
}
return true;
module.exports = {
general: require('./generalMatcher'),
msem: require('./msemMatcher')
};
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