@coinify/currency

中文文档
1.4.12发布于 2025/11/06MITCommonJS近 30 天下载 2012

Helper functions for managing amounts in different currencies

原始使用文档
文档目录10 节
  1. Installation
  2. Usage
  3. getDecimalsForCurrency(currency)
  4. fromSmallestSubunit(amount, currency)
  5. toSmallestSubunit(amount, currency)
  6. convertSubunitAmount(amountSubUnit, rate, fromCurrency, toC…
  7. computeRateBetweenSubunitAmounts(fromCurrency, fromAmount, …
  8. isValidCurrency(code)
  9. isValidFiatCurrency(code)
  10. isValidCryptoCurrency(code)

node-currency

npm version

Installation

Run the following command

npm install --save @coinify/currency

Usage

const currency = require('@coinify/currency');

currency exposes the following functions:

getDecimalsForCurrency(currency)

Returns the number of decimals after the floating point, with which the amount should be formatted, depending on the currency.

fromSmallestSubunit(amount, currency)

Convert an amount of money from the smallest sub-unit of the currency to the main-unit.

toSmallestSubunit(amount, currency)

Convert an amount of money from the main-unit of the currency to the smallest sub-unit.

convertSubunitAmount(amountSubUnit, rate, fromCurrency, toCurrency)

Convert between sub-unit amounts of two currencies with a given rate, correctly converting between sub-units with different decimal amounts.

computeRateBetweenSubunitAmounts(fromCurrency, fromAmount, toCurrency, toAmount)

Computes a rate between two amounts in two different currencies.

isValidCurrency(code)

Is the provided currency code a valid currency? (fiat or crypto)

isValidFiatCurrency(code)

Is the provided currency code a valid fiat currency?

isValidCryptoCurrency(code)

Is the provided currency code a valid crypto currency?

版本与发布记录

@coinify/currency 共发布 67 个版本,首次发布于 2017/11/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.4.12latest2025/11/061 年前
1.4.112025/08/281.2 年前
1.4.102025/08/281.2 年前
1.4.92025/04/301.5 年前
1.4.82025/04/031.6 年前
1.4.72025/03/131.7 年前

关于 @coinify/currency 的常见问题

@coinify/currency 是什么?

Helper functions for managing amounts in different currencies

如何安装 @coinify/currency?

在项目目录运行 npm install @coinify/currency,或使用 pnpm add / yarn add / bun add。

@coinify/currency 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/coinify__currency 是否存在。

@coinify/currency 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@coinify/currency 可以商用吗?

@coinify/currency 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@coinify/currency 的下载量有多少?

根据 npm 官方下载统计,@coinify/currency 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,012 次,日均约 67 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@coinify/currency 还在维护吗?

最新版本 1.4.12 发布于 2025/11/06(1 年前);至今共发布 67 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/11/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。