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

businessjs

v1.2.2

Published

Fast and accurate business and financial calculations in JavaScript.

Downloads

6

Readme

businessjs

A new finance library for javascript. Intended to improve the workflow of JavaScript developers who are also in the finance industry. The package includes nice helper functions to quickly get values for ratio analysis, time value of money, managerial calculations etc.

Currently version 1.x.x only has Time Value of Money

To get started

npm install businessjs

get CDN

<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/index.min.js"></script>

This will give you the package available for use in any front-end or Node.js environment.

Guide

Time Value of money

Import syntax:

import businessjs from 'businessjs';

In node environment:

const businessjs = require('businessjs');
const tvm = businessjs.tvm;

Browser support from node_modules

Using the CDN is recommended though.

<!DOCTYPE html>
<html>
  <head>
    <script src="node_modules/businessjs/build/index.js"></script>
  </head>
  <body></body>
</html>

This should create the instance globally on the window

<script>
  const tvm = businessjs.tvm;
</script>

Time Value of Money

Methods

futureValue = function(presentValue, interest, [numPeriods = 1, perPeriod = 1])

  • Requires the present value and effective interest in decimal format and returns a future value based on a number of periods.
  • numPeriods defaults to 1 as in 1 year.
  • perPeriod The amount of times an interest rate is compounded defaults to 1.

presentValue = function(futureValue, interest, [numPeriods = 1, perPeriod = 1])

  • Requires the present value and interest in decimal format and returns a future value.
  • numPeriods defaults to 1 as in 1 year.
  • perPeriod The amount of times an interest rate is compounded defaults to 1.

numPeriods = function(presentValue, futureValue, interest, [perPeriod = 1])

  • Returns the number of periods that an investment / loan would take to realise, pay off.
  • perPeriod The amount of times an interest rate is compounded defaults to 1.

interest = function(presentValue, futureValue, [numPeriods = 1, perPeriod = 1])

  • Returns the interest rate of a given investment/loan.
  • numPeriods defaults to 1 as in 1 year.
  • perPeriod The amount of times an interest rate is compounded defaults to 1.

futureValueAnnuityDue = function(payment, interest, [numPeriods = 1, perPeriod = 1])

  • Returns the future value of an annuity paid at the end of every cycle with an effective interest rate.
  • numPeriods defaults to 1 as in 1 year.
  • perPeriod The amount of times an interest rate is compounded defaults to 1.

futureValueAnnuityAdvance = function(payment, interest, [numPeriods = 1, perPeriod = 1])

  • Returns the future value of an annuity paid at the beginning of every cycle with an effective interest rate.
  • numPeriods defaults to 1 as in 1 year.
  • perPeriod The amount of times an interest rate is compounded defaults to 1.

presentValueAnnuityDue = function(payment, interest, [numPeriods = 1, perPeriod = 1])

  • Returns the present value of an annuity paid at the end of every cycle with an effective interest rate.
  • numPeriods defaults to 1 as in 1 year.
  • perPeriod The amount of times an interest rate is compounded defaults to 1.

presentValueAnnuityAdvance = function(payment, interest, [numPeriods = 1, perPeriod = 1])

  • Returns the present value of an annuity paid at the beginning of every cycle with an effective interest rate.
  • numPeriods defaults to 1 as in 1 year.
  • perPeriod The amount of times an interest rate is compounded defaults to 1.

effectiveRate = function(nominalRate, perPeriod)

  • Returns the annual effective interest rate from a nominal rate and per-period compund amount.
  • Useful because all other functions use effective rate, eg.
const tvm = require('businessjs').tvm;

// Convert the monthly nominal rate to yearly effective inline
tvm.futureValue(100, tvm.effectiveRate(0.1, 12), 1, 1);

amortisation = function(presentValue, interest, [numPeriods=1, perPeriod=12])

  • Returns an array of objects that have the following shape:
{
  period,
  payment,
  interestPortion,
  principlePortion,
  totalBalance,
  principleBalance
}
  • Returns the tabular data of an amortisation with breakdown of interest and principle amounts.
  • numPeriods defaults to 1 as in 1 year.
  • perPeriod The amount of times an interest rate is compounded defaults to 12 payments per year.

These are just the first few methods in version 1, Documentation will be updated as version improves.