Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-big-decimal

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-big-decimal - npm Package Compare versions

Comparing version 1.2.4 to 1.3.0

2

dist/node/big-decimal.d.ts

@@ -24,2 +24,4 @@ import { RoundingModes as Modes } from './roundingModes';

divide(number: bigDecimal, precision: any): bigDecimal;
static modulus(number1: any, number2: any): string;
modulus(number: bigDecimal): bigDecimal;
static compareTo(number1: any, number2: any): 0 | 1 | -1;

@@ -26,0 +28,0 @@ compareTo(number: bigDecimal): 0 | 1 | -1;

447

dist/node/js-big-decimal.js

@@ -94,3 +94,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 3);
/******/ return __webpack_require__(__webpack_require__.s = 6);
/******/ })

@@ -380,171 +380,2 @@ /************************************************************************/

var add_1 = __webpack_require__(0);
var round_1 = __webpack_require__(1);
var multiply_1 = __webpack_require__(4);
var divide_1 = __webpack_require__(5);
var compareTo_1 = __webpack_require__(6);
var subtract_1 = __webpack_require__(7);
var roundingModes_1 = __webpack_require__(2);
var bigDecimal = /** @class */ (function () {
function bigDecimal(number) {
if (number === void 0) { number = '0'; }
this.value = bigDecimal.validate(number);
}
bigDecimal.validate = function (number) {
if (number) {
number = number.toString();
if (isNaN(number))
throw Error("Parameter is not a number: " + number);
if (number[0] == '+')
number = number.substring(1);
}
else
number = '0';
//handle exponentiation
if (/e/i.test(number)) {
var _a = number.split(/[eE]/), mantisa = _a[0], exponent = _a[1];
mantisa = add_1.trim(mantisa);
exponent = parseInt(exponent) + mantisa.indexOf('.');
mantisa = mantisa.replace('.', '');
if (mantisa.length < exponent) {
number = mantisa + (new Array(exponent - mantisa.length + 1)).join('0');
}
else if (mantisa.length >= exponent && exponent > 0) {
number = add_1.trim(mantisa.substring(0, exponent)) +
((mantisa.length > exponent) ? ('.' + mantisa.substring(exponent)) : '');
}
else {
number = '0.' + (new Array(-exponent + 1)).join('0') + mantisa;
}
}
return number;
};
bigDecimal.prototype.getValue = function () {
return this.value;
};
bigDecimal.getPrettyValue = function (number, digits, separator) {
if (!(digits || separator)) {
digits = 3;
separator = ',';
}
else if (!(digits && separator)) {
throw Error('Illegal Arguments. Should pass both digits and separator or pass none');
}
number = bigDecimal.validate(number);
var neg = number.charAt(0) == '-';
if (neg)
number = number.substring(1);
var len = number.indexOf('.');
len = len > 0 ? len : (number.length);
var temp = '';
for (var i = len; i > 0;) {
if (i < digits) {
digits = i;
i = 0;
}
else
i -= digits;
temp = number.substring(i, i + digits) + ((i < (len - digits) && i >= 0) ? separator : '') + temp;
}
return (neg ? '-' : '') + temp + number.substring(len);
};
bigDecimal.prototype.getPrettyValue = function (digits, separator) {
return bigDecimal.getPrettyValue(this.value, digits, separator);
};
bigDecimal.round = function (number, precision, mode) {
if (precision === void 0) { precision = 0; }
if (mode === void 0) { mode = roundingModes_1.RoundingModes.HALF_EVEN; }
number = bigDecimal.validate(number);
if (isNaN(precision))
throw Error("Precision is not a number: " + precision);
return round_1.roundOff(number, precision, mode);
};
bigDecimal.prototype.round = function (precision, mode) {
if (precision === void 0) { precision = 0; }
if (mode === void 0) { mode = roundingModes_1.RoundingModes.HALF_EVEN; }
if (isNaN(precision))
throw Error("Precision is not a number: " + precision);
return new bigDecimal(round_1.roundOff(this.value, precision, mode));
};
bigDecimal.floor = function (number) {
number = bigDecimal.validate(number);
if (number.indexOf('.') === -1)
return number;
return bigDecimal.round(number, 0, roundingModes_1.RoundingModes.FLOOR);
};
bigDecimal.prototype.floor = function () {
if (this.value.indexOf('.') === -1)
return new bigDecimal(this.value);
return new bigDecimal(this.value).round(0, roundingModes_1.RoundingModes.FLOOR);
};
bigDecimal.ceil = function (number) {
number = bigDecimal.validate(number);
if (number.indexOf('.') === -1)
return number;
return bigDecimal.round(number, 0, roundingModes_1.RoundingModes.CEILING);
};
bigDecimal.prototype.ceil = function () {
if (this.value.indexOf('.') === -1)
return new bigDecimal(this.value);
return new bigDecimal(this.value).round(0, roundingModes_1.RoundingModes.CEILING);
};
bigDecimal.add = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return add_1.add(number1, number2);
};
bigDecimal.prototype.add = function (number) {
return new bigDecimal(add_1.add(this.value, number.getValue()));
};
bigDecimal.subtract = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return subtract_1.subtract(number1, number2);
};
bigDecimal.prototype.subtract = function (number) {
return new bigDecimal(subtract_1.subtract(this.value, number.getValue()));
};
bigDecimal.multiply = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return multiply_1.multiply(number1, number2);
};
bigDecimal.prototype.multiply = function (number) {
return new bigDecimal(multiply_1.multiply(this.value, number.getValue()));
};
bigDecimal.divide = function (number1, number2, precision) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return divide_1.divide(number1, number2, precision);
};
bigDecimal.prototype.divide = function (number, precision) {
return new bigDecimal(divide_1.divide(this.value, number.getValue(), precision));
};
bigDecimal.compareTo = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return compareTo_1.compareTo(number1, number2);
};
bigDecimal.prototype.compareTo = function (number) {
return compareTo_1.compareTo(this.value, number.getValue());
};
bigDecimal.negate = function (number) {
number = bigDecimal.validate(number);
return subtract_1.negate(number);
};
bigDecimal.prototype.negate = function () {
return new bigDecimal(subtract_1.negate(this.value));
};
bigDecimal.RoundingModes = roundingModes_1.RoundingModes;
return bigDecimal;
}());
module.exports = bigDecimal;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -655,3 +486,3 @@ exports.multiply = void 0;

/***/ }),
/* 5 */
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

@@ -751,2 +582,30 @@

/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.negate = exports.subtract = void 0;
var add_1 = __webpack_require__(0);
function subtract(number1, number2) {
number1 = number1.toString();
number2 = number2.toString();
number2 = negate(number2);
return add_1.add(number1, number2);
}
exports.subtract = subtract;
function negate(number) {
if (number[0] == '-') {
number = number.substr(1);
}
else {
number = '-' + number;
}
return number;
}
exports.negate = negate;
/***/ }),
/* 6 */

@@ -757,3 +616,221 @@ /***/ (function(module, exports, __webpack_require__) {

var add_1 = __webpack_require__(0);
var round_1 = __webpack_require__(1);
var multiply_1 = __webpack_require__(3);
var divide_1 = __webpack_require__(4);
var modulus_1 = __webpack_require__(7);
var compareTo_1 = __webpack_require__(8);
var subtract_1 = __webpack_require__(5);
var roundingModes_1 = __webpack_require__(2);
var bigDecimal = /** @class */ (function () {
function bigDecimal(number) {
if (number === void 0) { number = '0'; }
this.value = bigDecimal.validate(number);
}
bigDecimal.validate = function (number) {
if (number) {
number = number.toString();
if (isNaN(number))
throw Error("Parameter is not a number: " + number);
if (number[0] == '+')
number = number.substring(1);
}
else
number = '0';
//handle exponentiation
if (/e/i.test(number)) {
var _a = number.split(/[eE]/), mantisa = _a[0], exponent = _a[1];
mantisa = add_1.trim(mantisa);
exponent = parseInt(exponent) + mantisa.indexOf('.');
mantisa = mantisa.replace('.', '');
if (mantisa.length < exponent) {
number = mantisa + (new Array(exponent - mantisa.length + 1)).join('0');
}
else if (mantisa.length >= exponent && exponent > 0) {
number = add_1.trim(mantisa.substring(0, exponent)) +
((mantisa.length > exponent) ? ('.' + mantisa.substring(exponent)) : '');
}
else {
number = '0.' + (new Array(-exponent + 1)).join('0') + mantisa;
}
}
return number;
};
bigDecimal.prototype.getValue = function () {
return this.value;
};
bigDecimal.getPrettyValue = function (number, digits, separator) {
if (!(digits || separator)) {
digits = 3;
separator = ',';
}
else if (!(digits && separator)) {
throw Error('Illegal Arguments. Should pass both digits and separator or pass none');
}
number = bigDecimal.validate(number);
var neg = number.charAt(0) == '-';
if (neg)
number = number.substring(1);
var len = number.indexOf('.');
len = len > 0 ? len : (number.length);
var temp = '';
for (var i = len; i > 0;) {
if (i < digits) {
digits = i;
i = 0;
}
else
i -= digits;
temp = number.substring(i, i + digits) + ((i < (len - digits) && i >= 0) ? separator : '') + temp;
}
return (neg ? '-' : '') + temp + number.substring(len);
};
bigDecimal.prototype.getPrettyValue = function (digits, separator) {
return bigDecimal.getPrettyValue(this.value, digits, separator);
};
bigDecimal.round = function (number, precision, mode) {
if (precision === void 0) { precision = 0; }
if (mode === void 0) { mode = roundingModes_1.RoundingModes.HALF_EVEN; }
number = bigDecimal.validate(number);
if (isNaN(precision))
throw Error("Precision is not a number: " + precision);
return round_1.roundOff(number, precision, mode);
};
bigDecimal.prototype.round = function (precision, mode) {
if (precision === void 0) { precision = 0; }
if (mode === void 0) { mode = roundingModes_1.RoundingModes.HALF_EVEN; }
if (isNaN(precision))
throw Error("Precision is not a number: " + precision);
return new bigDecimal(round_1.roundOff(this.value, precision, mode));
};
bigDecimal.floor = function (number) {
number = bigDecimal.validate(number);
if (number.indexOf('.') === -1)
return number;
return bigDecimal.round(number, 0, roundingModes_1.RoundingModes.FLOOR);
};
bigDecimal.prototype.floor = function () {
if (this.value.indexOf('.') === -1)
return new bigDecimal(this.value);
return new bigDecimal(this.value).round(0, roundingModes_1.RoundingModes.FLOOR);
};
bigDecimal.ceil = function (number) {
number = bigDecimal.validate(number);
if (number.indexOf('.') === -1)
return number;
return bigDecimal.round(number, 0, roundingModes_1.RoundingModes.CEILING);
};
bigDecimal.prototype.ceil = function () {
if (this.value.indexOf('.') === -1)
return new bigDecimal(this.value);
return new bigDecimal(this.value).round(0, roundingModes_1.RoundingModes.CEILING);
};
bigDecimal.add = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return add_1.add(number1, number2);
};
bigDecimal.prototype.add = function (number) {
return new bigDecimal(add_1.add(this.value, number.getValue()));
};
bigDecimal.subtract = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return subtract_1.subtract(number1, number2);
};
bigDecimal.prototype.subtract = function (number) {
return new bigDecimal(subtract_1.subtract(this.value, number.getValue()));
};
bigDecimal.multiply = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return multiply_1.multiply(number1, number2);
};
bigDecimal.prototype.multiply = function (number) {
return new bigDecimal(multiply_1.multiply(this.value, number.getValue()));
};
bigDecimal.divide = function (number1, number2, precision) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return divide_1.divide(number1, number2, precision);
};
bigDecimal.prototype.divide = function (number, precision) {
return new bigDecimal(divide_1.divide(this.value, number.getValue(), precision));
};
bigDecimal.modulus = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return modulus_1.modulus(number1, number2);
};
bigDecimal.prototype.modulus = function (number) {
return new bigDecimal(modulus_1.modulus(this.value, number.getValue()));
};
bigDecimal.compareTo = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return compareTo_1.compareTo(number1, number2);
};
bigDecimal.prototype.compareTo = function (number) {
return compareTo_1.compareTo(this.value, number.getValue());
};
bigDecimal.negate = function (number) {
number = bigDecimal.validate(number);
return subtract_1.negate(number);
};
bigDecimal.prototype.negate = function () {
return new bigDecimal(subtract_1.negate(this.value));
};
bigDecimal.RoundingModes = roundingModes_1.RoundingModes;
return bigDecimal;
}());
module.exports = bigDecimal;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.modulus = void 0;
var divide_1 = __webpack_require__(4);
var round_1 = __webpack_require__(1);
var multiply_1 = __webpack_require__(3);
var subtract_1 = __webpack_require__(5);
var roundingModes_1 = __webpack_require__(2);
function modulus(dividend, divisor) {
if (divisor == 0) {
throw new Error('Cannot divide by 0');
}
dividend = dividend.toString();
divisor = divisor.toString();
validate(dividend);
validate(divisor);
var sign = '';
if (dividend[0] == '-') {
sign = '-';
dividend = dividend.substr(1);
}
if (divisor[0] == '-') {
divisor = divisor.substr(1);
}
var result = subtract_1.subtract(dividend, multiply_1.multiply(divisor, round_1.roundOff(divide_1.divide(dividend, divisor), 0, roundingModes_1.RoundingModes.FLOOR)));
return sign + result;
}
exports.modulus = modulus;
function validate(oparand) {
if (oparand.indexOf('.') != -1) {
throw new Error('Modulus of non-integers not supported');
}
}
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compareTo = void 0;

@@ -805,32 +882,4 @@ var add_1 = __webpack_require__(0);

/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.negate = exports.subtract = void 0;
var add_1 = __webpack_require__(0);
function subtract(number1, number2) {
number1 = number1.toString();
number2 = number2.toString();
number2 = negate(number2);
return add_1.add(number1, number2);
}
exports.subtract = subtract;
function negate(number) {
if (number[0] == '-') {
number = number.substr(1);
}
else {
number = '-' + number;
}
return number;
}
exports.negate = negate;
/***/ })
/******/ ]);
});

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.bigDecimal=t():e.bigDecimal=t()}(global,function(){return r={},i.m=n=[function(e,t,n){"use strict";function u(e){for(var t="",n=e.length,r=e.split(".")[1],i=r?r.length:0,o=0;o<n;o++)"0"<=e[o]&&e[o]<="9"?t+=9-parseInt(e[o]):t+=e[o];return d(t,0<i?"0."+new Array(i).join("0")+"1":"1")}function a(e){var t=e.split(".");for(t[0]||(t[0]="0");"0"==t[0][0]&&1<t[0].length;)t[0]=t[0].substring(1);return t[0]+(t[1]?"."+t[1]:"")}function s(e,t){var n=e.split("."),r=t.split("."),i=n[0].length,o=r[0].length;return o<i?r[0]=new Array(Math.abs(i-o)+1).join("0")+(r[0]?r[0]:""):n[0]=new Array(Math.abs(i-o)+1).join("0")+(n[0]?n[0]:""),i=n[1]?n[1].length:0,o=r[1]?r[1].length:0,(i||o)&&(o<i?r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-o)+1).join("0"):n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-o)+1).join("0")),[e=n[0]+(n[1]?"."+n[1]:""),t=r[0]+(r[1]?"."+r[1]:"")]}function d(e,t){var n=s(e,t);e=n[0],t=n[1];for(var r,i="",o=0,u=e.length-1;0<=u;u--){"."!==e[u]?(i=(r=parseInt(e[u])+parseInt(t[u])+o)%10+i,o=Math.floor(r/10)):i="."+i}return o?o.toString()+i:i}Object.defineProperty(t,"__esModule",{value:!0}),t.pad=t.trim=t.add=void 0,t.add=function(e,t){var n;void 0===t&&(t="0");var r=0,i=-1;"-"==e[0]&&(r++,i=1,(e=e.substring(1)).length),"-"==t[0]&&(r++,i=2,(t=t.substring(1)).length),e=a(e),t=a(t),e=(n=s(a(e),a(t)))[0],t=n[1],1==r&&(1==i?e=u(e):t=u(t));var o=d(e,t);return r?2==r?"-"+a(o):e.length<o.length?a(o.substring(1)):"-"+a(u(o)):a(o)},t.trim=a,t.pad=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.roundOff=void 0;var l=n(2);function f(e,t,n,r){if(e&&e!==new Array(e.length+1).join("0")&&!(r===l.RoundingModes.DOWN||!n&&r===l.RoundingModes.FLOOR||n&&r===l.RoundingModes.CEILING)){if(r===l.RoundingModes.UP||n&&r===l.RoundingModes.FLOOR||!n&&r===l.RoundingModes.CEILING)return 1;var i="5"+new Array(e.length).join("0");if(i<e)return 1;if(!(e<i))switch(r){case l.RoundingModes.HALF_DOWN:return;case l.RoundingModes.HALF_UP:return 1;case l.RoundingModes.HALF_EVEN:default:return parseInt(t[t.length-1])%2==1}}}function g(e,t){void 0===t&&(t=0),t=t||1,"number"==typeof e&&e.toString();for(var n="",r=e.length-1;0<=r;r--){var i=parseInt(e[r])+t;10==i?(t=1,i=0):t=0,n+=i}return t&&(n+=t),n.split("").reverse().join("")}t.roundOff=function e(t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=l.RoundingModes.HALF_EVEN),r===l.RoundingModes.UNNECESSARY)throw new Error("UNNECESSARY Rounding Mode has not yet been implemented");"number"==typeof t&&(t=t.toString());var i=!1;"-"===t[0]&&(i=!0,t=t.substring(1));var o=t.split("."),u=o[0],a=o[1];if(n<0){if(n=-n,u.length<=n)return"0";var s=u.substr(0,u.length-n);return(i?"-":"")+e(t=s+"."+u.substr(u.length-n)+a,0,r)+new Array(n+1).join("0")}if(0==n)return u.length,f(o[1],u,i,r)?(i?"-":"")+g(u):(i?"-":"")+u;if(!o[1])return(i?"-":"")+u+"."+new Array(n+1).join("0");if(o[1].length<n)return(i?"-":"")+u+"."+o[1]+new Array(n-o[1].length+1).join("0");a=o[1].substring(0,n);var d=o[1].substring(n);return d&&f(d,a,i,r)&&(a=g(a)).length>n?g(u,parseInt(a[0]))+"."+a.substring(1):(i?"-":"")+u+"."+a}},function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.RoundingModes=void 0,(r=t.RoundingModes||(t.RoundingModes={}))[r.CEILING=0]="CEILING",r[r.DOWN=1]="DOWN",r[r.FLOOR=2]="FLOOR",r[r.HALF_DOWN=3]="HALF_DOWN",r[r.HALF_EVEN=4]="HALF_EVEN",r[r.HALF_UP=5]="HALF_UP",r[r.UNNECESSARY=6]="UNNECESSARY",r[r.UP=7]="UP"},function(e,t,n){"use strict";var i=n(0),r=n(1),o=n(4),u=n(5),a=n(6),s=n(7),d=n(2),l=(f.validate=function(e){if(e){if(e=e.toString(),isNaN(e))throw Error("Parameter is not a number: "+e);"+"==e[0]&&(e=e.substring(1))}else e="0";var t,n,r;return/e/i.test(e)&&(n=(t=e.split(/[eE]/))[0],r=t[1],n=i.trim(n),r=parseInt(r)+n.indexOf("."),e=(n=n.replace(".","")).length<r?n+new Array(r-n.length+1).join("0"):n.length>=r&&0<r?i.trim(n.substring(0,r))+(n.length>r?"."+n.substring(r):""):"0."+new Array(1-r).join("0")+n),e},f.prototype.getValue=function(){return this.value},f.getPrettyValue=function(e,t,n){if(t||n){if(!t||!n)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else t=3,n=",";var r="-"==(e=f.validate(e)).charAt(0);r&&(e=e.substring(1));for(var i=e.indexOf("."),o="",u=i=0<i?i:e.length;0<u;)u<t?(t=u,u=0):u-=t,o=e.substring(u,u+t)+(u<i-t&&0<=u?n:"")+o;return(r?"-":"")+o+e.substring(i)},f.prototype.getPrettyValue=function(e,t){return f.getPrettyValue(this.value,e,t)},f.round=function(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=d.RoundingModes.HALF_EVEN),e=f.validate(e),isNaN(t))throw Error("Precision is not a number: "+t);return r.roundOff(e,t,n)},f.prototype.round=function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=d.RoundingModes.HALF_EVEN),isNaN(e))throw Error("Precision is not a number: "+e);return new f(r.roundOff(this.value,e,t))},f.floor=function(e){return-1===(e=f.validate(e)).indexOf(".")?e:f.round(e,0,d.RoundingModes.FLOOR)},f.prototype.floor=function(){return-1===this.value.indexOf(".")?new f(this.value):new f(this.value).round(0,d.RoundingModes.FLOOR)},f.ceil=function(e){return-1===(e=f.validate(e)).indexOf(".")?e:f.round(e,0,d.RoundingModes.CEILING)},f.prototype.ceil=function(){return-1===this.value.indexOf(".")?new f(this.value):new f(this.value).round(0,d.RoundingModes.CEILING)},f.add=function(e,t){return e=f.validate(e),t=f.validate(t),i.add(e,t)},f.prototype.add=function(e){return new f(i.add(this.value,e.getValue()))},f.subtract=function(e,t){return e=f.validate(e),t=f.validate(t),s.subtract(e,t)},f.prototype.subtract=function(e){return new f(s.subtract(this.value,e.getValue()))},f.multiply=function(e,t){return e=f.validate(e),t=f.validate(t),o.multiply(e,t)},f.prototype.multiply=function(e){return new f(o.multiply(this.value,e.getValue()))},f.divide=function(e,t,n){return e=f.validate(e),t=f.validate(t),u.divide(e,t,n)},f.prototype.divide=function(e,t){return new f(u.divide(this.value,e.getValue(),t))},f.compareTo=function(e,t){return e=f.validate(e),t=f.validate(t),a.compareTo(e,t)},f.prototype.compareTo=function(e){return a.compareTo(this.value,e.getValue())},f.negate=function(e){return e=f.validate(e),s.negate(e)},f.prototype.negate=function(){return new f(s.negate(this.value))},f.RoundingModes=d.RoundingModes,f);function f(e){void 0===e&&(e="0"),this.value=f.validate(e)}e.exports=l},function(e,t,n){"use strict";function b(e){for(;"0"==e[0];)e=e.substr(1);if(-1!=e.indexOf("."))for(;"0"==e[e.length-1];)e=e.substr(0,e.length-1);return""==e||"."==e?e="0":"."==e[e.length-1]&&(e=e.substr(0,e.length-1)),"."==e[0]&&(e="0"+e),e}Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=void 0,t.multiply=function(e,t){e=e.toString(),t=t.toString();var n=0;"-"==e[0]&&(n++,e=e.substr(1)),"-"==t[0]&&(n++,t=t.substr(1)),e=b(e),t=b(t);var r=0,i=0;-1!=e.indexOf(".")&&(r=e.length-e.indexOf(".")-1),-1!=t.indexOf(".")&&(i=t.length-t.indexOf(".")-1);var o,u=r+i;if(e=b(e.replace(".","")),t=b(t.replace(".","")),e.length<t.length&&(o=e,e=t,t=o),"0"==t)return"0";for(var a=t.length,s=0,d=[],l=a-1,f="",g=0;g<a;g++)d[g]=e.length-1;for(var c,v,g=0;g<2*e.length;g++){for(var p=0,h=t.length-1;l<=h&&0<=h;h--)-1<d[h]&&d[h]<e.length&&(p+=parseInt(e[d[h]--])*parseInt(t[h]));p+=s,s=Math.floor(p/10),f=p%10+f,l--}return f=b((c=f,0==(v=u)?c:(c=v>=c.length?new Array(v-c.length+1).join("0")+c:c).substr(0,c.length-v)+"."+c.substr(c.length-v,v))),1==n&&(f="-"+f),f}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.divide=void 0;var c=n(0),v=n(1);t.divide=function(e,t,n){if(void 0===n&&(n=8),0==t)throw new Error("Cannot divide by 0");if(e=e.toString(),t=t.toString(),e=e.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),t=t.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),0==e)return"0";var r=0;"-"==t[0]&&(t=t.substring(1),r++),"-"==e[0]&&(e=e.substring(1),r++);var i,o,u=0<t.indexOf(".")?t.length-t.indexOf(".")-1:-1;t=c.trim(t.replace(".","")),0<=u&&(-1==(i=0<e.indexOf(".")?e.length-e.indexOf(".")-1:-1)?e=c.trim(e+new Array(1+u).join("0")):i<u?(e=e.replace(".",""),e=c.trim(e+new Array(u-i+1).join("0"))):u<i?(o=(e=e.replace(".","")).length-i+u,e=c.trim(e.substring(0,o)+"."+e.substring(o))):u==i&&(e=c.trim(e.replace(".",""))));var a,s=0,d=t.length,l="",f=-1<e.indexOf(".")&&e.indexOf(".")<d?e.substring(0,d+1):e.substring(0,d);for(e=-1<e.indexOf(".")&&e.indexOf(".")<d?e.substring(d+1):e.substring(d),-1<f.indexOf(".")&&(a=f.length-f.indexOf(".")-1,d>(f=f.replace(".","")).length&&(a+=d-f.length,f+=new Array(d-f.length+1).join("0")),s=a,l="0."+new Array(a).join("0")),n+=2;s<=n;){for(var g=0;parseInt(f)>=parseInt(t);)f=c.add(f,"-"+t),g++;l+=g,e?("."==e[0]&&(l+=".",s++,e=e.substring(1)),f+=e.substring(0,1),e=e.substring(1)):(s||(l+="."),s++,f+="0")}return(1==r?"-":"")+c.trim(v.roundOff(l,n-2))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.compareTo=void 0;var o=n(0);t.compareTo=function(e,t){var n,r=!1;if("-"==e[0]&&"-"!=t[0])return-1;if("-"!=e[0]&&"-"==t[0])return 1;if("-"==e[0]&&"-"==t[0]&&(e=e.substr(1),t=t.substr(1),r=!0),e=(n=o.pad(e,t))[0],t=n[1],0==e.localeCompare(t))return 0;for(var i=0;i<e.length;i++)if(e[i]!=t[i])return e[i]>t[i]?r?-1:1:r?1:-1;return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negate=t.subtract=void 0;var r=n(0);function i(e){return e="-"==e[0]?e.substr(1):"-"+e}t.subtract=function(e,t){return e=e.toString(),t=i(t=t.toString()),r.add(e,t)},t.negate=i}],i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=3);function i(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}var n,r});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.bigDecimal=t():e.bigDecimal=t()}(global,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";function r(e){for(var t="",n=e.length,r=e.split(".")[1],i=r?r.length:0,o=0;o<n;o++)e[o]>="0"&&e[o]<="9"?t+=9-parseInt(e[o]):t+=e[o];return u(t,i>0?"0."+new Array(i).join("0")+"1":"1")}function i(e){var t=e.split(".");for(t[0]||(t[0]="0");"0"==t[0][0]&&t[0].length>1;)t[0]=t[0].substring(1);return t[0]+(t[1]?"."+t[1]:"")}function o(e,t){var n=e.split("."),r=t.split("."),i=n[0].length,o=r[0].length;return i>o?r[0]=new Array(Math.abs(i-o)+1).join("0")+(r[0]?r[0]:""):n[0]=new Array(Math.abs(i-o)+1).join("0")+(n[0]?n[0]:""),i=n[1]?n[1].length:0,o=r[1]?r[1].length:0,(i||o)&&(i>o?r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-o)+1).join("0"):n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-o)+1).join("0")),[e=n[0]+(n[1]?"."+n[1]:""),t=r[0]+(r[1]?"."+r[1]:"")]}function u(e,t){var n;e=(n=o(e,t))[0],t=n[1];for(var r="",i=0,u=e.length-1;u>=0;u--)if("."!==e[u]){var a=parseInt(e[u])+parseInt(t[u])+i;r=a%10+r,i=Math.floor(a/10)}else r="."+r;return i?i.toString()+r:r}Object.defineProperty(t,"__esModule",{value:!0}),t.pad=t.trim=t.add=void 0,t.add=function(e,t){var n;void 0===t&&(t="0");var a=0,s=-1;"-"==e[0]&&(a++,s=1,(e=e.substring(1)).length),"-"==t[0]&&(a++,s=2,(t=t.substring(1)).length),e=i(e),t=i(t),e=(n=o(i(e),i(t)))[0],t=n[1],1==a&&(1==s?e=r(e):t=r(t));var d=u(e,t);return a?2==a?"-"+i(d):e.length<d.length?i(d.substring(1)):"-"+i(r(d)):i(d)},t.trim=i,t.pad=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.roundOff=void 0;var r=n(2);function i(e,t,n,i){if(!e||e===new Array(e.length+1).join("0"))return!1;if(i===r.RoundingModes.DOWN||!n&&i===r.RoundingModes.FLOOR||n&&i===r.RoundingModes.CEILING)return!1;if(i===r.RoundingModes.UP||n&&i===r.RoundingModes.FLOOR||!n&&i===r.RoundingModes.CEILING)return!0;var o="5"+new Array(e.length).join("0");if(e>o)return!0;if(e<o)return!1;switch(i){case r.RoundingModes.HALF_DOWN:return!1;case r.RoundingModes.HALF_UP:return!0;case r.RoundingModes.HALF_EVEN:default:return parseInt(t[t.length-1])%2==1}}function o(e,t){void 0===t&&(t=0),t||(t=1),"number"==typeof e&&e.toString();for(var n="",r=e.length-1;r>=0;r--){var i=parseInt(e[r])+t;10==i?(t=1,i=0):t=0,n+=i}return t&&(n+=t),n.split("").reverse().join("")}t.roundOff=function e(t,n,u){if(void 0===n&&(n=0),void 0===u&&(u=r.RoundingModes.HALF_EVEN),u===r.RoundingModes.UNNECESSARY)throw new Error("UNNECESSARY Rounding Mode has not yet been implemented");"number"==typeof t&&(t=t.toString());var a=!1;"-"===t[0]&&(a=!0,t=t.substring(1));var s=t.split("."),d=s[0],l=s[1];if(n<0){if(n=-n,d.length<=n)return"0";var f=d.substr(0,d.length-n);return(a?"-":"")+(f=e(t=f+"."+d.substr(d.length-n)+l,0,u))+new Array(n+1).join("0")}if(0==n){d.length;return i(s[1],d,a,u)?(a?"-":"")+o(d):(a?"-":"")+d}if(!s[1])return(a?"-":"")+d+"."+new Array(n+1).join("0");if(s[1].length<n)return(a?"-":"")+d+"."+s[1]+new Array(n-s[1].length+1).join("0");l=s[1].substring(0,n);var g=s[1].substring(n);return g&&i(g,l,a,u)&&(l=o(l)).length>n?o(d,parseInt(l[0]))+"."+l.substring(1):(a?"-":"")+d+"."+l}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RoundingModes=void 0,function(e){e[e.CEILING=0]="CEILING",e[e.DOWN=1]="DOWN",e[e.FLOOR=2]="FLOOR",e[e.HALF_DOWN=3]="HALF_DOWN",e[e.HALF_EVEN=4]="HALF_EVEN",e[e.HALF_UP=5]="HALF_UP",e[e.UNNECESSARY=6]="UNNECESSARY",e[e.UP=7]="UP"}(t.RoundingModes||(t.RoundingModes={}))},function(e,t,n){"use strict";function r(e){for(;"0"==e[0];)e=e.substr(1);if(-1!=e.indexOf("."))for(;"0"==e[e.length-1];)e=e.substr(0,e.length-1);return""==e||"."==e?e="0":"."==e[e.length-1]&&(e=e.substr(0,e.length-1)),"."==e[0]&&(e="0"+e),e}Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=void 0,t.multiply=function(e,t){e=e.toString(),t=t.toString();var n=0;"-"==e[0]&&(n++,e=e.substr(1)),"-"==t[0]&&(n++,t=t.substr(1)),e=r(e),t=r(t);var i=0,o=0;-1!=e.indexOf(".")&&(i=e.length-e.indexOf(".")-1),-1!=t.indexOf(".")&&(o=t.length-t.indexOf(".")-1);var u=i+o;if(e=r(e.replace(".","")),t=r(t.replace(".","")),e.length<t.length){var a=e;e=t,t=a}if("0"==t)return"0";for(var s,d,l=t.length,f=0,g=[],c=l-1,v="",p=0;p<l;p++)g[p]=e.length-1;for(p=0;p<2*e.length;p++){for(var h=0,b=t.length-1;b>=c&&b>=0;b--)g[b]>-1&&g[b]<e.length&&(h+=parseInt(e[g[b]--])*parseInt(t[b]));h+=f,f=Math.floor(h/10),v=h%10+v,c--}return v=r((s=v,0==(d=u)?s:(s=d>=s.length?new Array(d-s.length+1).join("0")+s:s).substr(0,s.length-d)+"."+s.substr(s.length-d,d))),1==n&&(v="-"+v),v}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.divide=void 0;var r=n(0),i=n(1);t.divide=function(e,t,n){if(void 0===n&&(n=8),0==t)throw new Error("Cannot divide by 0");if(e=e.toString(),t=t.toString(),e=e.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),t=t.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),0==e)return"0";var o=0;"-"==t[0]&&(t=t.substring(1),o++),"-"==e[0]&&(e=e.substring(1),o++);var u=t.indexOf(".")>0?t.length-t.indexOf(".")-1:-1;if(t=r.trim(t.replace(".","")),u>=0){var a=e.indexOf(".")>0?e.length-e.indexOf(".")-1:-1;if(-1==a)e=r.trim(e+new Array(u+1).join("0"));else if(u>a)e=e.replace(".",""),e=r.trim(e+new Array(u-a+1).join("0"));else if(u<a){var s=(e=e.replace(".","")).length-a+u;e=r.trim(e.substring(0,s)+"."+e.substring(s))}else u==a&&(e=r.trim(e.replace(".","")))}var d=0,l=t.length,f="",g=e.indexOf(".")>-1&&e.indexOf(".")<l?e.substring(0,l+1):e.substring(0,l);if(e=e.indexOf(".")>-1&&e.indexOf(".")<l?e.substring(l+1):e.substring(l),g.indexOf(".")>-1){var c=g.length-g.indexOf(".")-1;l>(g=g.replace(".","")).length&&(c+=l-g.length,g+=new Array(l-g.length+1).join("0")),d=c,f="0."+new Array(c).join("0")}for(n+=2;d<=n;){for(var v=0;parseInt(g)>=parseInt(t);)g=r.add(g,"-"+t),v++;f+=v,e?("."==e[0]&&(f+=".",d++,e=e.substring(1)),g+=e.substring(0,1),e=e.substring(1)):(d||(f+="."),d++,g+="0")}return(1==o?"-":"")+r.trim(i.roundOff(f,n-2))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negate=t.subtract=void 0;var r=n(0);function i(e){return e="-"==e[0]?e.substr(1):"-"+e}t.subtract=function(e,t){return e=e.toString(),t=i(t=t.toString()),r.add(e,t)},t.negate=i},function(e,t,n){"use strict";var r=n(0),i=n(1),o=n(3),u=n(4),a=n(7),s=n(8),d=n(5),l=n(2),f=function(){function e(t){void 0===t&&(t="0"),this.value=e.validate(t)}return e.validate=function(e){if(e){if(e=e.toString(),isNaN(e))throw Error("Parameter is not a number: "+e);"+"==e[0]&&(e=e.substring(1))}else e="0";if(/e/i.test(e)){var t=e.split(/[eE]/),n=t[0],i=t[1];n=r.trim(n),i=parseInt(i)+n.indexOf("."),e=(n=n.replace(".","")).length<i?n+new Array(i-n.length+1).join("0"):n.length>=i&&i>0?r.trim(n.substring(0,i))+(n.length>i?"."+n.substring(i):""):"0."+new Array(1-i).join("0")+n}return e},e.prototype.getValue=function(){return this.value},e.getPrettyValue=function(t,n,r){if(n||r){if(!n||!r)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else n=3,r=",";var i="-"==(t=e.validate(t)).charAt(0);i&&(t=t.substring(1));for(var o=t.indexOf("."),u="",a=o=o>0?o:t.length;a>0;)a<n?(n=a,a=0):a-=n,u=t.substring(a,a+n)+(a<o-n&&a>=0?r:"")+u;return(i?"-":"")+u+t.substring(o)},e.prototype.getPrettyValue=function(t,n){return e.getPrettyValue(this.value,t,n)},e.round=function(t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=l.RoundingModes.HALF_EVEN),t=e.validate(t),isNaN(n))throw Error("Precision is not a number: "+n);return i.roundOff(t,n,r)},e.prototype.round=function(t,n){if(void 0===t&&(t=0),void 0===n&&(n=l.RoundingModes.HALF_EVEN),isNaN(t))throw Error("Precision is not a number: "+t);return new e(i.roundOff(this.value,t,n))},e.floor=function(t){return-1===(t=e.validate(t)).indexOf(".")?t:e.round(t,0,l.RoundingModes.FLOOR)},e.prototype.floor=function(){return-1===this.value.indexOf(".")?new e(this.value):new e(this.value).round(0,l.RoundingModes.FLOOR)},e.ceil=function(t){return-1===(t=e.validate(t)).indexOf(".")?t:e.round(t,0,l.RoundingModes.CEILING)},e.prototype.ceil=function(){return-1===this.value.indexOf(".")?new e(this.value):new e(this.value).round(0,l.RoundingModes.CEILING)},e.add=function(t,n){return t=e.validate(t),n=e.validate(n),r.add(t,n)},e.prototype.add=function(t){return new e(r.add(this.value,t.getValue()))},e.subtract=function(t,n){return t=e.validate(t),n=e.validate(n),d.subtract(t,n)},e.prototype.subtract=function(t){return new e(d.subtract(this.value,t.getValue()))},e.multiply=function(t,n){return t=e.validate(t),n=e.validate(n),o.multiply(t,n)},e.prototype.multiply=function(t){return new e(o.multiply(this.value,t.getValue()))},e.divide=function(t,n,r){return t=e.validate(t),n=e.validate(n),u.divide(t,n,r)},e.prototype.divide=function(t,n){return new e(u.divide(this.value,t.getValue(),n))},e.modulus=function(t,n){return t=e.validate(t),n=e.validate(n),a.modulus(t,n)},e.prototype.modulus=function(t){return new e(a.modulus(this.value,t.getValue()))},e.compareTo=function(t,n){return t=e.validate(t),n=e.validate(n),s.compareTo(t,n)},e.prototype.compareTo=function(e){return s.compareTo(this.value,e.getValue())},e.negate=function(t){return t=e.validate(t),d.negate(t)},e.prototype.negate=function(){return new e(d.negate(this.value))},e.RoundingModes=l.RoundingModes,e}();e.exports=f},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modulus=void 0;var r=n(4),i=n(1),o=n(3),u=n(5),a=n(2);function s(e){if(-1!=e.indexOf("."))throw new Error("Modulus of non-integers not supported")}t.modulus=function(e,t){if(0==t)throw new Error("Cannot divide by 0");e=e.toString(),t=t.toString(),s(e),s(t);var n="";return"-"==e[0]&&(n="-",e=e.substr(1)),"-"==t[0]&&(t=t.substr(1)),n+u.subtract(e,o.multiply(t,i.roundOff(r.divide(e,t),0,a.RoundingModes.FLOOR)))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.compareTo=void 0;var r=n(0);t.compareTo=function(e,t){var n,i=!1;if("-"==e[0]&&"-"!=t[0])return-1;if("-"!=e[0]&&"-"==t[0])return 1;if("-"==e[0]&&"-"==t[0]&&(e=e.substr(1),t=t.substr(1),i=!0),e=(n=r.pad(e,t))[0],t=n[1],0==e.localeCompare(t))return 0;for(var o=0;o<e.length;o++)if(e[o]!=t[o])return e[o]>t[o]?i?-1:1:i?1:-1;return 0}}])}));

@@ -85,3 +85,3 @@ var bigDecimal =

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 3);
/******/ return __webpack_require__(__webpack_require__.s = 6);
/******/ })

@@ -371,171 +371,2 @@ /************************************************************************/

var add_1 = __webpack_require__(0);
var round_1 = __webpack_require__(1);
var multiply_1 = __webpack_require__(4);
var divide_1 = __webpack_require__(5);
var compareTo_1 = __webpack_require__(6);
var subtract_1 = __webpack_require__(7);
var roundingModes_1 = __webpack_require__(2);
var bigDecimal = /** @class */ (function () {
function bigDecimal(number) {
if (number === void 0) { number = '0'; }
this.value = bigDecimal.validate(number);
}
bigDecimal.validate = function (number) {
if (number) {
number = number.toString();
if (isNaN(number))
throw Error("Parameter is not a number: " + number);
if (number[0] == '+')
number = number.substring(1);
}
else
number = '0';
//handle exponentiation
if (/e/i.test(number)) {
var _a = number.split(/[eE]/), mantisa = _a[0], exponent = _a[1];
mantisa = add_1.trim(mantisa);
exponent = parseInt(exponent) + mantisa.indexOf('.');
mantisa = mantisa.replace('.', '');
if (mantisa.length < exponent) {
number = mantisa + (new Array(exponent - mantisa.length + 1)).join('0');
}
else if (mantisa.length >= exponent && exponent > 0) {
number = add_1.trim(mantisa.substring(0, exponent)) +
((mantisa.length > exponent) ? ('.' + mantisa.substring(exponent)) : '');
}
else {
number = '0.' + (new Array(-exponent + 1)).join('0') + mantisa;
}
}
return number;
};
bigDecimal.prototype.getValue = function () {
return this.value;
};
bigDecimal.getPrettyValue = function (number, digits, separator) {
if (!(digits || separator)) {
digits = 3;
separator = ',';
}
else if (!(digits && separator)) {
throw Error('Illegal Arguments. Should pass both digits and separator or pass none');
}
number = bigDecimal.validate(number);
var neg = number.charAt(0) == '-';
if (neg)
number = number.substring(1);
var len = number.indexOf('.');
len = len > 0 ? len : (number.length);
var temp = '';
for (var i = len; i > 0;) {
if (i < digits) {
digits = i;
i = 0;
}
else
i -= digits;
temp = number.substring(i, i + digits) + ((i < (len - digits) && i >= 0) ? separator : '') + temp;
}
return (neg ? '-' : '') + temp + number.substring(len);
};
bigDecimal.prototype.getPrettyValue = function (digits, separator) {
return bigDecimal.getPrettyValue(this.value, digits, separator);
};
bigDecimal.round = function (number, precision, mode) {
if (precision === void 0) { precision = 0; }
if (mode === void 0) { mode = roundingModes_1.RoundingModes.HALF_EVEN; }
number = bigDecimal.validate(number);
if (isNaN(precision))
throw Error("Precision is not a number: " + precision);
return round_1.roundOff(number, precision, mode);
};
bigDecimal.prototype.round = function (precision, mode) {
if (precision === void 0) { precision = 0; }
if (mode === void 0) { mode = roundingModes_1.RoundingModes.HALF_EVEN; }
if (isNaN(precision))
throw Error("Precision is not a number: " + precision);
return new bigDecimal(round_1.roundOff(this.value, precision, mode));
};
bigDecimal.floor = function (number) {
number = bigDecimal.validate(number);
if (number.indexOf('.') === -1)
return number;
return bigDecimal.round(number, 0, roundingModes_1.RoundingModes.FLOOR);
};
bigDecimal.prototype.floor = function () {
if (this.value.indexOf('.') === -1)
return new bigDecimal(this.value);
return new bigDecimal(this.value).round(0, roundingModes_1.RoundingModes.FLOOR);
};
bigDecimal.ceil = function (number) {
number = bigDecimal.validate(number);
if (number.indexOf('.') === -1)
return number;
return bigDecimal.round(number, 0, roundingModes_1.RoundingModes.CEILING);
};
bigDecimal.prototype.ceil = function () {
if (this.value.indexOf('.') === -1)
return new bigDecimal(this.value);
return new bigDecimal(this.value).round(0, roundingModes_1.RoundingModes.CEILING);
};
bigDecimal.add = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return add_1.add(number1, number2);
};
bigDecimal.prototype.add = function (number) {
return new bigDecimal(add_1.add(this.value, number.getValue()));
};
bigDecimal.subtract = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return subtract_1.subtract(number1, number2);
};
bigDecimal.prototype.subtract = function (number) {
return new bigDecimal(subtract_1.subtract(this.value, number.getValue()));
};
bigDecimal.multiply = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return multiply_1.multiply(number1, number2);
};
bigDecimal.prototype.multiply = function (number) {
return new bigDecimal(multiply_1.multiply(this.value, number.getValue()));
};
bigDecimal.divide = function (number1, number2, precision) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return divide_1.divide(number1, number2, precision);
};
bigDecimal.prototype.divide = function (number, precision) {
return new bigDecimal(divide_1.divide(this.value, number.getValue(), precision));
};
bigDecimal.compareTo = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return compareTo_1.compareTo(number1, number2);
};
bigDecimal.prototype.compareTo = function (number) {
return compareTo_1.compareTo(this.value, number.getValue());
};
bigDecimal.negate = function (number) {
number = bigDecimal.validate(number);
return subtract_1.negate(number);
};
bigDecimal.prototype.negate = function () {
return new bigDecimal(subtract_1.negate(this.value));
};
bigDecimal.RoundingModes = roundingModes_1.RoundingModes;
return bigDecimal;
}());
module.exports = bigDecimal;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -646,3 +477,3 @@ exports.multiply = void 0;

/***/ }),
/* 5 */
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

@@ -742,2 +573,30 @@

/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.negate = exports.subtract = void 0;
var add_1 = __webpack_require__(0);
function subtract(number1, number2) {
number1 = number1.toString();
number2 = number2.toString();
number2 = negate(number2);
return add_1.add(number1, number2);
}
exports.subtract = subtract;
function negate(number) {
if (number[0] == '-') {
number = number.substr(1);
}
else {
number = '-' + number;
}
return number;
}
exports.negate = negate;
/***/ }),
/* 6 */

@@ -748,3 +607,221 @@ /***/ (function(module, exports, __webpack_require__) {

var add_1 = __webpack_require__(0);
var round_1 = __webpack_require__(1);
var multiply_1 = __webpack_require__(3);
var divide_1 = __webpack_require__(4);
var modulus_1 = __webpack_require__(7);
var compareTo_1 = __webpack_require__(8);
var subtract_1 = __webpack_require__(5);
var roundingModes_1 = __webpack_require__(2);
var bigDecimal = /** @class */ (function () {
function bigDecimal(number) {
if (number === void 0) { number = '0'; }
this.value = bigDecimal.validate(number);
}
bigDecimal.validate = function (number) {
if (number) {
number = number.toString();
if (isNaN(number))
throw Error("Parameter is not a number: " + number);
if (number[0] == '+')
number = number.substring(1);
}
else
number = '0';
//handle exponentiation
if (/e/i.test(number)) {
var _a = number.split(/[eE]/), mantisa = _a[0], exponent = _a[1];
mantisa = add_1.trim(mantisa);
exponent = parseInt(exponent) + mantisa.indexOf('.');
mantisa = mantisa.replace('.', '');
if (mantisa.length < exponent) {
number = mantisa + (new Array(exponent - mantisa.length + 1)).join('0');
}
else if (mantisa.length >= exponent && exponent > 0) {
number = add_1.trim(mantisa.substring(0, exponent)) +
((mantisa.length > exponent) ? ('.' + mantisa.substring(exponent)) : '');
}
else {
number = '0.' + (new Array(-exponent + 1)).join('0') + mantisa;
}
}
return number;
};
bigDecimal.prototype.getValue = function () {
return this.value;
};
bigDecimal.getPrettyValue = function (number, digits, separator) {
if (!(digits || separator)) {
digits = 3;
separator = ',';
}
else if (!(digits && separator)) {
throw Error('Illegal Arguments. Should pass both digits and separator or pass none');
}
number = bigDecimal.validate(number);
var neg = number.charAt(0) == '-';
if (neg)
number = number.substring(1);
var len = number.indexOf('.');
len = len > 0 ? len : (number.length);
var temp = '';
for (var i = len; i > 0;) {
if (i < digits) {
digits = i;
i = 0;
}
else
i -= digits;
temp = number.substring(i, i + digits) + ((i < (len - digits) && i >= 0) ? separator : '') + temp;
}
return (neg ? '-' : '') + temp + number.substring(len);
};
bigDecimal.prototype.getPrettyValue = function (digits, separator) {
return bigDecimal.getPrettyValue(this.value, digits, separator);
};
bigDecimal.round = function (number, precision, mode) {
if (precision === void 0) { precision = 0; }
if (mode === void 0) { mode = roundingModes_1.RoundingModes.HALF_EVEN; }
number = bigDecimal.validate(number);
if (isNaN(precision))
throw Error("Precision is not a number: " + precision);
return round_1.roundOff(number, precision, mode);
};
bigDecimal.prototype.round = function (precision, mode) {
if (precision === void 0) { precision = 0; }
if (mode === void 0) { mode = roundingModes_1.RoundingModes.HALF_EVEN; }
if (isNaN(precision))
throw Error("Precision is not a number: " + precision);
return new bigDecimal(round_1.roundOff(this.value, precision, mode));
};
bigDecimal.floor = function (number) {
number = bigDecimal.validate(number);
if (number.indexOf('.') === -1)
return number;
return bigDecimal.round(number, 0, roundingModes_1.RoundingModes.FLOOR);
};
bigDecimal.prototype.floor = function () {
if (this.value.indexOf('.') === -1)
return new bigDecimal(this.value);
return new bigDecimal(this.value).round(0, roundingModes_1.RoundingModes.FLOOR);
};
bigDecimal.ceil = function (number) {
number = bigDecimal.validate(number);
if (number.indexOf('.') === -1)
return number;
return bigDecimal.round(number, 0, roundingModes_1.RoundingModes.CEILING);
};
bigDecimal.prototype.ceil = function () {
if (this.value.indexOf('.') === -1)
return new bigDecimal(this.value);
return new bigDecimal(this.value).round(0, roundingModes_1.RoundingModes.CEILING);
};
bigDecimal.add = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return add_1.add(number1, number2);
};
bigDecimal.prototype.add = function (number) {
return new bigDecimal(add_1.add(this.value, number.getValue()));
};
bigDecimal.subtract = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return subtract_1.subtract(number1, number2);
};
bigDecimal.prototype.subtract = function (number) {
return new bigDecimal(subtract_1.subtract(this.value, number.getValue()));
};
bigDecimal.multiply = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return multiply_1.multiply(number1, number2);
};
bigDecimal.prototype.multiply = function (number) {
return new bigDecimal(multiply_1.multiply(this.value, number.getValue()));
};
bigDecimal.divide = function (number1, number2, precision) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return divide_1.divide(number1, number2, precision);
};
bigDecimal.prototype.divide = function (number, precision) {
return new bigDecimal(divide_1.divide(this.value, number.getValue(), precision));
};
bigDecimal.modulus = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return modulus_1.modulus(number1, number2);
};
bigDecimal.prototype.modulus = function (number) {
return new bigDecimal(modulus_1.modulus(this.value, number.getValue()));
};
bigDecimal.compareTo = function (number1, number2) {
number1 = bigDecimal.validate(number1);
number2 = bigDecimal.validate(number2);
return compareTo_1.compareTo(number1, number2);
};
bigDecimal.prototype.compareTo = function (number) {
return compareTo_1.compareTo(this.value, number.getValue());
};
bigDecimal.negate = function (number) {
number = bigDecimal.validate(number);
return subtract_1.negate(number);
};
bigDecimal.prototype.negate = function () {
return new bigDecimal(subtract_1.negate(this.value));
};
bigDecimal.RoundingModes = roundingModes_1.RoundingModes;
return bigDecimal;
}());
module.exports = bigDecimal;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.modulus = void 0;
var divide_1 = __webpack_require__(4);
var round_1 = __webpack_require__(1);
var multiply_1 = __webpack_require__(3);
var subtract_1 = __webpack_require__(5);
var roundingModes_1 = __webpack_require__(2);
function modulus(dividend, divisor) {
if (divisor == 0) {
throw new Error('Cannot divide by 0');
}
dividend = dividend.toString();
divisor = divisor.toString();
validate(dividend);
validate(divisor);
var sign = '';
if (dividend[0] == '-') {
sign = '-';
dividend = dividend.substr(1);
}
if (divisor[0] == '-') {
divisor = divisor.substr(1);
}
var result = subtract_1.subtract(dividend, multiply_1.multiply(divisor, round_1.roundOff(divide_1.divide(dividend, divisor), 0, roundingModes_1.RoundingModes.FLOOR)));
return sign + result;
}
exports.modulus = modulus;
function validate(oparand) {
if (oparand.indexOf('.') != -1) {
throw new Error('Modulus of non-integers not supported');
}
}
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compareTo = void 0;

@@ -796,31 +873,3 @@ var add_1 = __webpack_require__(0);

/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.negate = exports.subtract = void 0;
var add_1 = __webpack_require__(0);
function subtract(number1, number2) {
number1 = number1.toString();
number2 = number2.toString();
number2 = negate(number2);
return add_1.add(number1, number2);
}
exports.subtract = subtract;
function negate(number) {
if (number[0] == '-') {
number = number.substr(1);
}
else {
number = '-' + number;
}
return number;
}
exports.negate = negate;
/***/ })
/******/ ]);

@@ -1,1 +0,1 @@

var bigDecimal=function(t){var r={};function i(e){if(r[e])return r[e].exports;var n=r[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=r,i.d=function(e,n,t){i.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(n,e){if(1&e&&(n=i(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)i.d(t,r,function(e){return n[e]}.bind(null,r));return t},i.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(n,"a",n),n},i.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},i.p="",i(i.s=3)}([function(e,n,t){"use strict";function u(e){for(var n="",t=e.length,r=e.split(".")[1],i=r?r.length:0,o=0;o<t;o++)"0"<=e[o]&&e[o]<="9"?n+=9-parseInt(e[o]):n+=e[o];return d(n,0<i?"0."+new Array(i).join("0")+"1":"1")}function a(e){var n=e.split(".");for(n[0]||(n[0]="0");"0"==n[0][0]&&1<n[0].length;)n[0]=n[0].substring(1);return n[0]+(n[1]?"."+n[1]:"")}function s(e,n){var t=e.split("."),r=n.split("."),i=t[0].length,o=r[0].length;return o<i?r[0]=new Array(Math.abs(i-o)+1).join("0")+(r[0]?r[0]:""):t[0]=new Array(Math.abs(i-o)+1).join("0")+(t[0]?t[0]:""),i=t[1]?t[1].length:0,o=r[1]?r[1].length:0,(i||o)&&(o<i?r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-o)+1).join("0"):t[1]=(t[1]?t[1]:"")+new Array(Math.abs(i-o)+1).join("0")),[e=t[0]+(t[1]?"."+t[1]:""),n=r[0]+(r[1]?"."+r[1]:"")]}function d(e,n){var t=s(e,n);e=t[0],n=t[1];for(var r,i="",o=0,u=e.length-1;0<=u;u--){"."!==e[u]?(i=(r=parseInt(e[u])+parseInt(n[u])+o)%10+i,o=Math.floor(r/10)):i="."+i}return o?o.toString()+i:i}Object.defineProperty(n,"__esModule",{value:!0}),n.pad=n.trim=n.add=void 0,n.add=function(e,n){var t;void 0===n&&(n="0");var r=0,i=-1;"-"==e[0]&&(r++,i=1,(e=e.substring(1)).length),"-"==n[0]&&(r++,i=2,(n=n.substring(1)).length),e=a(e),n=a(n),e=(t=s(a(e),a(n)))[0],n=t[1],1==r&&(1==i?e=u(e):n=u(n));var o=d(e,n);return r?2==r?"-"+a(o):e.length<o.length?a(o.substring(1)):"-"+a(u(o)):a(o)},n.trim=a,n.pad=s},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.roundOff=void 0;var l=t(2);function f(e,n,t,r){if(e&&e!==new Array(e.length+1).join("0")&&!(r===l.RoundingModes.DOWN||!t&&r===l.RoundingModes.FLOOR||t&&r===l.RoundingModes.CEILING)){if(r===l.RoundingModes.UP||t&&r===l.RoundingModes.FLOOR||!t&&r===l.RoundingModes.CEILING)return 1;var i="5"+new Array(e.length).join("0");if(i<e)return 1;if(!(e<i))switch(r){case l.RoundingModes.HALF_DOWN:return;case l.RoundingModes.HALF_UP:return 1;case l.RoundingModes.HALF_EVEN:default:return parseInt(n[n.length-1])%2==1}}}function g(e,n){void 0===n&&(n=0),n=n||1,"number"==typeof e&&e.toString();for(var t="",r=e.length-1;0<=r;r--){var i=parseInt(e[r])+n;10==i?(n=1,i=0):n=0,t+=i}return n&&(t+=n),t.split("").reverse().join("")}n.roundOff=function e(n,t,r){if(void 0===t&&(t=0),void 0===r&&(r=l.RoundingModes.HALF_EVEN),r===l.RoundingModes.UNNECESSARY)throw new Error("UNNECESSARY Rounding Mode has not yet been implemented");"number"==typeof n&&(n=n.toString());var i=!1;"-"===n[0]&&(i=!0,n=n.substring(1));var o=n.split("."),u=o[0],a=o[1];if(t<0){if(t=-t,u.length<=t)return"0";var s=u.substr(0,u.length-t);return(i?"-":"")+e(n=s+"."+u.substr(u.length-t)+a,0,r)+new Array(t+1).join("0")}if(0==t)return u.length,f(o[1],u,i,r)?(i?"-":"")+g(u):(i?"-":"")+u;if(!o[1])return(i?"-":"")+u+"."+new Array(t+1).join("0");if(o[1].length<t)return(i?"-":"")+u+"."+o[1]+new Array(t-o[1].length+1).join("0");a=o[1].substring(0,t);var d=o[1].substring(t);return d&&f(d,a,i,r)&&(a=g(a)).length>t?g(u,parseInt(a[0]))+"."+a.substring(1):(i?"-":"")+u+"."+a}},function(e,n,t){"use strict";var r;Object.defineProperty(n,"__esModule",{value:!0}),n.RoundingModes=void 0,(r=n.RoundingModes||(n.RoundingModes={}))[r.CEILING=0]="CEILING",r[r.DOWN=1]="DOWN",r[r.FLOOR=2]="FLOOR",r[r.HALF_DOWN=3]="HALF_DOWN",r[r.HALF_EVEN=4]="HALF_EVEN",r[r.HALF_UP=5]="HALF_UP",r[r.UNNECESSARY=6]="UNNECESSARY",r[r.UP=7]="UP"},function(e,n,t){"use strict";var i=t(0),r=t(1),o=t(4),u=t(5),a=t(6),s=t(7),d=t(2),l=(f.validate=function(e){if(e){if(e=e.toString(),isNaN(e))throw Error("Parameter is not a number: "+e);"+"==e[0]&&(e=e.substring(1))}else e="0";var n,t,r;return/e/i.test(e)&&(t=(n=e.split(/[eE]/))[0],r=n[1],t=i.trim(t),r=parseInt(r)+t.indexOf("."),e=(t=t.replace(".","")).length<r?t+new Array(r-t.length+1).join("0"):t.length>=r&&0<r?i.trim(t.substring(0,r))+(t.length>r?"."+t.substring(r):""):"0."+new Array(1-r).join("0")+t),e},f.prototype.getValue=function(){return this.value},f.getPrettyValue=function(e,n,t){if(n||t){if(!n||!t)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else n=3,t=",";var r="-"==(e=f.validate(e)).charAt(0);r&&(e=e.substring(1));for(var i=e.indexOf("."),o="",u=i=0<i?i:e.length;0<u;)u<n?(n=u,u=0):u-=n,o=e.substring(u,u+n)+(u<i-n&&0<=u?t:"")+o;return(r?"-":"")+o+e.substring(i)},f.prototype.getPrettyValue=function(e,n){return f.getPrettyValue(this.value,e,n)},f.round=function(e,n,t){if(void 0===n&&(n=0),void 0===t&&(t=d.RoundingModes.HALF_EVEN),e=f.validate(e),isNaN(n))throw Error("Precision is not a number: "+n);return r.roundOff(e,n,t)},f.prototype.round=function(e,n){if(void 0===e&&(e=0),void 0===n&&(n=d.RoundingModes.HALF_EVEN),isNaN(e))throw Error("Precision is not a number: "+e);return new f(r.roundOff(this.value,e,n))},f.floor=function(e){return-1===(e=f.validate(e)).indexOf(".")?e:f.round(e,0,d.RoundingModes.FLOOR)},f.prototype.floor=function(){return-1===this.value.indexOf(".")?new f(this.value):new f(this.value).round(0,d.RoundingModes.FLOOR)},f.ceil=function(e){return-1===(e=f.validate(e)).indexOf(".")?e:f.round(e,0,d.RoundingModes.CEILING)},f.prototype.ceil=function(){return-1===this.value.indexOf(".")?new f(this.value):new f(this.value).round(0,d.RoundingModes.CEILING)},f.add=function(e,n){return e=f.validate(e),n=f.validate(n),i.add(e,n)},f.prototype.add=function(e){return new f(i.add(this.value,e.getValue()))},f.subtract=function(e,n){return e=f.validate(e),n=f.validate(n),s.subtract(e,n)},f.prototype.subtract=function(e){return new f(s.subtract(this.value,e.getValue()))},f.multiply=function(e,n){return e=f.validate(e),n=f.validate(n),o.multiply(e,n)},f.prototype.multiply=function(e){return new f(o.multiply(this.value,e.getValue()))},f.divide=function(e,n,t){return e=f.validate(e),n=f.validate(n),u.divide(e,n,t)},f.prototype.divide=function(e,n){return new f(u.divide(this.value,e.getValue(),n))},f.compareTo=function(e,n){return e=f.validate(e),n=f.validate(n),a.compareTo(e,n)},f.prototype.compareTo=function(e){return a.compareTo(this.value,e.getValue())},f.negate=function(e){return e=f.validate(e),s.negate(e)},f.prototype.negate=function(){return new f(s.negate(this.value))},f.RoundingModes=d.RoundingModes,f);function f(e){void 0===e&&(e="0"),this.value=f.validate(e)}e.exports=l},function(e,n,t){"use strict";function b(e){for(;"0"==e[0];)e=e.substr(1);if(-1!=e.indexOf("."))for(;"0"==e[e.length-1];)e=e.substr(0,e.length-1);return""==e||"."==e?e="0":"."==e[e.length-1]&&(e=e.substr(0,e.length-1)),"."==e[0]&&(e="0"+e),e}Object.defineProperty(n,"__esModule",{value:!0}),n.multiply=void 0,n.multiply=function(e,n){e=e.toString(),n=n.toString();var t=0;"-"==e[0]&&(t++,e=e.substr(1)),"-"==n[0]&&(t++,n=n.substr(1)),e=b(e),n=b(n);var r=0,i=0;-1!=e.indexOf(".")&&(r=e.length-e.indexOf(".")-1),-1!=n.indexOf(".")&&(i=n.length-n.indexOf(".")-1);var o,u=r+i;if(e=b(e.replace(".","")),n=b(n.replace(".","")),e.length<n.length&&(o=e,e=n,n=o),"0"==n)return"0";for(var a=n.length,s=0,d=[],l=a-1,f="",g=0;g<a;g++)d[g]=e.length-1;for(var c,v,g=0;g<2*e.length;g++){for(var p=0,h=n.length-1;l<=h&&0<=h;h--)-1<d[h]&&d[h]<e.length&&(p+=parseInt(e[d[h]--])*parseInt(n[h]));p+=s,s=Math.floor(p/10),f=p%10+f,l--}return f=b((c=f,0==(v=u)?c:(c=v>=c.length?new Array(v-c.length+1).join("0")+c:c).substr(0,c.length-v)+"."+c.substr(c.length-v,v))),1==t&&(f="-"+f),f}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.divide=void 0;var c=t(0),v=t(1);n.divide=function(e,n,t){if(void 0===t&&(t=8),0==n)throw new Error("Cannot divide by 0");if(e=e.toString(),n=n.toString(),e=e.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),n=n.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),0==e)return"0";var r=0;"-"==n[0]&&(n=n.substring(1),r++),"-"==e[0]&&(e=e.substring(1),r++);var i,o,u=0<n.indexOf(".")?n.length-n.indexOf(".")-1:-1;n=c.trim(n.replace(".","")),0<=u&&(-1==(i=0<e.indexOf(".")?e.length-e.indexOf(".")-1:-1)?e=c.trim(e+new Array(1+u).join("0")):i<u?(e=e.replace(".",""),e=c.trim(e+new Array(u-i+1).join("0"))):u<i?(o=(e=e.replace(".","")).length-i+u,e=c.trim(e.substring(0,o)+"."+e.substring(o))):u==i&&(e=c.trim(e.replace(".",""))));var a,s=0,d=n.length,l="",f=-1<e.indexOf(".")&&e.indexOf(".")<d?e.substring(0,d+1):e.substring(0,d);for(e=-1<e.indexOf(".")&&e.indexOf(".")<d?e.substring(d+1):e.substring(d),-1<f.indexOf(".")&&(a=f.length-f.indexOf(".")-1,d>(f=f.replace(".","")).length&&(a+=d-f.length,f+=new Array(d-f.length+1).join("0")),s=a,l="0."+new Array(a).join("0")),t+=2;s<=t;){for(var g=0;parseInt(f)>=parseInt(n);)f=c.add(f,"-"+n),g++;l+=g,e?("."==e[0]&&(l+=".",s++,e=e.substring(1)),f+=e.substring(0,1),e=e.substring(1)):(s||(l+="."),s++,f+="0")}return(1==r?"-":"")+c.trim(v.roundOff(l,t-2))}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.compareTo=void 0;var o=t(0);n.compareTo=function(e,n){var t,r=!1;if("-"==e[0]&&"-"!=n[0])return-1;if("-"!=e[0]&&"-"==n[0])return 1;if("-"==e[0]&&"-"==n[0]&&(e=e.substr(1),n=n.substr(1),r=!0),e=(t=o.pad(e,n))[0],n=t[1],0==e.localeCompare(n))return 0;for(var i=0;i<e.length;i++)if(e[i]!=n[i])return e[i]>n[i]?r?-1:1:r?1:-1;return 0}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.negate=n.subtract=void 0;var r=t(0);function i(e){return e="-"==e[0]?e.substr(1):"-"+e}n.subtract=function(e,n){return e=e.toString(),n=i(n=n.toString()),r.add(e,n)},n.negate=i}]);
var bigDecimal=function(e){var n={};function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(r,i,function(n){return e[n]}.bind(null,i));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=6)}([function(e,n,t){"use strict";function r(e){for(var n="",t=e.length,r=e.split(".")[1],i=r?r.length:0,o=0;o<t;o++)e[o]>="0"&&e[o]<="9"?n+=9-parseInt(e[o]):n+=e[o];return u(n,i>0?"0."+new Array(i).join("0")+"1":"1")}function i(e){var n=e.split(".");for(n[0]||(n[0]="0");"0"==n[0][0]&&n[0].length>1;)n[0]=n[0].substring(1);return n[0]+(n[1]?"."+n[1]:"")}function o(e,n){var t=e.split("."),r=n.split("."),i=t[0].length,o=r[0].length;return i>o?r[0]=new Array(Math.abs(i-o)+1).join("0")+(r[0]?r[0]:""):t[0]=new Array(Math.abs(i-o)+1).join("0")+(t[0]?t[0]:""),i=t[1]?t[1].length:0,o=r[1]?r[1].length:0,(i||o)&&(i>o?r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-o)+1).join("0"):t[1]=(t[1]?t[1]:"")+new Array(Math.abs(i-o)+1).join("0")),[e=t[0]+(t[1]?"."+t[1]:""),n=r[0]+(r[1]?"."+r[1]:"")]}function u(e,n){var t;e=(t=o(e,n))[0],n=t[1];for(var r="",i=0,u=e.length-1;u>=0;u--)if("."!==e[u]){var a=parseInt(e[u])+parseInt(n[u])+i;r=a%10+r,i=Math.floor(a/10)}else r="."+r;return i?i.toString()+r:r}Object.defineProperty(n,"__esModule",{value:!0}),n.pad=n.trim=n.add=void 0,n.add=function(e,n){var t;void 0===n&&(n="0");var a=0,s=-1;"-"==e[0]&&(a++,s=1,(e=e.substring(1)).length),"-"==n[0]&&(a++,s=2,(n=n.substring(1)).length),e=i(e),n=i(n),e=(t=o(i(e),i(n)))[0],n=t[1],1==a&&(1==s?e=r(e):n=r(n));var d=u(e,n);return a?2==a?"-"+i(d):e.length<d.length?i(d.substring(1)):"-"+i(r(d)):i(d)},n.trim=i,n.pad=o},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.roundOff=void 0;var r=t(2);function i(e,n,t,i){if(!e||e===new Array(e.length+1).join("0"))return!1;if(i===r.RoundingModes.DOWN||!t&&i===r.RoundingModes.FLOOR||t&&i===r.RoundingModes.CEILING)return!1;if(i===r.RoundingModes.UP||t&&i===r.RoundingModes.FLOOR||!t&&i===r.RoundingModes.CEILING)return!0;var o="5"+new Array(e.length).join("0");if(e>o)return!0;if(e<o)return!1;switch(i){case r.RoundingModes.HALF_DOWN:return!1;case r.RoundingModes.HALF_UP:return!0;case r.RoundingModes.HALF_EVEN:default:return parseInt(n[n.length-1])%2==1}}function o(e,n){void 0===n&&(n=0),n||(n=1),"number"==typeof e&&e.toString();for(var t="",r=e.length-1;r>=0;r--){var i=parseInt(e[r])+n;10==i?(n=1,i=0):n=0,t+=i}return n&&(t+=n),t.split("").reverse().join("")}n.roundOff=function e(n,t,u){if(void 0===t&&(t=0),void 0===u&&(u=r.RoundingModes.HALF_EVEN),u===r.RoundingModes.UNNECESSARY)throw new Error("UNNECESSARY Rounding Mode has not yet been implemented");"number"==typeof n&&(n=n.toString());var a=!1;"-"===n[0]&&(a=!0,n=n.substring(1));var s=n.split("."),d=s[0],l=s[1];if(t<0){if(t=-t,d.length<=t)return"0";var f=d.substr(0,d.length-t);return(a?"-":"")+(f=e(n=f+"."+d.substr(d.length-t)+l,0,u))+new Array(t+1).join("0")}if(0==t){d.length;return i(s[1],d,a,u)?(a?"-":"")+o(d):(a?"-":"")+d}if(!s[1])return(a?"-":"")+d+"."+new Array(t+1).join("0");if(s[1].length<t)return(a?"-":"")+d+"."+s[1]+new Array(t-s[1].length+1).join("0");l=s[1].substring(0,t);var g=s[1].substring(t);return g&&i(g,l,a,u)&&(l=o(l)).length>t?o(d,parseInt(l[0]))+"."+l.substring(1):(a?"-":"")+d+"."+l}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.RoundingModes=void 0,function(e){e[e.CEILING=0]="CEILING",e[e.DOWN=1]="DOWN",e[e.FLOOR=2]="FLOOR",e[e.HALF_DOWN=3]="HALF_DOWN",e[e.HALF_EVEN=4]="HALF_EVEN",e[e.HALF_UP=5]="HALF_UP",e[e.UNNECESSARY=6]="UNNECESSARY",e[e.UP=7]="UP"}(n.RoundingModes||(n.RoundingModes={}))},function(e,n,t){"use strict";function r(e){for(;"0"==e[0];)e=e.substr(1);if(-1!=e.indexOf("."))for(;"0"==e[e.length-1];)e=e.substr(0,e.length-1);return""==e||"."==e?e="0":"."==e[e.length-1]&&(e=e.substr(0,e.length-1)),"."==e[0]&&(e="0"+e),e}Object.defineProperty(n,"__esModule",{value:!0}),n.multiply=void 0,n.multiply=function(e,n){e=e.toString(),n=n.toString();var t=0;"-"==e[0]&&(t++,e=e.substr(1)),"-"==n[0]&&(t++,n=n.substr(1)),e=r(e),n=r(n);var i=0,o=0;-1!=e.indexOf(".")&&(i=e.length-e.indexOf(".")-1),-1!=n.indexOf(".")&&(o=n.length-n.indexOf(".")-1);var u=i+o;if(e=r(e.replace(".","")),n=r(n.replace(".","")),e.length<n.length){var a=e;e=n,n=a}if("0"==n)return"0";for(var s,d,l=n.length,f=0,g=[],c=l-1,v="",p=0;p<l;p++)g[p]=e.length-1;for(p=0;p<2*e.length;p++){for(var h=0,b=n.length-1;b>=c&&b>=0;b--)g[b]>-1&&g[b]<e.length&&(h+=parseInt(e[g[b]--])*parseInt(n[b]));h+=f,f=Math.floor(h/10),v=h%10+v,c--}return v=r((s=v,0==(d=u)?s:(s=d>=s.length?new Array(d-s.length+1).join("0")+s:s).substr(0,s.length-d)+"."+s.substr(s.length-d,d))),1==t&&(v="-"+v),v}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.divide=void 0;var r=t(0),i=t(1);n.divide=function(e,n,t){if(void 0===t&&(t=8),0==n)throw new Error("Cannot divide by 0");if(e=e.toString(),n=n.toString(),e=e.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),n=n.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),0==e)return"0";var o=0;"-"==n[0]&&(n=n.substring(1),o++),"-"==e[0]&&(e=e.substring(1),o++);var u=n.indexOf(".")>0?n.length-n.indexOf(".")-1:-1;if(n=r.trim(n.replace(".","")),u>=0){var a=e.indexOf(".")>0?e.length-e.indexOf(".")-1:-1;if(-1==a)e=r.trim(e+new Array(u+1).join("0"));else if(u>a)e=e.replace(".",""),e=r.trim(e+new Array(u-a+1).join("0"));else if(u<a){var s=(e=e.replace(".","")).length-a+u;e=r.trim(e.substring(0,s)+"."+e.substring(s))}else u==a&&(e=r.trim(e.replace(".","")))}var d=0,l=n.length,f="",g=e.indexOf(".")>-1&&e.indexOf(".")<l?e.substring(0,l+1):e.substring(0,l);if(e=e.indexOf(".")>-1&&e.indexOf(".")<l?e.substring(l+1):e.substring(l),g.indexOf(".")>-1){var c=g.length-g.indexOf(".")-1;l>(g=g.replace(".","")).length&&(c+=l-g.length,g+=new Array(l-g.length+1).join("0")),d=c,f="0."+new Array(c).join("0")}for(t+=2;d<=t;){for(var v=0;parseInt(g)>=parseInt(n);)g=r.add(g,"-"+n),v++;f+=v,e?("."==e[0]&&(f+=".",d++,e=e.substring(1)),g+=e.substring(0,1),e=e.substring(1)):(d||(f+="."),d++,g+="0")}return(1==o?"-":"")+r.trim(i.roundOff(f,t-2))}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.negate=n.subtract=void 0;var r=t(0);function i(e){return e="-"==e[0]?e.substr(1):"-"+e}n.subtract=function(e,n){return e=e.toString(),n=i(n=n.toString()),r.add(e,n)},n.negate=i},function(e,n,t){"use strict";var r=t(0),i=t(1),o=t(3),u=t(4),a=t(7),s=t(8),d=t(5),l=t(2),f=function(){function e(n){void 0===n&&(n="0"),this.value=e.validate(n)}return e.validate=function(e){if(e){if(e=e.toString(),isNaN(e))throw Error("Parameter is not a number: "+e);"+"==e[0]&&(e=e.substring(1))}else e="0";if(/e/i.test(e)){var n=e.split(/[eE]/),t=n[0],i=n[1];t=r.trim(t),i=parseInt(i)+t.indexOf("."),e=(t=t.replace(".","")).length<i?t+new Array(i-t.length+1).join("0"):t.length>=i&&i>0?r.trim(t.substring(0,i))+(t.length>i?"."+t.substring(i):""):"0."+new Array(1-i).join("0")+t}return e},e.prototype.getValue=function(){return this.value},e.getPrettyValue=function(n,t,r){if(t||r){if(!t||!r)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else t=3,r=",";var i="-"==(n=e.validate(n)).charAt(0);i&&(n=n.substring(1));for(var o=n.indexOf("."),u="",a=o=o>0?o:n.length;a>0;)a<t?(t=a,a=0):a-=t,u=n.substring(a,a+t)+(a<o-t&&a>=0?r:"")+u;return(i?"-":"")+u+n.substring(o)},e.prototype.getPrettyValue=function(n,t){return e.getPrettyValue(this.value,n,t)},e.round=function(n,t,r){if(void 0===t&&(t=0),void 0===r&&(r=l.RoundingModes.HALF_EVEN),n=e.validate(n),isNaN(t))throw Error("Precision is not a number: "+t);return i.roundOff(n,t,r)},e.prototype.round=function(n,t){if(void 0===n&&(n=0),void 0===t&&(t=l.RoundingModes.HALF_EVEN),isNaN(n))throw Error("Precision is not a number: "+n);return new e(i.roundOff(this.value,n,t))},e.floor=function(n){return-1===(n=e.validate(n)).indexOf(".")?n:e.round(n,0,l.RoundingModes.FLOOR)},e.prototype.floor=function(){return-1===this.value.indexOf(".")?new e(this.value):new e(this.value).round(0,l.RoundingModes.FLOOR)},e.ceil=function(n){return-1===(n=e.validate(n)).indexOf(".")?n:e.round(n,0,l.RoundingModes.CEILING)},e.prototype.ceil=function(){return-1===this.value.indexOf(".")?new e(this.value):new e(this.value).round(0,l.RoundingModes.CEILING)},e.add=function(n,t){return n=e.validate(n),t=e.validate(t),r.add(n,t)},e.prototype.add=function(n){return new e(r.add(this.value,n.getValue()))},e.subtract=function(n,t){return n=e.validate(n),t=e.validate(t),d.subtract(n,t)},e.prototype.subtract=function(n){return new e(d.subtract(this.value,n.getValue()))},e.multiply=function(n,t){return n=e.validate(n),t=e.validate(t),o.multiply(n,t)},e.prototype.multiply=function(n){return new e(o.multiply(this.value,n.getValue()))},e.divide=function(n,t,r){return n=e.validate(n),t=e.validate(t),u.divide(n,t,r)},e.prototype.divide=function(n,t){return new e(u.divide(this.value,n.getValue(),t))},e.modulus=function(n,t){return n=e.validate(n),t=e.validate(t),a.modulus(n,t)},e.prototype.modulus=function(n){return new e(a.modulus(this.value,n.getValue()))},e.compareTo=function(n,t){return n=e.validate(n),t=e.validate(t),s.compareTo(n,t)},e.prototype.compareTo=function(e){return s.compareTo(this.value,e.getValue())},e.negate=function(n){return n=e.validate(n),d.negate(n)},e.prototype.negate=function(){return new e(d.negate(this.value))},e.RoundingModes=l.RoundingModes,e}();e.exports=f},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.modulus=void 0;var r=t(4),i=t(1),o=t(3),u=t(5),a=t(2);function s(e){if(-1!=e.indexOf("."))throw new Error("Modulus of non-integers not supported")}n.modulus=function(e,n){if(0==n)throw new Error("Cannot divide by 0");e=e.toString(),n=n.toString(),s(e),s(n);var t="";return"-"==e[0]&&(t="-",e=e.substr(1)),"-"==n[0]&&(n=n.substr(1)),t+u.subtract(e,o.multiply(n,i.roundOff(r.divide(e,n),0,a.RoundingModes.FLOOR)))}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.compareTo=void 0;var r=t(0);n.compareTo=function(e,n){var t,i=!1;if("-"==e[0]&&"-"!=n[0])return-1;if("-"!=e[0]&&"-"==n[0])return 1;if("-"==e[0]&&"-"==n[0]&&(e=e.substr(1),n=n.substr(1),i=!0),e=(t=r.pad(e,n))[0],n=t[1],0==e.localeCompare(n))return 0;for(var o=0;o<e.length;o++)if(e[o]!=n[o])return e[o]>n[o]?i?-1:1:i?1:-1;return 0}}]);
{
"name": "js-big-decimal",
"version": "1.2.4",
"version": "1.3.0",
"description": "Work with large numbers on the client side. Round them off to any required precission.",

@@ -8,6 +8,6 @@ "main": "dist/node/js-big-decimal",

"scripts": {
"test": "./node_modules/.bin/jasmine JASMINE_CONFIG_PATH=spec/jasmine.json --helper=spec/helper/*.js",
"test": "ts-node node_modules/jasmine/bin/jasmine --config=spec/jasmine.json --helper=spec/helper/*.js",
"test:watch": "chokidar \"src/**/*.ts\" -c \"npm run travis-test\"",
"pretravis-test": "tsc",
"travis-test": "cross-env JASMINE_CONFIG_PATH=spec/jasmine.json jasmine-ts",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"travis-test": "nyc -x \"**/*.spec.ts\" ts-node node_modules/jasmine/bin/jasmine --config=spec/jasmine.json",
"test-random": "node test/randomtest.js",

@@ -55,2 +55,3 @@ "compile": "tsc",

"del": "^5.1.0",
"doctoc": "^1.4.0",
"glob": "^7.1.6",

@@ -61,6 +62,5 @@ "gulp": "^4.0.2",

"jasmine-spec-reporter": "^5.0.2",
"jasmine-ts": "^0.3.0",
"terser-webpack-plugin": "^3.0.8",
"ts-node": "^8.10.2",
"typescript": "^3.9.7",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.44.1",

@@ -70,3 +70,6 @@ "webpack-cli": "^3.3.12"

"false": {},
"dependencies": {}
"dependencies": {
"coveralls": "^3.1.0",
"nyc": "^15.1.0"
}
}

@@ -5,2 +5,3 @@ # JS Big Decimal

[![devDependencies Status](https://img.shields.io/david/dev/royNiladri/js-big-decimal.svg?style=flat-square)](https://david-dm.org/royNiladri/js-big-decimal?type=dev)
[![Coverage Status](https://img.shields.io/coveralls/github/royNiladri/js-big-decimal/master?style=flat-square)](https://coveralls.io/github/royNiladri/js-big-decimal?branch=master)
[![license](https://img.shields.io/github/license/royNiladri/js-big-decimal.svg?style=flat-square)](https://github.com/royNiladri/js-big-decimal/blob/master/LICENSE)

@@ -32,2 +33,3 @@ [![npm](https://img.shields.io/npm/v/js-big-decimal.svg?style=flat-square)](https://www.npmjs.com/package/js-big-decimal)

- [divide(dividend, divisor, precision)](#dividedividend-divisor-precision)
- [modulus(dividend, divisor)](#modulusdividend-divisor)

@@ -66,3 +68,3 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update -->

### bigDecimal(number)
Create a new objet of type BigDecimal. Supports parameters of type `number` and `string`. If string passed cannot be parsed as a number error is thrown. It is recommended to use string as it circumvents the issue of precision with JS native `float` implementation and max limit for `integer`.
Create a new object of type BigDecimal. Supports parameters of type `number` and `string`. If string passed cannot be parsed as a number error is thrown. It is recommended to use string as it circumvents the issue of precision with JS native `float` implementation and max limit for `integer`.

@@ -84,3 +86,3 @@ It supports exponentiation, but only with integral exponent.

### getPrettyValue(number, digits, separator)
By default this returns the number in standard number format, comma after every three digts. Both arguments, `digits` - the number of digits (of the integral part) to group by, and `separator` - the character to mark the separation. Example of this can be to format a 16 digit number as _credit card_.
By default this returns the number in standard number format, comma after every three digits. Both arguments, `digits` - the number of digits (of the integral part) to group by, and `separator` - the character to mark the separation. Example of this can be to format a 16 digit number as _credit card_.
```javascript

@@ -182,3 +184,3 @@ var value = bigDecimal.getPrettyValue("12345.6789"); // value = "12,345.6789"

### add(augend, addend)
Add two numbers. Pass in negative for substraction. Ensure parameters are `string`s.
Add two numbers. Pass in negative for subtraction. Ensure parameters are `string`s.
```javascript

@@ -222,3 +224,3 @@ var sum = bigDecimal.add("23.678", "67.34"); // sum = "91.018"

```javascript
var quotient = bigDecimal.divide('45', '4', 2); // quotient = 11.25
var quotient = bigDecimal.divide('45', '4', 2); // quotient = '11.25'
```

@@ -231,1 +233,14 @@ Alternately, use the instance property. It returns the result as new `bigDecimal`.

```
### modulus(dividend, divisor)
Get the modulus of two numbers, i.e., remainder when the dividend is divided by the divisor. Note that both divisor and dividend need to be integers.
```javascript
var remainder = bigDecimal.modulus('45', '4'); // remainder = '1'
```
Alternately, use the instance property. It returns the result as new `bigDecimal`.
```javascript
var n1 = new bigDecimal('45');
var n2 = new bigDecimal('4');
var remainder = n1.modulus(n2); // remainder = new bigDecimal('1')
```
Further, the result takes the sign of the dividend and the sign of the divisor is ignored. Note that this behaviour is the same as in Java and JavaScript.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc