1.0.6 • Published 7 months ago

currency-to-words-util v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

currency-to-words-util

currency-to-words is a lightweight library that converts numeric values into readable word formats, supporting multiple currencies with customizable configurations for main and subunits. Ideal for invoices, receipts, or financial applications.

Installation

Install the package via npm:

npm install currency-to-words-util

Or with Yarn:

yarn add currency-to-words-util

Importing

You can import the library into your project using ES6 imports:

import { convertToWords } from 'currency-to-words-util';

Usage

Here's how to use the library:

import currencyToWords from "currency-to-words-util";

const result = currencyToWords({
  value: 1234.56,
  suffix: true,
  currencyConfig: {
    mainUnit: "DOLLAR",
    subUnit: "CENT",
  },
});

console.log(result);
// Output: ONE THOUSAND TWO HUNDRED THIRTY-FOUR DOLLARS AND FIFTY-SIX CENTS ONLY

Options

currencyToWords({ value, suffix, currencyConfig })

ParameterTypeDefaultDescription
valuenumberundefinedThe amount to convert into words.
suffixstring , boolean (optional)"ONLY"The suffix to add at the end of the result (e.g., "ONLY").
currencyConfigCurrencyConfig (optional){ mainUnit: "RUPEE", subUnit: "PAISA" }Configuration for the main and subunits of the currency.

CurrencyConfig

PropertyTypeDescription
mainUnitstringName of the main currency unit (e.g., "DOLLAR").
subUnitstringName of the subunit (e.g., "CENT").

Features

  • Support for multiple currencies through customizable configurations.

  • Handles both whole numbers and fractional parts.

  • Lightweight and easy to integrate.

  • Fully customizable suffix and output formatting.

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago