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

loan-extended

v0.0.44

Published

Tool for making calculations on loans

Downloads

58

Readme

loan-extended

Loan is a tool for representing and performing calculations on loans in JavaScript.

Table of contents

Features

  • Represent and serialize data about a loan
  • Calculate payment plans
  • Effective interest rate
  • Total loan cost
  • Amortize a defined loan according to the payment plan
  • Etc
  • Deferred
  • Balloon Payment

Example

var Loan = require('loan');

// set up a monthly annuity loan with 120 instalments until settled
var loan = new Loan({
  type: 'annuity',
  pay_every: 'month',
  principal: 100000,
  interest_rate: 0.05,
  invoice_fee: 25,
  instalments: 120,
  // ballon_at: 60
});

// 0.0565
console.log(loan.getEffectiveInterestRate());

Installation

Loan can be installed with npm npm install in your shell should suffice.

Version history

  • v0.0.43 2023-06-27 Initial (beta) release.

Class documentation

A comprehensive class documentation made with jsdoc is available at loan.tedeh.net together with this readme.

Usage

This section is a friendly showcase of some of the features a loan object has. For more in-depth information, peruse the source code, the tests, or the [class documentation][#class-documentation]

Effective interest rate

Payment Plan

A payment plan is a list of loans relating to the current instance, where every loan in the list corresponds to a

To return a payment plan for a loan instance,

Filtering

Completing unknown values

Sometimes not all values of a given loan are known, and it would be useful to infer the unknowns. Loan has a limited capability (more to come) to do this:

| Value | Requirements | Description | |---------------|----------------------------------------------------------|--------------------------------------------------------------| | instalments | 1) principal 2) interest_rate 3) data.monthly_cost | Calculate the number of instalments left for an annuity loan |

Example calculating instalments given some other values:

var Loan = require('loan');

var loan = new Loan({
  principal: 50000,
  interst_rate: 0.05,
  data: {monthly_cost: 3000}
});

loan.canCalculateUnknown('instalments');
// returns true

loan.calculateUnknown();
// returns an object with a single property "instalments" corresponding to the wanted value

Amortizing

When the as_of date on a loan instance is earlier in time than one (1) pay_every period, shouldAmortize returns true. Running amortize when this is the case returns a copy of the current loan with the present value updated. The as_of date is also updated to correspond to the start of the current pay_every period.

Example amortizing an older loan:

var Loan = require('loan');
var moment = require('moment');

var loan = new Loan({
  interest_rate: 0.01,
  principal: 10000,
  pay_every: 'month',
  instalments: 10,
  type: 'annuity',
  as_of: moment().subtract(3, 'months').toDate()
});

loan.shouldAmortize();
// returns true

loan.amortize();
// returns a copy of loan but with values following three months of amortization

Example fully amortizing a loan:

var Loan = require('loan');
var moment = require('moment');

var loan = new Loan({
  interest_rate: 0.01,
  principal: 10000,
  pay_every: 'month',
  instalments: 2, // only 2 instalments left
  type: 'annuity',
  as_of: moment().subtract(5, 'months').toDate()
});

loan.shouldAmortize();
// returns true

loan.amortize();
// returns a copy of loan with a principal equal to zero

Contributing

Fork of tedeh's loan

requests on Github is most welcome.

Please make sure to follow the style of the project, lint your code with make lint, and test it with make test before submitting a patch.