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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gold-karat-value

v0.1.0

Published

Estimate gold melt and scrap value from karat, weight, and a 24K price per gram.

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-value

Usage

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

  1. Convert the entered weight to grams.
  2. Purity ratio = karat ÷ 24 (14K ≈ 0.5833).
  3. Price per gram at that karat = 24K price per gram × ratio, rounded to cents.
  4. Melt value = grams × that per-gram price, rounded to cents.
  5. 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