gold-karat-value
v0.1.0
Published
Estimate gold melt and scrap value from karat, weight, and a 24K price per gram.
Maintainers
Readme
gold-karat-value
Estimate gold melt value from karat, weight, and a 24K price per gram.
Jewelry and scrap workflows usually start from the same three inputs: how heavy the piece is, what karat stamp it carries, and what fine gold is trading at today. This package keeps that math in one place so a Node script, CLI, or backend can reuse the same rounding rules.
It does not call a price API. You pass in the 24K price you already have (spot feed, cached quote, or a number typed by the user).
Install
npm install gold-karat-valueUsage
const { meltValue, scrapValue } = require("gold-karat-value");
const melt = meltValue(10, "gram", 14, 65);
console.log(`14K melt: $${melt.total.toFixed(2)} ($${melt.perGram.toFixed(2)}/g)`);
const scrap = scrapValue(10, "gram", 14, 65, 0.85);
console.log(`85% scrap offer: $${scrap.scrap.toFixed(2)}`);Units: gram, pennyweight, troy_ounce, troy_pound, kilogram. Karat must be between 0 and 24 (including fractional stamps such as 21.6).
Formula
- Convert the entered weight to grams.
- Purity ratio = karat ÷ 24 (14K ≈ 0.5833).
- Price per gram at that karat = 24K price per gram × ratio, rounded to cents.
- Melt value = grams × that per-gram price, rounded to cents.
- Scrap estimate = melt value × a payout ratio between 0 and 1 (for example 0.50 at a pawn shop, 0.85 for some online buyers).
The same cent-rounding is applied to per-gram, per-troy-ounce, and per-troy-pound quotes so table output stays consistent with a UI.
When you need live prices
This library stops at the arithmetic. If you want the same karat and unit conversion with a regularly updated spot price in the browser, there is a gold calculator that applies these ratios without an account.
License
MIT
