mf-matcher
Advanced tools
Comparing version 0.5.0 to 0.5.2
{ | ||
"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') | ||
}; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8476
8
190
1
1
+ Addedmf-utilities@^0.5.2
+ Addedatom-sorter@0.5.12(transitive)
+ Addedchemical-elements@0.5.12(transitive)
+ Addedmf-parser@0.5.12(transitive)
+ Addedmf-utilities@0.5.12(transitive)
+ Addedpapaparse@4.6.3(transitive)