@pioneer-platform/helpers 4.0.12 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,14 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BigIntArithmetics = exports.formatBigIntToSafeValue = exports.toMultiplier = void 0;
13
- var types_1 = require("@coinmasters/types");
14
- var TAG = " | BigIntArithmetics | ";
15
- var DEFAULT_DECIMAL = 8;
16
- var bigintPow = function (base, exponent) {
17
- var tag = TAG + " | bigintPow | ";
3
+ exports.BigIntArithmetics = exports.toMultiplier = void 0;
4
+ exports.formatBigIntToSafeValue = formatBigIntToSafeValue;
5
+ const types_1 = require("@coinmasters/types");
6
+ const TAG = " | BigIntArithmetics | ";
7
+ const DEFAULT_DECIMAL = 8;
8
+ const bigintPow = (base, exponent) => {
9
+ let tag = TAG + " | bigintPow | ";
18
10
  try {
19
- var result = BigInt(1);
11
+ let result = BigInt(1);
20
12
  while (exponent > 0) {
21
13
  if (exponent % 2 === 1) {
22
14
  result *= base;
@@ -31,15 +23,15 @@ var bigintPow = function (base, exponent) {
31
23
  return BigInt(1);
32
24
  }
33
25
  };
34
- var toMultiplier = function (decimal) {
35
- var tag = TAG + " | toMultiplier | ";
26
+ const toMultiplier = (decimal) => {
27
+ let tag = TAG + " | toMultiplier | ";
36
28
  //console.log(tag + 'input decimal:', decimal);
37
29
  try {
38
30
  if (decimal < 0) {
39
31
  throw new Error("Decimal must be non-negative");
40
32
  }
41
- var result = BigInt(1);
42
- for (var i = 0; i < decimal; i++) {
33
+ let result = BigInt(1);
34
+ for (let i = 0; i < decimal; i++) {
43
35
  result *= BigInt(10);
44
36
  }
45
37
  //console.log(tag + 'result:', result);
@@ -51,8 +43,8 @@ var toMultiplier = function (decimal) {
51
43
  }
52
44
  };
53
45
  exports.toMultiplier = toMultiplier;
54
- var decimalFromMultiplier = function (multiplier) {
55
- var tag = TAG + " | decimalFromMultiplier | ";
46
+ const decimalFromMultiplier = (multiplier) => {
47
+ let tag = TAG + " | decimalFromMultiplier | ";
56
48
  try {
57
49
  return Math.log10(Number(multiplier));
58
50
  }
@@ -61,9 +53,8 @@ var decimalFromMultiplier = function (multiplier) {
61
53
  return 0;
62
54
  }
63
55
  };
64
- function formatBigIntToSafeValue(_a) {
65
- var value = _a.value, bigIntDecimal = _a.bigIntDecimal, decimal = _a.decimal;
66
- var tag = TAG + " | BigIntArithmetics | ";
56
+ function formatBigIntToSafeValue({ value, bigIntDecimal, decimal, }) {
57
+ const tag = TAG + " | BigIntArithmetics | ";
67
58
  try {
68
59
  //console.log(tag,'value:',value,'bigIntDecimal:',bigIntDecimal,'decimal:',decimal);
69
60
  if (!decimal)
@@ -75,7 +66,7 @@ function formatBigIntToSafeValue(_a) {
75
66
  throw new Error(TAG + 'Negative value is not allowed');
76
67
  }
77
68
  // Convert bigint to string and then to number
78
- var valueString = value.toString();
69
+ let valueString = value.toString();
79
70
  //console.log(tag,'valueString:',valueString);
80
71
  //console.log(tag,'valueString:',valueString.length);
81
72
  //console.log(tag,'decimal:',decimal);
@@ -84,10 +75,10 @@ function formatBigIntToSafeValue(_a) {
84
75
  valueString = '0'.repeat(decimal - valueString.length + 1) + valueString;
85
76
  }
86
77
  // Determine the integer and decimal parts
87
- var integerPart = valueString.slice(0, valueString.length - decimal) || '0';
88
- var decimalPart = valueString.slice(valueString.length - decimal).padEnd(decimal, '0');
78
+ const integerPart = valueString.slice(0, valueString.length - decimal) || '0';
79
+ const decimalPart = valueString.slice(valueString.length - decimal).padEnd(decimal, '0');
89
80
  // Construct the final formatted value
90
- var formattedValue = "".concat(integerPart, ".").concat(decimalPart);
81
+ const formattedValue = `${integerPart}.${decimalPart}`;
91
82
  //console.log(tag,"formattedValue:", formattedValue);
92
83
  return formattedValue;
93
84
  }
@@ -96,8 +87,21 @@ function formatBigIntToSafeValue(_a) {
96
87
  return '';
97
88
  }
98
89
  }
99
- exports.formatBigIntToSafeValue = formatBigIntToSafeValue;
100
- var BigIntArithmetics = /** @class */ (function () {
90
+ class BigIntArithmetics {
91
+ static fromBigInt(value, decimal) {
92
+ let tag = TAG + " | fromBigInt | ";
93
+ try {
94
+ //console.log(tag,"Decimal: ", decimal);
95
+ return new BigIntArithmetics({
96
+ decimal,
97
+ value: formatBigIntToSafeValue({ value, bigIntDecimal: (0, exports.toMultiplier)(decimal || DEFAULT_DECIMAL), decimal }),
98
+ });
99
+ }
100
+ catch (error) {
101
+ console.error(tag + 'Error in fromBigInt:', error);
102
+ return new BigIntArithmetics(0);
103
+ }
104
+ }
101
105
  // static shiftDecimals({
102
106
  // value,
103
107
  // from,
@@ -135,13 +139,13 @@ var BigIntArithmetics = /** @class */ (function () {
135
139
  caip: 'eip155:8453/slip44:60'
136
140
  }
137
141
  */
138
- function BigIntArithmetics(params) {
139
- var tag = TAG + " | constructor | ";
142
+ constructor(params) {
143
+ let tag = TAG + " | constructor | ";
140
144
  try {
141
145
  ////console.log(tag + 'Constructor Params:', params);
142
- var value = getStringValue(params);
146
+ const value = getStringValue(params);
143
147
  ////console.log(tag + 'String Value:', value);
144
- var isComplex = typeof params === 'object' && params !== null;
148
+ const isComplex = typeof params === 'object' && params !== null;
145
149
  this.decimal = isComplex ? params.decimal : undefined;
146
150
  ////console.log(tag , 'Decimal:', this.decimal);
147
151
  ////console.log(tag , 'isComplex:', isComplex);
@@ -149,7 +153,7 @@ var BigIntArithmetics = /** @class */ (function () {
149
153
  this.decimalMultiplier = (0, exports.toMultiplier)(this.decimal || DEFAULT_DECIMAL);
150
154
  }
151
155
  else {
152
- var maxDecimals = Math.max(getFloatDecimals(toSafeValue(value)), this.decimal || 0);
156
+ const maxDecimals = Math.max(getFloatDecimals(toSafeValue(value)), this.decimal || 0);
153
157
  this.decimalMultiplier = (0, exports.toMultiplier)(maxDecimals);
154
158
  }
155
159
  ////console.log(tag + 'Decimal Multiplier:', this.decimalMultiplier);
@@ -163,20 +167,6 @@ var BigIntArithmetics = /** @class */ (function () {
163
167
  this.bigIntValue = BigInt(0);
164
168
  }
165
169
  }
166
- BigIntArithmetics.fromBigInt = function (value, decimal) {
167
- var tag = TAG + " | fromBigInt | ";
168
- try {
169
- //console.log(tag,"Decimal: ", decimal);
170
- return new BigIntArithmetics({
171
- decimal: decimal,
172
- value: formatBigIntToSafeValue({ value: value, bigIntDecimal: (0, exports.toMultiplier)(decimal || DEFAULT_DECIMAL), decimal: decimal }),
173
- });
174
- }
175
- catch (error) {
176
- console.error(tag + 'Error in fromBigInt:', error);
177
- return new BigIntArithmetics(0);
178
- }
179
- };
180
170
  // constructor(params: SKBigIntParams) {
181
171
  // let tag = TAG + " | constructor | ";
182
172
  // try {
@@ -204,75 +194,59 @@ var BigIntArithmetics = /** @class */ (function () {
204
194
  // this.bigIntValue = BigInt(0);
205
195
  // }
206
196
  // }
207
- BigIntArithmetics.prototype.set = function (value) {
208
- var tag = TAG + " | set | ";
197
+ set(value) {
198
+ let tag = TAG + " | set | ";
209
199
  try {
210
200
  // @ts-ignore
211
- return new BigIntArithmetics({ decimal: this.decimal, value: value });
201
+ return new BigIntArithmetics({ decimal: this.decimal, value });
212
202
  }
213
203
  catch (error) {
214
204
  console.error(tag + 'Error in set:', error);
215
205
  return this;
216
206
  }
217
- };
218
- BigIntArithmetics.prototype.add = function () {
219
- var args = [];
220
- for (var _i = 0; _i < arguments.length; _i++) {
221
- args[_i] = arguments[_i];
222
- }
223
- var tag = TAG + " | add | ";
207
+ }
208
+ add(...args) {
209
+ let tag = TAG + " | add | ";
224
210
  try {
225
- return this.arithmetics.apply(this, __spreadArray(['add'], args, false));
211
+ return this.arithmetics('add', ...args);
226
212
  }
227
213
  catch (error) {
228
214
  console.error(tag + 'Error in add:', error);
229
215
  return this;
230
216
  }
231
- };
232
- BigIntArithmetics.prototype.sub = function () {
233
- var args = [];
234
- for (var _i = 0; _i < arguments.length; _i++) {
235
- args[_i] = arguments[_i];
236
- }
237
- var tag = TAG + " | sub | ";
217
+ }
218
+ sub(...args) {
219
+ let tag = TAG + " | sub | ";
238
220
  try {
239
- return this.arithmetics.apply(this, __spreadArray(['sub'], args, false));
221
+ return this.arithmetics('sub', ...args);
240
222
  }
241
223
  catch (error) {
242
224
  console.error(tag + 'Error in sub:', error);
243
225
  return this;
244
226
  }
245
- };
246
- BigIntArithmetics.prototype.mul = function () {
247
- var args = [];
248
- for (var _i = 0; _i < arguments.length; _i++) {
249
- args[_i] = arguments[_i];
250
- }
251
- var tag = TAG + " | mul | ";
227
+ }
228
+ mul(...args) {
229
+ let tag = TAG + " | mul | ";
252
230
  try {
253
- return this.arithmetics.apply(this, __spreadArray(['mul'], args, false));
231
+ return this.arithmetics('mul', ...args);
254
232
  }
255
233
  catch (error) {
256
234
  console.error(tag + 'Error in mul:', error);
257
235
  return this;
258
236
  }
259
- };
260
- BigIntArithmetics.prototype.div = function () {
261
- var args = [];
262
- for (var _i = 0; _i < arguments.length; _i++) {
263
- args[_i] = arguments[_i];
264
- }
265
- var tag = TAG + " | div | ";
237
+ }
238
+ div(...args) {
239
+ let tag = TAG + " | div | ";
266
240
  try {
267
- return this.arithmetics.apply(this, __spreadArray(['div'], args, false));
241
+ return this.arithmetics('div', ...args);
268
242
  }
269
243
  catch (error) {
270
244
  console.error(tag + 'Error in div:', error);
271
245
  return this;
272
246
  }
273
- };
274
- BigIntArithmetics.prototype.gt = function (value) {
275
- var tag = TAG + " | gt | ";
247
+ }
248
+ gt(value) {
249
+ let tag = TAG + " | gt | ";
276
250
  try {
277
251
  return this.comparison('gt', value);
278
252
  }
@@ -280,9 +254,9 @@ var BigIntArithmetics = /** @class */ (function () {
280
254
  console.error(tag + 'Error in gt:', error);
281
255
  return false;
282
256
  }
283
- };
284
- BigIntArithmetics.prototype.gte = function (value) {
285
- var tag = TAG + " | gte | ";
257
+ }
258
+ gte(value) {
259
+ let tag = TAG + " | gte | ";
286
260
  try {
287
261
  return this.comparison('gte', value);
288
262
  }
@@ -290,9 +264,9 @@ var BigIntArithmetics = /** @class */ (function () {
290
264
  console.error(tag + 'Error in gte:', error);
291
265
  return false;
292
266
  }
293
- };
294
- BigIntArithmetics.prototype.lt = function (value) {
295
- var tag = TAG + " | lt | ";
267
+ }
268
+ lt(value) {
269
+ let tag = TAG + " | lt | ";
296
270
  try {
297
271
  return this.comparison('lt', value);
298
272
  }
@@ -300,9 +274,9 @@ var BigIntArithmetics = /** @class */ (function () {
300
274
  console.error(tag + 'Error in lt:', error);
301
275
  return false;
302
276
  }
303
- };
304
- BigIntArithmetics.prototype.lte = function (value) {
305
- var tag = TAG + " | lte | ";
277
+ }
278
+ lte(value) {
279
+ let tag = TAG + " | lte | ";
306
280
  try {
307
281
  return this.comparison('lte', value);
308
282
  }
@@ -310,9 +284,9 @@ var BigIntArithmetics = /** @class */ (function () {
310
284
  console.error(tag + 'Error in lte:', error);
311
285
  return false;
312
286
  }
313
- };
314
- BigIntArithmetics.prototype.eqValue = function (value) {
315
- var tag = TAG + " | eqValue | ";
287
+ }
288
+ eqValue(value) {
289
+ let tag = TAG + " | eqValue | ";
316
290
  try {
317
291
  return this.comparison('eqValue', value);
318
292
  }
@@ -320,14 +294,14 @@ var BigIntArithmetics = /** @class */ (function () {
320
294
  console.error(tag + 'Error in eqValue:', error);
321
295
  return false;
322
296
  }
323
- };
297
+ }
324
298
  //@ts-ignore
325
- BigIntArithmetics.prototype.getValue = function (type) {
326
- var tag = TAG + " | getValue | ";
299
+ getValue(type) {
300
+ let tag = TAG + " | getValue | ";
327
301
  try {
328
302
  //console.log(tag,'getValue type:', type);
329
303
  //console.log(tag,'decimalMultiplier: ', this.decimalMultiplier);
330
- var value = formatBigIntToSafeValue({
304
+ const value = formatBigIntToSafeValue({
331
305
  value: this.bigIntValue,
332
306
  bigIntDecimal: (0, exports.toMultiplier)(this.decimal || DEFAULT_DECIMAL),
333
307
  decimal: this.decimal || DEFAULT_DECIMAL,
@@ -347,13 +321,13 @@ var BigIntArithmetics = /** @class */ (function () {
347
321
  console.error(tag + 'Error in getValue:', error);
348
322
  return null;
349
323
  }
350
- };
324
+ }
351
325
  // @ts-ignore
352
- BigIntArithmetics.prototype.getBaseValue = function (type) {
353
- var tag = TAG + " | getBaseValue | ";
326
+ getBaseValue(type) {
327
+ let tag = TAG + " | getBaseValue | ";
354
328
  try {
355
- var divisor = this.decimalMultiplier / (0, exports.toMultiplier)(this.decimal || types_1.BaseDecimal.THOR);
356
- var baseValue = this.bigIntValue / divisor;
329
+ const divisor = this.decimalMultiplier / (0, exports.toMultiplier)(this.decimal || types_1.BaseDecimal.THOR);
330
+ const baseValue = this.bigIntValue / divisor;
357
331
  switch (type) {
358
332
  case 'number':
359
333
  return Number(baseValue);
@@ -367,15 +341,15 @@ var BigIntArithmetics = /** @class */ (function () {
367
341
  console.error(tag + 'Error in getBaseValue:', error);
368
342
  return null;
369
343
  }
370
- };
371
- BigIntArithmetics.prototype.getBigIntValue = function (value, decimal) {
372
- var tag = TAG + " | getBigIntValue | ";
344
+ }
345
+ getBigIntValue(value, decimal) {
346
+ let tag = TAG + " | getBigIntValue | ";
373
347
  try {
374
348
  if (!decimal && typeof value === 'object' && value !== null) {
375
349
  return value.bigIntValue;
376
350
  }
377
- var stringValue = getStringValue(value);
378
- var safeValue = toSafeValue(stringValue);
351
+ const stringValue = getStringValue(value);
352
+ const safeValue = toSafeValue(stringValue);
379
353
  if (safeValue === '0' || safeValue === 'undefined')
380
354
  return BigInt(0);
381
355
  return this.toBigInt(safeValue, decimal);
@@ -384,15 +358,14 @@ var BigIntArithmetics = /** @class */ (function () {
384
358
  console.error(tag + 'Error in getBigIntValue:', error);
385
359
  return BigInt(0);
386
360
  }
387
- };
388
- BigIntArithmetics.prototype.toSignificant = function (significantDigits) {
389
- if (significantDigits === void 0) { significantDigits = 6; }
390
- var tag = TAG + " | toSignificant | ";
361
+ }
362
+ toSignificant(significantDigits = 6) {
363
+ let tag = TAG + " | toSignificant | ";
391
364
  try {
392
- var _a = this.getValue('string').split('.'), int = _a[0], dec = _a[1];
393
- var integer = int || '';
394
- var decimal = dec || '';
395
- var valueLength = parseInt(integer) ? integer.length + decimal.length : decimal.length;
365
+ const [int, dec] = this.getValue('string').split('.');
366
+ const integer = int || '';
367
+ const decimal = dec || '';
368
+ const valueLength = parseInt(integer) ? integer.length + decimal.length : decimal.length;
396
369
  if (valueLength <= significantDigits) {
397
370
  return this.getValue('string');
398
371
  }
@@ -400,111 +373,102 @@ var BigIntArithmetics = /** @class */ (function () {
400
373
  return integer.slice(0, significantDigits).padEnd(integer.length, '0');
401
374
  }
402
375
  if (parseInt(integer)) {
403
- return "".concat(integer, ".").concat(decimal.slice(0, significantDigits - integer.length)).padEnd(significantDigits - integer.length, '0');
376
+ return `${integer}.${decimal.slice(0, significantDigits - integer.length)}`.padEnd(significantDigits - integer.length, '0');
404
377
  }
405
- var trimmedDecimal = parseInt(decimal);
406
- var slicedDecimal = "".concat(trimmedDecimal).slice(0, significantDigits);
407
- return "0.".concat(slicedDecimal.padStart(decimal.length - "".concat(trimmedDecimal).length + slicedDecimal.length, '0'));
378
+ const trimmedDecimal = parseInt(decimal);
379
+ const slicedDecimal = `${trimmedDecimal}`.slice(0, significantDigits);
380
+ return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, '0')}`;
408
381
  }
409
382
  catch (error) {
410
383
  console.error(tag + 'Error in toSignificant:', error);
411
384
  return '';
412
385
  }
413
- };
414
- BigIntArithmetics.prototype.toFixed = function (fixedDigits) {
415
- if (fixedDigits === void 0) { fixedDigits = 6; }
416
- var tag = TAG + " | toFixed | ";
386
+ }
387
+ toFixed(fixedDigits = 6) {
388
+ let tag = TAG + " | toFixed | ";
417
389
  try {
418
- var _a = this.getValue('string').split('.'), int = _a[0], dec = _a[1];
419
- var integer = int || '';
420
- var decimal = dec || '';
390
+ const [int, dec] = this.getValue('string').split('.');
391
+ const integer = int || '';
392
+ const decimal = dec || '';
421
393
  if (parseInt(integer)) {
422
- return "".concat(integer, ".").concat(decimal.slice(0, fixedDigits)).padEnd(fixedDigits, '0');
394
+ return `${integer}.${decimal.slice(0, fixedDigits)}`.padEnd(fixedDigits, '0');
423
395
  }
424
- var trimmedDecimal = parseInt(decimal);
425
- var slicedDecimal = "".concat(trimmedDecimal).slice(0, fixedDigits);
426
- return "0.".concat(slicedDecimal.padStart(decimal.length - "".concat(trimmedDecimal).length + slicedDecimal.length, '0'));
396
+ const trimmedDecimal = parseInt(decimal);
397
+ const slicedDecimal = `${trimmedDecimal}`.slice(0, fixedDigits);
398
+ return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, '0')}`;
427
399
  }
428
400
  catch (error) {
429
401
  console.error(tag + 'Error in toFixed:', error);
430
402
  return '';
431
403
  }
432
- };
433
- BigIntArithmetics.prototype.toAbbreviation = function (digits) {
434
- if (digits === void 0) { digits = 2; }
435
- var tag = TAG + " | toAbbreviation | ";
404
+ }
405
+ toAbbreviation(digits = 2) {
406
+ let tag = TAG + " | toAbbreviation | ";
436
407
  try {
437
- var value = this.getValue('number');
438
- var abbreviations = ['', 'K', 'M', 'B', 'T', 'Q', 'Qi', 'S'];
439
- var tier = Math.floor(Math.log10(Math.abs(value)) / 3);
440
- var suffix = abbreviations[tier];
408
+ const value = this.getValue('number');
409
+ const abbreviations = ['', 'K', 'M', 'B', 'T', 'Q', 'Qi', 'S'];
410
+ const tier = Math.floor(Math.log10(Math.abs(value)) / 3);
411
+ const suffix = abbreviations[tier];
441
412
  if (!suffix)
442
413
  return this.getValue('string');
443
- var scale = Math.pow(10, (tier * 3));
444
- var scaled = value / scale;
445
- return "".concat(scaled.toFixed(digits)).concat(suffix);
414
+ const scale = Math.pow(10, (tier * 3));
415
+ const scaled = value / scale;
416
+ return `${scaled.toFixed(digits)}${suffix}`;
446
417
  }
447
418
  catch (error) {
448
419
  console.error(tag + 'Error in toAbbreviation:', error);
449
420
  return '';
450
421
  }
451
- };
452
- BigIntArithmetics.prototype.toCurrency = function (currency, _a) {
453
- if (currency === void 0) { currency = '$'; }
454
- var _b = _a === void 0 ? {} : _a, _c = _b.currencyPosition, currencyPosition = _c === void 0 ? 'start' : _c, _d = _b.decimal, decimal = _d === void 0 ? 2 : _d, _e = _b.decimalSeparator, decimalSeparator = _e === void 0 ? '.' : _e, _f = _b.thousandSeparator, thousandSeparator = _f === void 0 ? ',' : _f;
455
- var tag = TAG + " | toCurrency | ";
422
+ }
423
+ toCurrency(currency = '$', { currencyPosition = 'start', decimal = 2, decimalSeparator = '.', thousandSeparator = ',', } = {}) {
424
+ let tag = TAG + " | toCurrency | ";
456
425
  try {
457
- var value = this.getValue('number');
458
- var _g = value.toFixed(6).split('.'), int = _g[0], _h = _g[1], dec = _h === void 0 ? '' : _h;
459
- var integer = int.replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator);
460
- var parsedValue = !int && !dec
426
+ const value = this.getValue('number');
427
+ const [int, dec = ''] = value.toFixed(6).split('.');
428
+ const integer = int.replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator);
429
+ const parsedValue = !int && !dec
461
430
  ? '0.00'
462
431
  : int === '0'
463
- ? "".concat(parseFloat("0.".concat(dec))).replace('.', decimalSeparator)
464
- : "".concat(integer).concat(parseInt(dec) ? "".concat(decimalSeparator).concat(dec.slice(0, decimal)) : '');
465
- return "".concat(currencyPosition === 'start' ? currency : '').concat(parsedValue).concat(currencyPosition === 'end' ? currency : '');
432
+ ? `${parseFloat(`0.${dec}`)}`.replace('.', decimalSeparator)
433
+ : `${integer}${parseInt(dec) ? `${decimalSeparator}${dec.slice(0, decimal)}` : ''}`;
434
+ return `${currencyPosition === 'start' ? currency : ''}${parsedValue}${currencyPosition === 'end' ? currency : ''}`;
466
435
  }
467
436
  catch (error) {
468
437
  console.error(tag + 'Error in toCurrency:', error);
469
438
  return '';
470
439
  }
471
- };
472
- BigIntArithmetics.prototype.arithmetics = function (method) {
473
- var _this = this;
474
- var args = [];
475
- for (var _i = 1; _i < arguments.length; _i++) {
476
- args[_i - 1] = arguments[_i];
477
- }
478
- var tag = TAG + " | arithmetics | ";
440
+ }
441
+ arithmetics(method, ...args) {
442
+ let tag = TAG + " | arithmetics | ";
479
443
  try {
480
- var precisionDecimal = this.retrievePrecisionDecimal.apply(this, __spreadArray([this], args, false));
481
- var decimal_1 = Math.max(precisionDecimal, decimalFromMultiplier(this.decimalMultiplier));
482
- var precisionDecimalMultiplier_1 = (0, exports.toMultiplier)(decimal_1);
483
- var result = args.reduce(function (acc, arg) {
484
- var value = _this.getBigIntValue(arg, decimal_1);
444
+ const precisionDecimal = this.retrievePrecisionDecimal(this, ...args);
445
+ const decimal = Math.max(precisionDecimal, decimalFromMultiplier(this.decimalMultiplier));
446
+ const precisionDecimalMultiplier = (0, exports.toMultiplier)(decimal);
447
+ const result = args.reduce((acc, arg) => {
448
+ const value = this.getBigIntValue(arg, decimal);
485
449
  switch (method) {
486
450
  case 'add':
487
451
  return acc + value;
488
452
  case 'sub':
489
453
  return acc - value;
490
454
  case 'mul':
491
- return (acc * value) / precisionDecimalMultiplier_1;
455
+ return (acc * value) / precisionDecimalMultiplier;
492
456
  case 'div': {
493
457
  if (value === BigInt(0))
494
458
  throw new RangeError('Division by zero');
495
- return (acc * precisionDecimalMultiplier_1) / value;
459
+ return (acc * precisionDecimalMultiplier) / value;
496
460
  }
497
461
  default:
498
462
  return acc;
499
463
  }
500
- }, (this.bigIntValue * precisionDecimalMultiplier_1) / this.decimalMultiplier);
501
- var formattedValue = formatBigIntToSafeValue({
502
- bigIntDecimal: (0, exports.toMultiplier)(decimal_1),
503
- decimal: decimal_1,
464
+ }, (this.bigIntValue * precisionDecimalMultiplier) / this.decimalMultiplier);
465
+ const formattedValue = formatBigIntToSafeValue({
466
+ bigIntDecimal: (0, exports.toMultiplier)(decimal),
467
+ decimal,
504
468
  value: result,
505
469
  });
506
470
  return new BigIntArithmetics({
507
- decimalMultiplier: (0, exports.toMultiplier)(decimal_1),
471
+ decimalMultiplier: (0, exports.toMultiplier)(decimal),
508
472
  decimal: this.decimal,
509
473
  value: formattedValue,
510
474
  });
@@ -513,17 +477,13 @@ var BigIntArithmetics = /** @class */ (function () {
513
477
  console.error(tag + 'Error in arithmetics:', error);
514
478
  return this;
515
479
  }
516
- };
517
- BigIntArithmetics.prototype.comparison = function (method) {
518
- var args = [];
519
- for (var _i = 1; _i < arguments.length; _i++) {
520
- args[_i - 1] = arguments[_i];
521
- }
522
- var tag = TAG + " | comparison | ";
480
+ }
481
+ comparison(method, ...args) {
482
+ let tag = TAG + " | comparison | ";
523
483
  try {
524
- var decimal = this.retrievePrecisionDecimal.apply(this, __spreadArray([this], args, false));
525
- var value = this.getBigIntValue(args[0], decimal);
526
- var compareToValue = this.getBigIntValue(this, decimal);
484
+ const decimal = this.retrievePrecisionDecimal(this, ...args);
485
+ const value = this.getBigIntValue(args[0], decimal);
486
+ const compareToValue = this.getBigIntValue(this, decimal);
527
487
  switch (method) {
528
488
  case 'gt':
529
489
  return compareToValue > value;
@@ -541,70 +501,65 @@ var BigIntArithmetics = /** @class */ (function () {
541
501
  console.error(tag + 'Error in comparison:', error);
542
502
  return false;
543
503
  }
544
- };
545
- BigIntArithmetics.prototype.setValue = function (value) {
546
- var tag = TAG + " | setValue | ";
504
+ }
505
+ setValue(value) {
506
+ let tag = TAG + " | setValue | ";
547
507
  try {
548
508
  //console.log(tag, 'value:', value);
549
509
  //console.log(tag, ' this.decimal:', this.decimal);
550
- var safeValue = formatBigIntToSafeValue({ value: value, decimal: this.decimal });
510
+ const safeValue = formatBigIntToSafeValue({ value: value, decimal: this.decimal });
551
511
  //console.log(tag, 'safeValue:', safeValue);
552
512
  this.bigIntValue = this.toBigInt(safeValue);
553
513
  }
554
514
  catch (error) {
555
515
  console.error(tag + 'Error in setValue:', error);
556
516
  }
557
- };
558
- BigIntArithmetics.prototype.retrievePrecisionDecimal = function () {
559
- var args = [];
560
- for (var _i = 0; _i < arguments.length; _i++) {
561
- args[_i] = arguments[_i];
562
- }
563
- var tag = TAG + " | retrievePrecisionDecimal | ";
517
+ }
518
+ retrievePrecisionDecimal(...args) {
519
+ let tag = TAG + " | retrievePrecisionDecimal | ";
564
520
  try {
565
- var decimals = args
566
- .map(function (arg) {
567
- var isObject = typeof arg === 'object' && arg !== null;
568
- var value = isObject
521
+ const decimals = args
522
+ .map((arg) => {
523
+ const isObject = typeof arg === 'object' && arg !== null;
524
+ const value = isObject
569
525
  ? arg.decimal || decimalFromMultiplier(arg.decimalMultiplier)
570
526
  : getFloatDecimals(toSafeValue(arg));
571
527
  return value;
572
528
  })
573
529
  .filter(Boolean);
574
- return Math.max.apply(Math, __spreadArray(__spreadArray([], decimals, false), [DEFAULT_DECIMAL], false));
530
+ return Math.max(...decimals, DEFAULT_DECIMAL);
575
531
  }
576
532
  catch (error) {
577
533
  console.error(tag + 'Error in retrievePrecisionDecimal:', error);
578
534
  return DEFAULT_DECIMAL;
579
535
  }
580
- };
581
- BigIntArithmetics.prototype.toBigInt = function (value, decimal) {
582
- var tag = TAG + " | toBigInt | ";
536
+ }
537
+ toBigInt(value, decimal) {
538
+ let tag = TAG + " | toBigInt | ";
583
539
  try {
584
- var multiplier = decimal ? (0, exports.toMultiplier)(decimal) : this.decimalMultiplier;
585
- var padDecimal = decimalFromMultiplier(multiplier);
586
- var _a = value.split('.'), _b = _a[0], integerPart = _b === void 0 ? '' : _b, _c = _a[1], decimalPart = _c === void 0 ? '' : _c;
587
- return BigInt("".concat(integerPart).concat(decimalPart.padEnd(padDecimal, '0')));
540
+ const multiplier = decimal ? (0, exports.toMultiplier)(decimal) : this.decimalMultiplier;
541
+ const padDecimal = decimalFromMultiplier(multiplier);
542
+ const [integerPart = '', decimalPart = ''] = value.split('.');
543
+ return BigInt(`${integerPart}${decimalPart.padEnd(padDecimal, '0')}`);
588
544
  }
589
545
  catch (error) {
590
546
  console.error(tag + 'Error in toBigInt:', error);
591
547
  return BigInt(0);
592
548
  }
593
- };
594
- return BigIntArithmetics;
595
- }());
549
+ }
550
+ }
596
551
  exports.BigIntArithmetics = BigIntArithmetics;
597
- var numberFormatter = Intl.NumberFormat('fullwide', {
552
+ const numberFormatter = Intl.NumberFormat('fullwide', {
598
553
  useGrouping: false,
599
554
  maximumFractionDigits: 20,
600
555
  });
601
556
  function toSafeValue(value) {
602
- var tag = TAG + " | toSafeValue | ";
557
+ let tag = TAG + " | toSafeValue | ";
603
558
  try {
604
- var parsedValue = typeof value === 'number' ? numberFormatter.format(value) : getStringValue(value);
605
- var splitValue = "".concat(parsedValue).replace(/,/g, '.').split('.');
559
+ const parsedValue = typeof value === 'number' ? numberFormatter.format(value) : getStringValue(value);
560
+ const splitValue = `${parsedValue}`.replace(/,/g, '.').split('.');
606
561
  return splitValue.length > 1
607
- ? "".concat(splitValue.slice(0, -1).join(''), ".").concat(splitValue.at(-1))
562
+ ? `${splitValue.slice(0, -1).join('')}.${splitValue.at(-1)}`
608
563
  : splitValue[0];
609
564
  }
610
565
  catch (error) {
@@ -613,10 +568,10 @@ function toSafeValue(value) {
613
568
  }
614
569
  }
615
570
  function getFloatDecimals(value) {
616
- var tag = TAG + " | getFloatDecimals | ";
571
+ let tag = TAG + " | getFloatDecimals | ";
617
572
  try {
618
- var decimals = 0;
619
- var parts = value.split('.');
573
+ let decimals = 0;
574
+ const parts = value.split('.');
620
575
  if (parts.length > 1 && parts[1].length > 0) {
621
576
  decimals = parts[1].length;
622
577
  }
@@ -628,7 +583,7 @@ function getFloatDecimals(value) {
628
583
  }
629
584
  }
630
585
  function getStringValue(param) {
631
- var tag = TAG + " | getStringValue | ";
586
+ let tag = TAG + " | getStringValue | ";
632
587
  try {
633
588
  return typeof param === 'object' && param !== null
634
589
  ? 'getValue' in param