chemical-formula
v4.0.1
Published
Parse a chemical formula to get a count of each element in a compound
Downloads
21
Readme
chemical-formula
Parse a chemical formula to get a count of each element in a compound.
Example
var chemicalFormula = require('chemical-formula');
chemicalFormula('H2O');
// => {H: 2, O: 1}
chemicalFormula('HOCH2CH2OH');
// => {H: 6, O: 2, C: 2}
Installation
$ npm install chemical-formula
API
var chemicalFormula = require('chemical-formula');
chemicalFormula(formula)
Parse String formula
and return an Object whose keys are element symbols
and values are the quantities of each element in formula
.