This Node.js library provides functions to calculate Equated Monthly Installment (EMI) for loans and mortgages.
To install the library, use npm:
npm install emi-calculator
Below is an example of how to use the library:
const emiCalculator = require('emi-calculator');
const principal = 100000;
const annualInterestRate = 10;
const tenureInYears = 1;
const emi = emiCalculator.calculateEMI(principal, annualInterestRate, tenureInYears);
console.log('EMI:', emi);
const totalPayment = emiCalculator.calculateTotalPayment(emi, tenureInYears);
console.log('Total Payment:', totalPayment);
const totalInterest = emiCalculator.calculateTotalInterest(totalPayment, principal);
console.log('Total Interest:', totalInterest);
Calculates the Equated Monthly Installment (EMI).
principal
(number): The principal loan amountannualInterestRate
(number): The annual interest rate (in percentage)tenureInYears
(number): The loan tenure (in years)- Returns:
number
- The EMI amount
Calculates the total payment amount over the loan tenure.
emi
(number): The EMI amounttenureInYears
(number): The loan tenure (in years)- Returns:
number
- The total payment amount
Calculates the total interest paid over the loan tenure.
totalPayment
(number): The total payment amount over the tenureprincipal
(number): The principal loan amount- Returns:
number
- The total interest paid
To run the tests, use npm:
npm test