0.2.1 • Published 6 months ago
qansigliere-splitbills v0.2.1
Split Bills | Split Payments
The library is based on the Javascript programming language and allows you to calculate different number of split bills and tips based on the initial amount. You just need to specify amount, number of payments, should we calculate tips and percentage of tips
Author
https://www.youtube.com/@QANSIGLIERE/
Support the project
https://buymeacoffee.com/qansigliere
Installing
Using npm:
npm i qansigliere-splitbills
Functions
splitBills(initialAmount, numberOfPayments, withTips, tipsRatePercent)
- This function calculates the amount of each
individual payment based on the specified initial amount and the number of expected payments. Plus it can calculate a
tip for each payment if needed.
Example
CommonJS
var { splitBills } = require('qansigliere-splitbills');
console.log(JSON.stringify(splitBills(1.31, 4, true, 15)));
console.log(JSON.stringify(splitBills(0.01, 2, true, 15, false))); // Error message turned off
Output
[{"amount":0.33,"tips":0.05},{"amount":0.33,"tips":0.05},{"amount":0.33,"tips":0.05},{"amount":0.32,"tips":0.05}]
[{"amount":0.01,"tips":0}]
ES Module
import { splitBills } from 'qansigliere-splitbills';
console.log(JSON.stringify(splitBills(1.31, 4, true, 15)));
console.log(JSON.stringify(splitBills(0.01, 2, true, 15, false))); // Error message turned off
Output
[{"amount":0.33,"tips":0.05},{"amount":0.33,"tips":0.05},{"amount":0.33,"tips":0.05},{"amount":0.32,"tips":0.05}]
[{"amount":0.01,"tips":0}]