npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tvm-calculator

v2.0.0

Published

A library of financial calculator functions allowing easy incorporation of time value of money calculations into any application

Downloads

33

Readme

tvm-calculator

Introduction

The tvm-calculator package is a library of time value of money calculations that you would find on a financial calculator. This includes functions to find present value, future value, payment amount, number of payments, and interest rate given a set of input parameters.

Installation

Using npm:

$ npm i tvm-calculator

Note: add --save if you are using npm < 5.0.0

or

  • Download or fork the repository from GitHub.
  • Extract the file tvm-calculator from the project and include it in your application on the client side.

Example Usage

var tvmCalculator = require('tvm-calculator');

// Specify params as object
const tvmParams = { pv: -100000, fv: 0, nper: 30, rate: 4 };

// Calculate payment amount of a loan
const periodicPayment = tvmCalculator.calcPMT(tvmParams);

// Log calculated result (3508.33)
console.log('Payment amount (PMT): ', periodicPayment);

Parameters

Parameters are listed below. When solving for a value such as PMT, that parameter can be omitted. Parameters specified as "Optional" will default to the values described below. All parameters should be passed in as a single object.

rate, // Number: Interest Rate as whole number nper, // Number: Number of Periods in term pmt, // Number: Payment Amount pv, // Number: Present Value (should be entered as negative) fv, // Number: Future Value isBeginning, // Boolean: Is payment made at the BEGINNING of period? (Optional: defaults to false) isDiscrete, // Boolean: Is compounding DISCRETE? (Optional: defaults to true) cf, // Number: Compounding Frequency (Optional: defaults to 12 for monthly) pf, // Number: Payment Frequency (Optional: defaults to 12 for monthly)

Available Methods

Example method calls listed below. Further details to come.

calcNper

Calculate number of periods. Required params: rate, pmt, pv, fv.

const numberPeriods = tvmCalculator.calcNPer({ pv: -100000, fv: 0, pmt: 3508, rate: 4 });
console.log('Number of Periods (N)', numberPeriods); // 30.00

calcInterestRate

Calculate interest rate. Required params: nper, pmt, pv, fv.

const interestRate = tvmCalculator.calcInterestRate({ pv: -100000, fv: 0, nper: 30, pmt: 3508 });
console.log('Interest Rate (I/Y)', interestRate); // 3.993

calcPV

Calculate present value. Required params: nper, pmt, fv, rate.

const presentValue = tvmCalculator.calcPV({ nper: 30, fv: 0, pmt: 3508, rate: 4 });
console.log('Present Value (PV)', presentValue); // -99990.73

calcPMT

Calculate payment amount. Required params: nper, pv, fv, rate.

const paymentAmount = tvmCalculator.calcPMT({ pv: -100000, fv: 0, nper: 30, rate: 4 });
console.log('Payment Amount (PMT)', paymentAmount); // 3508.33

calcFV

Calculate future value. Required params: nper, pv, pmt, rate.

const futureValue = tvmCalculator.calcFV({ pv: -100000, pmt: 3508, nper: 30, rate: 4 });
console.log('Future Value (FV)', futureValue); // 10.24

Full Params Example:

const tvmParams = {
    pv: -100000,
    fv: 0,
    nper: 30,
    rate: 4,
    isBeginning: false,
    isDiscrete: true,
    cf: 1,
    pf: 1,
};
const periodicPayment = tvmCalculator.calcPMT(tvmParams);

console.log("Payment Amount (PMT): ", periodicPayment); // 5783.01

To Do

  • Add unit testing
  • Improve documentation