npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nam088/chemical-balancer

v1.2.0

Published

A lightweight and robust chemical equation balancer using Gaussian elimination.

Downloads

410

Readme

Cân Bằng Phương Trình Hóa Học

Thư viện TypeScript nhẹ cho các phép tính hóa học: cân bằng phương trình, khối lượng mol, tính toán theo phương trình, và nhiều hơn nữa.

Tính Năng

  • Cân Bằng Phương Trình - Sử dụng phương pháp khử Gauss
  • Tính Khối Lượng Mol - Đầy đủ 118 nguyên tố
  • Tính Toán Theo Phương Trình - Chuyển đổi mol/gram
  • Chất Phản Ứng Giới Hạn - Tìm chất phản ứng hết trước
  • Phân Loại Phản Ứng - Đốt cháy, acid-base, oxi-hóa khử, v.v.
  • Trạng Thái Vật Chất - Hỗ trợ (s), (l), (g), (aq)

Cài Đặt

npm install @nam088/chemical-balancer

Hướng Dẫn Sử Dụng

Cân Bằng Phương Trình

import { ChemicalBalancer } from '@nam088/chemical-balancer';

const result = ChemicalBalancer.balance('Fe + O2 -> Fe2O3');
console.log(result.balancedString); // '4Fe + 3O2 -> 2Fe2O3'

Tính Khối Lượng Mol

import { calculateMolarMass } from '@nam088/chemical-balancer';

calculateMolarMass('H2O');     // 18.015
calculateMolarMass('C6H12O6'); // 180.16 (glucose)
calculateMolarMass('NaCl');    // 58.44

Tính Toán Theo Phương Trình

import { calculateStoichiometry } from '@nam088/chemical-balancer';

// Tính số gram H2O tạo thành từ 2 mol H2
const result = calculateStoichiometry({
  equation: 'H2 + O2 -> H2O',
  given: { molecule: 'H2', amount: 2, unit: 'mol' },
  find: { molecule: 'H2O', unit: 'g' }
});
console.log(result.amount); // 36.03

Chất Phản Ứng Giới Hạn

import { findLimitingReagent } from '@nam088/chemical-balancer';

const result = findLimitingReagent({
  equation: 'H2 + O2 -> H2O',
  reagents: [
    { molecule: 'H2', amount: 4, unit: 'mol' },
    { molecule: 'O2', amount: 1, unit: 'mol' }
  ]
});
console.log(result.limiting); // 'O2'
console.log(result.excess);   // [{ molecule: 'H2', remaining: 2 }]

Phân Loại Phản Ứng

import { classifyReaction } from '@nam088/chemical-balancer';

classifyReaction('CH4 + O2 -> CO2 + H2O');
// { type: 'combustion', confidence: 0.95 }

classifyReaction('HCl + NaOH -> NaCl + H2O');
// { type: 'acid-base', confidence: 0.9 }

Phân Tích Công Thức Với Trạng Thái

import { Parser } from '@nam088/chemical-balancer';

Parser.parseFormulaWithState('H2O(l)');
// { elements: { H: 2, O: 1 }, state: 'l' }

Parser.parseFormulaWithState('NaCl(aq)');
// { elements: { Na: 1, Cl: 1 }, state: 'aq' }

Nâng Cao: Phương Trình "Monster"

Thư viện xử lý được các phương trình cực kỳ phức tạp:

const input = '[Cr(N2H4CO)6]4[Cr(CN)6]3 + KMnO4 + H2SO4 -> K2Cr2O7 + MnSO4 + CO2 + KNO3 + K2SO4 + H2O';
const result = ChemicalBalancer.balance(input);
// Hệ số lên đến 1879!

Tham Khảo API

| Hàm | Mô Tả | |-----|-------| | ChemicalBalancer.balance(eq) | Cân bằng phương trình hóa học | | calculateMolarMass(formula) | Tính khối lượng mol (g/mol) | | calculateMolarMassDetailed(formula) | Khối lượng mol chi tiết theo nguyên tố | | calculateStoichiometry(input) | Chuyển đổi mol/gram | | findLimitingReagent(input) | Tìm chất phản ứng giới hạn | | classifyReaction(eq) | Phân loại loại phản ứng | | Parser.parseFormula(formula) | Phân tích thành số nguyên tử | | Parser.parseFormulaWithState(formula) | Phân tích với trạng thái vật chất | | isValidElement(symbol) | Kiểm tra nguyên tố có tồn tại | | setLocale(locale) | Đặt ngôn ngữ ('en' hoặc 'vi') |

Đa Ngôn Ngữ (i18n)

Thư viện hỗ trợ tiếng Anh và tiếng Việt cho thông báo lỗi và phân loại phản ứng:

import { setLocale, classifyReaction } from '@nam088/chemical-balancer';

// Mặc định: Tiếng Anh
classifyReaction('CH4 + O2 -> CO2 + H2O');
// { typeName: 'Combustion', reason: 'Reaction involves O2...' }

// Chuyển sang tiếng Việt
setLocale('vi');
classifyReaction('CH4 + O2 -> CO2 + H2O');
// { typeName: 'Phản ứng đốt cháy', reason: 'Phản ứng có O2...' }

Giấy Phép

MIT