Git Product home page Git Product logo

chemymass's Introduction

🧪 chemymass

Simple Molar Mass Calculator

📝 Description

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

🔧 Installation

chemymass is easy to install, just do:

npm i chemymass

📕 Usage

chemymass from v2 is an ESM-only module - you are not able to import it with require().

If you cannot switch to ESM, please use v1 which remains compatible with CommonJS.

npm i chemymass@1

Ways to call the module from your program:

// Standard Long Mode - Get molar mass and element percentages.
import chemymass from "chemymass";

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.
import { short } from "chemymass";

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.
import { verbal } from "chemymass";

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.
import { verbalShort } from "chemymass";

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
*/
// Standard Bulk Mode - Get molar mass and element percentages.
import { bulk } from "chemymass";

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
*/
// Standard Short Mode - Get only molar mass.
import { bulkShort } from "chemymass";

const formula = ["H2SO4", "H2O", "CuSO4"];
const precision = 7;
const units = "amu";
console.log(chemymass.short(formula, precision, units));

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

📰 Notes

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

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

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

  • 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 "" (No units - just number).

  • (^2.0.3) 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

chemymass's People

Contributors

eehoveckis avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.