🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more
Socket
Book a DemoInstallSign in
Socket

financial-utils

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry
One or more versions of this package were compromised as part of the ongoing “North Korea’s Contagious Interview Campaign” supply chain attack.

financial-utils

A lightweight Node.js utility library for common financial operations like currency formatting, tax calculation, currency conversion, and loan EMI computation.

latest
npmnpm
Version
1.0.2
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

💸 financial-utils

A lightweight and easy-to-use Node.js module that provides practical financial utility functions including:

  • Currency formatting
  • Tax calculation
  • Currency conversion (mock)
  • Loan EMI (Equated Monthly Installment) computation

📦 Installation

To install the module via npm, run the following command in your terminal:

npm install financial-utils

🚀 Usage

Once installed, you can use the module in your Node.js project as shown below:

const {
  formatCurrency,
  calculateTax,
  convertCurrency,
  calculateEMI,
} = require('financial-utils');

// Format currency
console.log(formatCurrency(1234.56));                      // $1,234.56
console.log(formatCurrency(1234.56, 'EUR', 'de-DE'));      // 1.234,56 €

// Calculate tax
console.log(calculateTax(1000, 0.2));                      // 200.00

// Convert currency (mock rate)
console.log(convertCurrency(100, 1.13));                   // 113.00

// Calculate EMI
console.log(calculateEMI(10000, 7.5, 12));                 // 865.27

📚 API Reference

formatCurrency(amount, currency = 'USD', locale = 'en-US') Formats a number into a localized currency string.

  • amount number: The amount to format.
  • currency string (optional): The ISO 4217 currency code (e.g., USD, EUR). Defaults to 'USD'.
  • locale string (optional): The BCP 47 language tag for localization (e.g., en-US, de-DE). Defaults to 'en-US'.

Example

formatCurrency(1234.56);               // $1,234.56
formatCurrency(1234.56, 'EUR', 'de-DE'); // 1.234,56 €

calculateTax(amount, rate) Calculates tax based on a percentage rate.

  • amount number: The amount on which tax will be calculated.
  • rate number: The tax rate as a decimal (e.g., 0.2 for 20%).

Example

calculateTax(1000, 0.2); // 200.00

calculateEMI(principal, annualRate, months) Calculates the Equated Monthly Installment (EMI) for a loan.

  • principal number: The loan amount.
  • annualRate number: The annual interest rate as a percentage (e.g., 7.5 for 7.5%).
  • months number: The loan duration in months.

Example

calculateEMI(10000, 7.5, 12); // 865.27

✅ Example Use Cases

This module can be used in various financial applications, including:

  • 🛒 E-commerce: Displaying product prices in various currencies.
  • 🧾 Taxation: Applying tax rates to invoices and receipts.
  • 💵 Currency Conversion: Converting amounts between different currencies (mock functionality).
  • 🏦 Loan Calculators: Calculating EMI (monthly payments) for loans.

📁 Project Structure

The project follows a modular structure with separate files for each financial utility function:

financial-utils/
├── index.js           # Main entry point
├── currency.js        # Currency-related functions (e.g., formatCurrency, convertCurrency)
├── tax.js             # Tax-related function (e.g., calculateTax)
├── loan.js            # Loan-related function (e.g., calculateEMI)
├── test.js            # Test script for demonstration
└── package.json       # Project metadata and dependencies

📄 License

This module is licensed under the MIT License.

Keywords

finance

FAQs

Package last updated on 08 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts