2.5.0 • Published 6 months ago
node-debt-snowball v2.5.0
node-debt-snowball
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 strategy = 'avalanche'; // possible values: avalanche (default), snowball
const repaymentPlan = snowball(accounts, additionalPayment, strategy);
console.log('repaymentPlan', repaymentPlan);
Strategies
There are two options for the strategy
argument:
avalanche
- This strategy applies additional payments to the account with the highest interest rate. This is the default valuesnowball
- This strategy focuses on paying off the account with the lowest balance first
For additional information on these strategies read more on Investopedia.
API
Full API documentation is available can be found at https://nielse63.github.io/node-debt-snowball
Response Schema
{
"totalInterestPaid": "number",
"totalPayments": "number",
"strategy": "string",
"payments": [
{
"balance": "number",
"accounts": [
{
"name": "string",
"balanceStart": "number",
"balanceEnd": "number",
"accruedInterest": "number",
"additionalPayment": "number",
"paymentAmount": "number"
}
]
}
]
}
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 v20.13.1
:
nvm use v20.13.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 |
2.5.0
6 months ago
2.4.0
6 months ago
2.3.2
7 months ago
2.3.4
7 months ago
2.3.3
7 months ago
2.3.0
7 months ago
2.3.1
7 months ago
2.2.0
7 months ago
2.1.2
7 months ago
2.1.1
7 months ago
2.1.4
7 months ago
2.1.3
7 months ago
2.1.5
7 months ago
2.1.0
1 year ago
1.2.0
2 years ago
2.0.0
2 years ago
1.2.1
2 years ago
1.1.0
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago