Registry / finance / az-money-formatter

az-money-formatter

JSON →
library1.9.2jsnpmunverified

A minimal npm package for formatting monetary values, currently at version 1.9.2. It provides a simple function to convert numbers into Chinese-currency formatted strings (e.g., 元, 角, 分). The package is lightweight with no dependencies and focuses on the specific niche of Chinese money formatting. It has not been updated since its release.

npm install az-money-formatter
INSTALL
IMPORT
SIG · AZ-MONEY-FORMATTER
A
az-money-formatter
financejavascriptv1.9.2
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.

default
import moneyFormat from 'az-money-formatter'
import { moneyFormat } from 'az-money-formatter'
The package exports a single default function.
default
const moneyFormat = require('az-money-formatter')
const { moneyFormat } = require('az-money-formatter')
In CommonJS, the default export is accessed via require, not destructuring.
moneyFormat (default)
const moneyFormat = require('az-money-formatter').default
For systems that treat default exports differently (e.g., some bundlers with esModuleInterop), you may need .default.

Formats a number into Chinese currency string using the single default export.

import moneyFormat from 'az-money-formatter'; const formatted = moneyFormat(1234.56); console.log(formatted); // => '壹仟贰佰叁拾肆元伍角陆分'
Debug
Known issues
gotchaInput must be a number; strings will return unexpected results.
fix
Ensure to parse strings to numbers: moneyFormat(parseFloat(input))
affects: >=1.0.0
gotchaOnly supports up to two decimal places (分). Fractions beyond hundredths are truncated.
fix
Use toFixed(2) or round before formatting: moneyFormat(Math.round(num * 100) / 100)
affects: >=1.0.0
gotchaNegative numbers are not handled; returns empty string or NaN.
fix
Check sign before formatting: if (num < 0) throw new Error('Negative not supported')
affects: >=1.0.0
breakingNo TypeScript declarations; manual declaration needed.
fix
Create a .d.ts file: declare module 'az-money-formatter';
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'az-money-formatter' or its corresponding type declarations.
Missing TypeScript declaration file for the package.
fix
Add a declaration file: // @ts-ignore or create a .d.ts with 'declare module "az-money-formatter"'
TypeError: moneyFormat is not a function
Incorrect import style (named import instead of default) or using .default incorrectly.
fix
Use default import: import moneyFormat from 'az-money-formatter'
moneyFormat(...) returns '' or 'NaN元'
Input is not a finite number or is negative.
fix
Validate input: if (typeof num !== 'number' || isNaN(num)) return '';
Upgrade
Version history
1.9.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
43 hits · last 30 days
node
36
Resources
az-money-formatter — npm install az-money-formatter · libregistry