Registry / payments / simple-currency-formatter

simple-currency-formatter

JSON →
library1.0.4jsnpmunverified

A minimal currency formatting utility extracted from vue2-filters, providing basic locale-aware currency formatting without relying on Intl.NumberFormat. Version 1.0.4 is the latest stable release; no active development or release cadence is evident. It supports simple symbol and decimal formatting with configurable currency symbol and decimal separator. Suitable for lightweight projects where Intl is unavailable or undesired, but lacks modern features like fractional digits control and extended locale support.

npm install simple-currency-formatter
INSTALL
IMPORT
SIG · SIMPLE-CURRENCY-FO
S
simple-currency-formatter
paymentsjavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

currencyFormatter
import { currencyFormatter } from 'simple-currency-formatter'
const currencyFormatter = require('simple-currency-formatter')
ESM-only; package does not export a CommonJS module.
formatCurrency
import { formatCurrency } from 'simple-currency-formatter'
import { default as formatCurrency } from 'simple-currency-formatter'
formatCurrency is a named export, not default.
default
import currencyFormatter from 'simple-currency-formatter'
import { default } from 'simple-currency-formatter'
Default import is available but not recommended; named exports are preferred.

Shows basic usage of formatCurrency with options for symbol, decimal separator, precision, and thousands separator.

import { formatCurrency } from 'simple-currency-formatter'; const result = formatCurrency(1234.56, { symbol: '$', decimal: '.', precision: 2, separator: ',' }); console.log(result); // "$1,234.56"
Debug
Known issues
gotchaThe package does not handle negative numbers; negative values are formatted without a minus sign.
fix
Prepend '-' manually or use a more robust library.
affects: >=0.0.0
gotchaPrecision option does not round correctly for floating-point numbers; it truncates decimal places.
fix
Use Math.round before passing the value.
affects: >=0.0.0
gotchaThe package is not actively maintained; last update in 2019 (v1.0.4).
fix
Consider alternatives like accounting-js or Intl.NumberFormat.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: currencyFormatter is not a function
Using default import incorrectly; the library exports named exports, not a default function.
fix
Use import { currencyFormatter } from 'simple-currency-formatter' and call it accordingly.
Cannot read property 'replace' of undefined
Passing undefined or null as the amount.
fix
Ensure the amount is a valid number: formatCurrency(Number(amount) || 0, options)
formatCurrency is not a function
Attempting to use CommonJS require in an ESM-only environment.
fix
Switch to ES modules: import { formatCurrency } from 'simple-currency-formatter'.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
22
OpenAI (training)
1
Resources
simple-currency-formatter — npm install simple-currency-formatter · libregistry