node-debt-snowball
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

node-debt-snowball

GitHub Workflow Status Depfu Codecov GitHub issues by-label GitHub

Node script to calculate debt repayment using the snowball method

Features

  • Fully tested with 100% code coverage
  • Module and CommonJS compatible
  • Nightly builds to evaluate accuracy
  • Lightweight - completely dependency free

Installation

npm install node-debt-snowball

Usage

Basic Usage

import snowball from 'node-debt-snowball';

const accounts = [
  {
    name: 'Credit Card',
    interest: 14.99,
    balance: 1000,
    minPayment: 75,
  },
  {
    name: 'Student Loan',
    interest: 4.75,
    balance: 7500,
    minPayment: 150,
  },
];
const additionalPayment = 100;

const repaymentPlan = snowball(accounts, additionalPayment);
console.log('repaymentPlan', repaymentPlan);

API

Full API documentation is available can be found in the docs/ directory.

Response Schema

[
  {
    "balance": "number",
    "accounts": [
      {
        "name": "string",
        "startingBalance": "number",
        "endingBalance": "number",
        "accruedInterest": "number",
        "additionalPayment": "number",
        "paymentAmount": "number"
      }
      // more accounts...
    ]
  }
  // more payment periods...
]

A full sample response can be found at examples/response.json.

Contributing

Clone the repo and install the dependencies:

git clone https://github.com/nielse63/node-debt-snowball.git
cd node-debt-snowball
npm ci

Prerequisites

Node v16.20.1:

nvm use v16.20.1

NPM Scripts

Script Description
npm run lint Lint and autofix source files
npm run build Compile the TypeScript source to the dist directory
npm test Runs unit tests with Jest
npm run dev Executes the example script, saving the response to the file system
npm run docs Builds the documentation

Package Sidebar

Install

npm i node-debt-snowball

Weekly Downloads

4

Version

2.1.0

License

MIT

Unpacked Size

29.6 kB

Total Files

19

Last publish

Collaborators

  • nielse63