compound-parser
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Compound Parser

A fast and simple parser for chemical compounds.

Converts a string representing a chemical compound (eg. H2O) into a Map of the different atoms that make up that compound (eg. {"H" => 2, "O" => 1}).

Example Usage

const parse = require("compound-parser");

const water = parse("H2O");                     // Map {"H" => 2, "O" => 1}
const ironHydroxide = parse("Fe(OH)3");         // Map {"Fe" => 1, "O" => 3, "H" => 3}
const someCompound = parse("H2((O2)2(Ca2)2)2"); // Map {"H" => 2, "O" => 8, "Ca" => 8}

Installation

You can use the package by installing it with npm npm i compound-parser

Package Sidebar

Install

npm i compound-parser

Weekly Downloads

1

Version

1.0.5

License

ISC

Unpacked Size

8.77 kB

Total Files

10

Last publish

Collaborators

  • dzhanidaud