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

fmt-money

v1.0.7

Published

A utility for formatting money values with commas and decimals.

Readme

fmt-money;

一个简单的工具,用于将数字格式化为货币值,添加千分位分隔符,并支持任意位小数。

A simple tool for formatting numbers as currency values, adding thousand separators, and supporting any number of decimal places.

安装

通过 npm 安装:

Install via npm:

npm install fmt-money;

API

formatMoney(amount, decimalCount = 2) 通过添加千分位分隔符和四舍五入到指定的小数位数,格式化给定的金额。

Formats a given amount by adding thousand separators and rounding to the specified decimal places.

参数 amount (number): 要格式化的金额。必须是有效的数字。 decimalCount (number | string, 可选): 要显示的小数位数。默认为 2。可以是数字或数字字符串。

返回值 格式化后的货币值字符串表示。例如,1234.56 变为 "1,234.56"。 A formatted string representation of the monetary value. For example, 1234.56 becomes "1,234.56".

错误处理 如果 amount 不是有效的数字,函数将记录错误:Invalid input: amount must be a number. 如果 decimalCount 不是有效的非负数字或数字字符串,函数将记录错误:Invalid input: decimalCount must be a number or a numeric string.

If amount is not a valid number, the function will log an error: Invalid input: amount must be a number. If decimalCount is not a valid non-negative number or a numeric string, the function will log an error: Invalid input: decimalCount must be a number or a numeric string.

示例

import formatMoney from 'fmt-money';

formatMoney(1234567.891); // "1,234,567.89" formatMoney(1234567.891, 1); // "1,234,567.9" formatMoney(1234567, 0); // "1,234,567"