chemymass

1.0.16 • Public • Published

🧪 chemymass

Simple Molar Mass Calculator

📝 Description

chemymass - Simple molar mass calculator. Calculates molar mass for any valid formula.

🔧 Setup

chemymass is easy to setup, just do:

npm i chemymass

📕 Usage

To require chemymass in your program do:

const chemymass = require("chemymass");

Ways to call chemymass from your program:

// Standard Long Mode - Get molar mass and element percentages.
const formula = "H₂SO₄";
const precision = 3;
const units = "g/mol";
console.log(chemymass(formula, precision, units));

/* Output:
H₂SO₄:
2 H · 1.007825 = 2.016 (2.055% of mass)
1 S · 32.066 = 32.066 (32.694% of mass)
4 O · 15.9994 = 63.998 (65.251% of mass)
Total: 98.079 g/mol
*/
// Standard Short Mode - Get only molar mass.
const formula = "CuSO₄·5H₂O";
const precision = 7;
const units = "amu";
console.log(chemymass.short(formula, precision, units));

/* Output:
249.6848500 amu
*/
// Standard Verbal Mode - Get molar mass and element percentages from query.
const query = "Sugar";
const precision = 7;
const units = "Da";
chemymass.verbal(query, precision, units)
  .then(output => console.log(output));

/* Output:
Sugar - C₁₂H₂₂O₁₁:
12 C · 12.011 = 144.1320000 (42.1072251% of mass)
22 H · 1.007825 = 22.1721500 (6.4774492% of mass)
11 O · 15.9994 = 175.9934000 (51.4153256% of mass)
Total: 342.2975500 Da
*/
// Short Verbal Mode - Get only molar mass from query.
const query = "58-08-2";
const precision = 7;
const units = "u";
chemymass.verbalShort(query, precision, units)
  .then(output => console.log(output));

/* Output:
194.1918500 u
*/
// Bulk Long Mode - Get molar mass and element percentages.
const formula = ["H₂SO₄", "H₂O", "CuSO₄"];
const precision = 3;
const units = "g/mol";
console.log(chemymass.bulk(formula, precision, units));

/* Output:
H₂SO₄:
1 S · 32.066 = 32.066 (32.694% of mass)
4 O · 15.9994 = 63.998 (65.251% of mass)
Total: 98.079 g/mol

H₂O:
2 H · 1.007825 = 2.016 (11.189% of mass)
1 O · 15.9994 = 15.999 (88.811% of mass)
Total: 18.015 g/mol

CuSO₄:
1 Cu · 63.546 = 63.546 (39.813% of mass)
1 S · 32.066 = 32.066 (20.090% of mass)
4 O · 15.9994 = 63.998 (40.096% of mass)
Total: 159.610 g/mol
*/
// Bulk Short Mode - Get only molar mass.
const formula = ["H₂SO₄", "H₂O", "CuSO₄"];
const precision = 7;
const units = "amu";
console.log(chemymass.bulkShort(formula, precision, units));

/* Output:
98.0792500 amu
18.0150500 amu
159.6096000 amu
*/

📰 Notes

  • (^1.0.8) This module understands both normal numbers and subscripts. You don't have to specifically convert them.

  • (^1.0.10) Crystal Hydrates work without any modifications. Formulas can be with signs ·, × or *.

  • (^1.0.11) Verbal mode supported query types: Plain Text Name, CAS number, SMILES, IUPAC, FICTS identifier, Cactvs HASHISY, uuuuu identifier.

  • (^1.0.12) units is optional parameter which defaults to g/mol. Available options are g/mol (Grams per mole); kg/mol (Kilograms per mole); Da (Daltons); amu (Atomic mass unit); u (Same as amu) or "" (Just number - no units) (^1.0.13).

  • (^1.0.14) Bulk options is now available. Just pass an array of formulas and all of them will be calculated.

  • precision is optional parameter which defaults to 3 if not passed to function.

  • Verbal mode is made possible by NIH NCI/CADD Group! Without their API, verbal mode probably wouldn't be a thing.

👨‍⚖️ License

chemymass by EEHoveckis is licensed under a Creative Commons Attribution 4.0 International License.
Permissions beyond the scope of this license may be available on request.
Creative Commons Attribution 4.0 International License

Package Sidebar

Install

npm i chemymass

Weekly Downloads

2

Version

1.0.16

License

CC-BY-4.0

Unpacked Size

38.3 kB

Total Files

10

Last publish

Collaborators

  • eehoveckis