bankers-math
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -6,2 +6,3 @@ | ||
const E = 1e-8 | ||
const DIFFRA_EQ = 'Equilibrium' | ||
const DIFFRA_PROPORT = 'Proportionality' | ||
@@ -17,2 +18,3 @@ const DIFFRA_PAYOFF = 'Payoff' | ||
NA, | ||
DIFFRA_EQ | ||
DIFFRA_PROPORT, | ||
@@ -74,11 +76,17 @@ DIFFRA_PAYOFF, | ||
if ( normalisationMethod && normalisationMethod !== NA && feeTotal > amount ) { | ||
if ( normalisationMethod === DIFFRA_PROPORT ) { | ||
feeValues = Services.divide( amount, feeValues, rounding ) | ||
} else if ( normalisationMethod === DIFFRA_PAYOFF ) { | ||
let toCut = feeTotal - amount | ||
for (let i = feeValues.length - 1; toCut > 0 && i >= 0; ++i) { | ||
let tc = toCut <= feeValues[i] ? toCut : feeValues[i] | ||
feeValues[i] -= tc | ||
toCut -= tc | ||
if ( normalisationMethod && normalisationMethod !== NA ) { | ||
if (feeTotal < amount) { | ||
if ( normalisationMethod === DIFFRA_EQ ) | ||
feeValues = Services.divide( amount, feeValues, rounding ) | ||
} | ||
else if (feeTotal > amount) { | ||
if ( normalisationMethod === DIFFRA_PROPORT ) { | ||
feeValues = Services.divide( amount, feeValues, rounding ) | ||
} else if ( normalisationMethod === DIFFRA_PAYOFF ) { | ||
let toCut = feeTotal - amount | ||
for (let i = feeValues.length - 1; toCut > 0 && i >= 0; ++i) { | ||
let tc = toCut <= feeValues[i] ? toCut : feeValues[i] | ||
feeValues[i] -= tc | ||
toCut -= tc | ||
} | ||
} | ||
@@ -85,0 +93,0 @@ } |
{ | ||
"name": "bankers-math", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Helper function for Bankers' calculus", | ||
@@ -25,3 +25,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"jest": "^27.4.7" | ||
"jest": "^27.5.1" | ||
}, | ||
@@ -28,0 +28,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11300
299