Skip to content

Parse a chemical formula to get a count of each element in a compound

License

Notifications You must be signed in to change notification settings

kenany/chemical-formula

Repository files navigation

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.

About

Parse a chemical formula to get a count of each element in a compound

Resources

License

Stars

Watchers

Forks

Packages