Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "fp-money", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"private": false, | ||
@@ -44,3 +44,3 @@ "description": "FluidPay input formatter and currency selector", | ||
"vue": "^3.2.39", | ||
"vue-loader": "^17.0.0", | ||
"vue-loader": "^17.1.1", | ||
"vue-router": "^4.1.5", | ||
@@ -47,0 +47,0 @@ "vue-template-compiler": "^2.7.10", |
@@ -132,2 +132,3 @@ export interface Currencies { | ||
// bankersRounding handles rounding a number using bankers rounding. | ||
export function bankersRounding(num: number, fraction: number): number { | ||
@@ -144,1 +145,30 @@ const d = fraction || 0 | ||
} | ||
// originalNumberFromPercentage takes in a number and a percentage and | ||
// calculates what the original number was multiplied by the percentage to get | ||
// the passed in number. | ||
export function originalNumberFromPercentage(number: number, percentage: number, fraction: number): number { | ||
// Get a clean number from either string or number | ||
const numberStr = number.toString() | ||
if (numberStr.trim() === '') { | ||
return 0 | ||
} | ||
number = parseFloat(numberStr) | ||
// Get a clean percentage from either string or number | ||
const percentageStr = percentage.toString() | ||
if (percentageStr.trim() === '') { | ||
return 0 | ||
} | ||
percentage = parseFloat(percentageStr) | ||
// Get fraction multiplier | ||
let multi = '1' | ||
for (let i = 0; i < fraction; i++) { | ||
multi += '0' | ||
} | ||
const multiInt = parseInt(multi, 10) | ||
const percentageValue = 1 + percentage / 100 | ||
return Math.round(Number((number / percentageValue).toFixed(5)) * multiInt) / multiInt | ||
} |
const path = require('path') | ||
const MiniCssExtractPlugin = require("mini-css-extract-plugin") | ||
const VueLoaderPlugin = require('vue-loader/lib/plugin') | ||
const { VueLoaderPlugin } = require('vue-loader') | ||
@@ -5,0 +5,0 @@ module.exports = { |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6555110
56
4290
1