steamutils 1.4.32 → 1.4.34

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.
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GBrowserProjectService"><![CDATA[{
4
+ "tabs": [
5
+ {
6
+ "url": "http://google.com.vn",
7
+ "createdAt": "2024-08-14T16:14:35Z"
8
+ }
9
+ ]
10
+ }]]></component>
11
+ </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.4.32",
3
+ "version": "1.4.34",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",
package/utils.js CHANGED
@@ -1,6 +1,515 @@
1
1
  import { EAuthTokenPlatformType, LoginApprover, LoginSession } from "steam-session";
2
+ import moment from "moment";
2
3
 
3
4
  const isBrowser = typeof window !== "undefined";
5
+ const g_rgCurrencyData = {
6
+ USD: {
7
+ strCode: "USD",
8
+ eCurrencyCode: 1,
9
+ strSymbol: "$",
10
+ bSymbolIsPrefix: true,
11
+ bWholeUnitsOnly: false,
12
+ strDecimalSymbol: ".",
13
+ strThousandsSeparator: ",",
14
+ strSymbolAndNumberSeparator: "",
15
+ },
16
+ GBP: {
17
+ strCode: "GBP",
18
+ eCurrencyCode: 2,
19
+ strSymbol: "\u00a3",
20
+ bSymbolIsPrefix: true,
21
+ bWholeUnitsOnly: false,
22
+ strDecimalSymbol: ".",
23
+ strThousandsSeparator: ",",
24
+ strSymbolAndNumberSeparator: "",
25
+ },
26
+ EUR: {
27
+ strCode: "EUR",
28
+ eCurrencyCode: 3,
29
+ strSymbol: "\u20ac",
30
+ bSymbolIsPrefix: false,
31
+ bWholeUnitsOnly: false,
32
+ strDecimalSymbol: ",",
33
+ strThousandsSeparator: " ",
34
+ strSymbolAndNumberSeparator: "",
35
+ },
36
+ CHF: {
37
+ strCode: "CHF",
38
+ eCurrencyCode: 4,
39
+ strSymbol: "CHF",
40
+ bSymbolIsPrefix: true,
41
+ bWholeUnitsOnly: false,
42
+ strDecimalSymbol: ".",
43
+ strThousandsSeparator: " ",
44
+ strSymbolAndNumberSeparator: " ",
45
+ },
46
+ RUB: {
47
+ strCode: "RUB",
48
+ eCurrencyCode: 5,
49
+ strSymbol: "p\u0443\u0431.",
50
+ bSymbolIsPrefix: false,
51
+ bWholeUnitsOnly: true,
52
+ strDecimalSymbol: ",",
53
+ strThousandsSeparator: "",
54
+ strSymbolAndNumberSeparator: " ",
55
+ },
56
+ BRL: {
57
+ strCode: "BRL",
58
+ eCurrencyCode: 7,
59
+ strSymbol: "R$",
60
+ bSymbolIsPrefix: true,
61
+ bWholeUnitsOnly: false,
62
+ strDecimalSymbol: ",",
63
+ strThousandsSeparator: ".",
64
+ strSymbolAndNumberSeparator: " ",
65
+ },
66
+ JPY: {
67
+ strCode: "JPY",
68
+ eCurrencyCode: 8,
69
+ strSymbol: "\u00a5",
70
+ bSymbolIsPrefix: true,
71
+ bWholeUnitsOnly: true,
72
+ strDecimalSymbol: ".",
73
+ strThousandsSeparator: ",",
74
+ strSymbolAndNumberSeparator: " ",
75
+ },
76
+ NOK: {
77
+ strCode: "NOK",
78
+ eCurrencyCode: 9,
79
+ strSymbol: "kr",
80
+ bSymbolIsPrefix: false,
81
+ bWholeUnitsOnly: false,
82
+ strDecimalSymbol: ",",
83
+ strThousandsSeparator: ".",
84
+ strSymbolAndNumberSeparator: " ",
85
+ },
86
+ IDR: {
87
+ strCode: "IDR",
88
+ eCurrencyCode: 10,
89
+ strSymbol: "Rp",
90
+ bSymbolIsPrefix: true,
91
+ bWholeUnitsOnly: true,
92
+ strDecimalSymbol: ".",
93
+ strThousandsSeparator: " ",
94
+ strSymbolAndNumberSeparator: " ",
95
+ },
96
+ MYR: {
97
+ strCode: "MYR",
98
+ eCurrencyCode: 11,
99
+ strSymbol: "RM",
100
+ bSymbolIsPrefix: true,
101
+ bWholeUnitsOnly: false,
102
+ strDecimalSymbol: ".",
103
+ strThousandsSeparator: ",",
104
+ strSymbolAndNumberSeparator: "",
105
+ },
106
+ PHP: {
107
+ strCode: "PHP",
108
+ eCurrencyCode: 12,
109
+ strSymbol: "P",
110
+ bSymbolIsPrefix: true,
111
+ bWholeUnitsOnly: false,
112
+ strDecimalSymbol: ".",
113
+ strThousandsSeparator: ",",
114
+ strSymbolAndNumberSeparator: "",
115
+ },
116
+ SGD: {
117
+ strCode: "SGD",
118
+ eCurrencyCode: 13,
119
+ strSymbol: "S$",
120
+ bSymbolIsPrefix: true,
121
+ bWholeUnitsOnly: false,
122
+ strDecimalSymbol: ".",
123
+ strThousandsSeparator: ",",
124
+ strSymbolAndNumberSeparator: "",
125
+ },
126
+ THB: {
127
+ strCode: "THB",
128
+ eCurrencyCode: 14,
129
+ strSymbol: "\u0e3f",
130
+ bSymbolIsPrefix: true,
131
+ bWholeUnitsOnly: false,
132
+ strDecimalSymbol: ".",
133
+ strThousandsSeparator: ",",
134
+ strSymbolAndNumberSeparator: "",
135
+ },
136
+ VND: {
137
+ strCode: "VND",
138
+ eCurrencyCode: 15,
139
+ strSymbol: "\u20ab",
140
+ bSymbolIsPrefix: false,
141
+ bWholeUnitsOnly: true,
142
+ strDecimalSymbol: ",",
143
+ strThousandsSeparator: ".",
144
+ strSymbolAndNumberSeparator: "",
145
+ },
146
+ KRW: {
147
+ strCode: "KRW",
148
+ eCurrencyCode: 16,
149
+ strSymbol: "\u20a9",
150
+ bSymbolIsPrefix: true,
151
+ bWholeUnitsOnly: true,
152
+ strDecimalSymbol: ".",
153
+ strThousandsSeparator: ",",
154
+ strSymbolAndNumberSeparator: " ",
155
+ },
156
+ TRY: {
157
+ strCode: "TRY",
158
+ eCurrencyCode: 17,
159
+ strSymbol: "TL",
160
+ bSymbolIsPrefix: false,
161
+ bWholeUnitsOnly: false,
162
+ strDecimalSymbol: ",",
163
+ strThousandsSeparator: ".",
164
+ strSymbolAndNumberSeparator: " ",
165
+ },
166
+ UAH: {
167
+ strCode: "UAH",
168
+ eCurrencyCode: 18,
169
+ strSymbol: "\u20b4",
170
+ bSymbolIsPrefix: false,
171
+ bWholeUnitsOnly: true,
172
+ strDecimalSymbol: ",",
173
+ strThousandsSeparator: " ",
174
+ strSymbolAndNumberSeparator: "",
175
+ },
176
+ MXN: {
177
+ strCode: "MXN",
178
+ eCurrencyCode: 19,
179
+ strSymbol: "Mex$",
180
+ bSymbolIsPrefix: true,
181
+ bWholeUnitsOnly: false,
182
+ strDecimalSymbol: ".",
183
+ strThousandsSeparator: ",",
184
+ strSymbolAndNumberSeparator: " ",
185
+ },
186
+ CAD: {
187
+ strCode: "CAD",
188
+ eCurrencyCode: 20,
189
+ strSymbol: "CDN$",
190
+ bSymbolIsPrefix: true,
191
+ bWholeUnitsOnly: false,
192
+ strDecimalSymbol: ".",
193
+ strThousandsSeparator: ",",
194
+ strSymbolAndNumberSeparator: " ",
195
+ },
196
+ AUD: {
197
+ strCode: "AUD",
198
+ eCurrencyCode: 21,
199
+ strSymbol: "A$",
200
+ bSymbolIsPrefix: true,
201
+ bWholeUnitsOnly: false,
202
+ strDecimalSymbol: ".",
203
+ strThousandsSeparator: ",",
204
+ strSymbolAndNumberSeparator: " ",
205
+ },
206
+ NZD: {
207
+ strCode: "NZD",
208
+ eCurrencyCode: 22,
209
+ strSymbol: "NZ$",
210
+ bSymbolIsPrefix: true,
211
+ bWholeUnitsOnly: false,
212
+ strDecimalSymbol: ".",
213
+ strThousandsSeparator: ",",
214
+ strSymbolAndNumberSeparator: " ",
215
+ },
216
+ PLN: {
217
+ strCode: "PLN",
218
+ eCurrencyCode: 6,
219
+ strSymbol: "z\u0142",
220
+ bSymbolIsPrefix: false,
221
+ bWholeUnitsOnly: false,
222
+ strDecimalSymbol: ",",
223
+ strThousandsSeparator: " ",
224
+ strSymbolAndNumberSeparator: "",
225
+ },
226
+ CNY: {
227
+ strCode: "CNY",
228
+ eCurrencyCode: 23,
229
+ strSymbol: "\u00a5",
230
+ bSymbolIsPrefix: true,
231
+ bWholeUnitsOnly: false,
232
+ strDecimalSymbol: ".",
233
+ strThousandsSeparator: ",",
234
+ strSymbolAndNumberSeparator: " ",
235
+ },
236
+ INR: {
237
+ strCode: "INR",
238
+ eCurrencyCode: 24,
239
+ strSymbol: "\u20b9",
240
+ bSymbolIsPrefix: true,
241
+ bWholeUnitsOnly: true,
242
+ strDecimalSymbol: ".",
243
+ strThousandsSeparator: ",",
244
+ strSymbolAndNumberSeparator: " ",
245
+ },
246
+ CLP: {
247
+ strCode: "CLP",
248
+ eCurrencyCode: 25,
249
+ strSymbol: "CLP$",
250
+ bSymbolIsPrefix: true,
251
+ bWholeUnitsOnly: true,
252
+ strDecimalSymbol: ",",
253
+ strThousandsSeparator: ".",
254
+ strSymbolAndNumberSeparator: " ",
255
+ },
256
+ PEN: {
257
+ strCode: "PEN",
258
+ eCurrencyCode: 26,
259
+ strSymbol: "S/.",
260
+ bSymbolIsPrefix: true,
261
+ bWholeUnitsOnly: false,
262
+ strDecimalSymbol: ".",
263
+ strThousandsSeparator: ",",
264
+ strSymbolAndNumberSeparator: "",
265
+ },
266
+ COP: {
267
+ strCode: "COP",
268
+ eCurrencyCode: 27,
269
+ strSymbol: "COL$",
270
+ bSymbolIsPrefix: true,
271
+ bWholeUnitsOnly: true,
272
+ strDecimalSymbol: ",",
273
+ strThousandsSeparator: ".",
274
+ strSymbolAndNumberSeparator: " ",
275
+ },
276
+ ZAR: {
277
+ strCode: "ZAR",
278
+ eCurrencyCode: 28,
279
+ strSymbol: "R",
280
+ bSymbolIsPrefix: true,
281
+ bWholeUnitsOnly: false,
282
+ strDecimalSymbol: ".",
283
+ strThousandsSeparator: " ",
284
+ strSymbolAndNumberSeparator: " ",
285
+ },
286
+ HKD: {
287
+ strCode: "HKD",
288
+ eCurrencyCode: 29,
289
+ strSymbol: "HK$",
290
+ bSymbolIsPrefix: true,
291
+ bWholeUnitsOnly: false,
292
+ strDecimalSymbol: ".",
293
+ strThousandsSeparator: ",",
294
+ strSymbolAndNumberSeparator: " ",
295
+ },
296
+ TWD: {
297
+ strCode: "TWD",
298
+ eCurrencyCode: 30,
299
+ strSymbol: "NT$",
300
+ bSymbolIsPrefix: true,
301
+ bWholeUnitsOnly: true,
302
+ strDecimalSymbol: ".",
303
+ strThousandsSeparator: ",",
304
+ strSymbolAndNumberSeparator: " ",
305
+ },
306
+ SAR: {
307
+ strCode: "SAR",
308
+ eCurrencyCode: 31,
309
+ strSymbol: "SR",
310
+ bSymbolIsPrefix: false,
311
+ bWholeUnitsOnly: false,
312
+ strDecimalSymbol: ".",
313
+ strThousandsSeparator: ",",
314
+ strSymbolAndNumberSeparator: " ",
315
+ },
316
+ AED: {
317
+ strCode: "AED",
318
+ eCurrencyCode: 32,
319
+ strSymbol: "AED",
320
+ bSymbolIsPrefix: false,
321
+ bWholeUnitsOnly: false,
322
+ strDecimalSymbol: ".",
323
+ strThousandsSeparator: ",",
324
+ strSymbolAndNumberSeparator: " ",
325
+ },
326
+ SEK: {
327
+ strCode: "SEK",
328
+ eCurrencyCode: 33,
329
+ strSymbol: "kr",
330
+ bSymbolIsPrefix: false,
331
+ bWholeUnitsOnly: false,
332
+ strDecimalSymbol: ".",
333
+ strThousandsSeparator: ",",
334
+ strSymbolAndNumberSeparator: " ",
335
+ },
336
+ ARS: {
337
+ strCode: "ARS",
338
+ eCurrencyCode: 34,
339
+ strSymbol: "ARS$",
340
+ bSymbolIsPrefix: true,
341
+ bWholeUnitsOnly: false,
342
+ strDecimalSymbol: ",",
343
+ strThousandsSeparator: ".",
344
+ strSymbolAndNumberSeparator: " ",
345
+ },
346
+ ILS: {
347
+ strCode: "ILS",
348
+ eCurrencyCode: 35,
349
+ strSymbol: "\u20aa",
350
+ bSymbolIsPrefix: true,
351
+ bWholeUnitsOnly: false,
352
+ strDecimalSymbol: ".",
353
+ strThousandsSeparator: ",",
354
+ strSymbolAndNumberSeparator: "",
355
+ },
356
+ BYN: {
357
+ strCode: "BYN",
358
+ eCurrencyCode: 36,
359
+ strSymbol: "Br",
360
+ bSymbolIsPrefix: true,
361
+ bWholeUnitsOnly: false,
362
+ strDecimalSymbol: ".",
363
+ strThousandsSeparator: ",",
364
+ strSymbolAndNumberSeparator: "",
365
+ },
366
+ KZT: {
367
+ strCode: "KZT",
368
+ eCurrencyCode: 37,
369
+ strSymbol: "\u20b8",
370
+ bSymbolIsPrefix: false,
371
+ bWholeUnitsOnly: true,
372
+ strDecimalSymbol: ",",
373
+ strThousandsSeparator: " ",
374
+ strSymbolAndNumberSeparator: "",
375
+ },
376
+ KWD: {
377
+ strCode: "KWD",
378
+ eCurrencyCode: 38,
379
+ strSymbol: "KD",
380
+ bSymbolIsPrefix: false,
381
+ bWholeUnitsOnly: false,
382
+ strDecimalSymbol: ".",
383
+ strThousandsSeparator: ",",
384
+ strSymbolAndNumberSeparator: " ",
385
+ },
386
+ QAR: {
387
+ strCode: "QAR",
388
+ eCurrencyCode: 39,
389
+ strSymbol: "QR",
390
+ bSymbolIsPrefix: false,
391
+ bWholeUnitsOnly: false,
392
+ strDecimalSymbol: ".",
393
+ strThousandsSeparator: ",",
394
+ strSymbolAndNumberSeparator: " ",
395
+ },
396
+ CRC: {
397
+ strCode: "CRC",
398
+ eCurrencyCode: 40,
399
+ strSymbol: "\u20a1",
400
+ bSymbolIsPrefix: true,
401
+ bWholeUnitsOnly: true,
402
+ strDecimalSymbol: ",",
403
+ strThousandsSeparator: ".",
404
+ strSymbolAndNumberSeparator: "",
405
+ },
406
+ UYU: {
407
+ strCode: "UYU",
408
+ eCurrencyCode: 41,
409
+ strSymbol: "$U",
410
+ bSymbolIsPrefix: true,
411
+ bWholeUnitsOnly: true,
412
+ strDecimalSymbol: ",",
413
+ strThousandsSeparator: ".",
414
+ strSymbolAndNumberSeparator: "",
415
+ },
416
+ BGN: {
417
+ strCode: "BGN",
418
+ eCurrencyCode: 42,
419
+ strSymbol: "\u043b\u0432",
420
+ bSymbolIsPrefix: false,
421
+ bWholeUnitsOnly: false,
422
+ strDecimalSymbol: ".",
423
+ strThousandsSeparator: ",",
424
+ strSymbolAndNumberSeparator: " ",
425
+ },
426
+ HRK: {
427
+ strCode: "HRK",
428
+ eCurrencyCode: 43,
429
+ strSymbol: "kn",
430
+ bSymbolIsPrefix: false,
431
+ bWholeUnitsOnly: false,
432
+ strDecimalSymbol: ".",
433
+ strThousandsSeparator: ",",
434
+ strSymbolAndNumberSeparator: " ",
435
+ },
436
+ CZK: {
437
+ strCode: "CZK",
438
+ eCurrencyCode: 44,
439
+ strSymbol: "K\u010d",
440
+ bSymbolIsPrefix: false,
441
+ bWholeUnitsOnly: false,
442
+ strDecimalSymbol: ".",
443
+ strThousandsSeparator: ",",
444
+ strSymbolAndNumberSeparator: " ",
445
+ },
446
+ DKK: {
447
+ strCode: "DKK",
448
+ eCurrencyCode: 45,
449
+ strSymbol: "kr.",
450
+ bSymbolIsPrefix: false,
451
+ bWholeUnitsOnly: false,
452
+ strDecimalSymbol: ".",
453
+ strThousandsSeparator: ",",
454
+ strSymbolAndNumberSeparator: " ",
455
+ },
456
+ HUF: {
457
+ strCode: "HUF",
458
+ eCurrencyCode: 46,
459
+ strSymbol: "Ft",
460
+ bSymbolIsPrefix: false,
461
+ bWholeUnitsOnly: false,
462
+ strDecimalSymbol: ".",
463
+ strThousandsSeparator: ",",
464
+ strSymbolAndNumberSeparator: " ",
465
+ },
466
+ RON: {
467
+ strCode: "RON",
468
+ eCurrencyCode: 47,
469
+ strSymbol: "lei",
470
+ bSymbolIsPrefix: false,
471
+ bWholeUnitsOnly: false,
472
+ strDecimalSymbol: ".",
473
+ strThousandsSeparator: ",",
474
+ strSymbolAndNumberSeparator: " ",
475
+ },
476
+ RMB: {
477
+ strCode: "RMB",
478
+ eCurrencyCode: 9000,
479
+ strSymbol: "\u5200\u5e01",
480
+ bSymbolIsPrefix: false,
481
+ bWholeUnitsOnly: true,
482
+ strDecimalSymbol: ".",
483
+ strThousandsSeparator: "",
484
+ strSymbolAndNumberSeparator: " ",
485
+ },
486
+ NXP: {
487
+ strCode: "NXP",
488
+ eCurrencyCode: 9001,
489
+ strSymbol: "\uc6d0",
490
+ bSymbolIsPrefix: false,
491
+ bWholeUnitsOnly: true,
492
+ strDecimalSymbol: ".",
493
+ strThousandsSeparator: ",",
494
+ strSymbolAndNumberSeparator: "",
495
+ },
496
+ };
497
+ const g_rgWalletInfo = {
498
+ wallet_currency: 15,
499
+ wallet_country: "VN",
500
+ wallet_state: "",
501
+ wallet_fee: "1",
502
+ wallet_fee_minimum: "1",
503
+ wallet_fee_percent: "0.05",
504
+ wallet_publisher_fee_percent_default: "0.10",
505
+ wallet_fee_base: "0",
506
+ wallet_balance: "6540490",
507
+ wallet_delayed_balance: "0",
508
+ wallet_max_balance: "4500000000",
509
+ wallet_trade_max_balance: "4049999616",
510
+ success: 1,
511
+ rwgrsn: -2,
512
+ };
4
513
 
5
514
  export const sleep = (ms) => {
6
515
  return new Promise((resolve) => {
@@ -247,3 +756,117 @@ export function getBonusXpTimeRefresh() {
247
756
  }
248
757
  return resetDay;
249
758
  }
759
+
760
+ export function estimateNextXp(currentXp, xpEarned) {
761
+ //estimate next xp
762
+ let bonusTime = 1;
763
+ if (xpEarned < 4500) {
764
+ bonusTime = 4;
765
+ } else if (xpEarned < 7500) {
766
+ bonusTime = 2;
767
+ } else if (xpEarned < 11200) {
768
+ bonusTime = 1;
769
+ } else {
770
+ bonusTime = 0.175;
771
+ }
772
+
773
+ const nextXp = 30 * 13 * bonusTime;
774
+ return nextXp + currentXp;
775
+ }
776
+
777
+ export function formatMarketCurrency(valueInCents, currencyCode = getMarketCurrencyCode(g_rgWalletInfo.wallet_currency), countryCode) {
778
+ if (!valueInCents && valueInCents !== 0) {
779
+ return "";
780
+ }
781
+
782
+ let currencyFormat = (valueInCents / 100).toFixed(2);
783
+
784
+ if (g_rgCurrencyData[currencyCode]) {
785
+ const currencyData = g_rgCurrencyData[currencyCode];
786
+ if (isCurrencyWholeUnits(currencyCode)) {
787
+ currencyFormat = currencyFormat.replace(".00", "");
788
+ }
789
+
790
+ if (currencyData.strDecimalSymbol !== ".") {
791
+ currencyFormat = currencyFormat.replace(".", currencyData.strDecimalSymbol);
792
+ }
793
+
794
+ const currencySymbol = getMarketCurrencySymbol(currencyCode);
795
+ const currencyReturn = isCurrencySymbolBeforeValue(currencyCode) ? currencySymbol + currencyData.strSymbolAndNumberSeparator + currencyFormat : currencyFormat + currencyData.strSymbolAndNumberSeparator + currencySymbol;
796
+
797
+ if (currencyCode === "USD" && typeof countryCode != "undefined" && countryCode != "US") {
798
+ return `${currencyReturn} USD`;
799
+ } else if (currencyCode === "EUR") {
800
+ return currencyReturn.replace(",00", ",--");
801
+ } else {
802
+ return currencyReturn;
803
+ }
804
+ } else {
805
+ return `${currencyFormat} ${currencyCode}`;
806
+ }
807
+ }
808
+
809
+ export function getMarketPriceValueAsInt(strAmount) {
810
+ let nAmount;
811
+ if (!strAmount) {
812
+ return 0;
813
+ }
814
+
815
+ // Users may enter either comma or period for the decimal mark and digit group separators.
816
+ strAmount = strAmount.replace(/,/g, ".");
817
+
818
+ // strip the currency symbol, set .-- to .00
819
+ strAmount = strAmount.replace(getMarketCurrencySymbol(getMarketCurrencyCode(g_rgWalletInfo.wallet_currency)), "").replace(".--", ".00");
820
+
821
+ // strip spaces
822
+ strAmount = strAmount.replace(/ /g, "");
823
+
824
+ // Remove all but the last period so that entries like "1,147.6" work
825
+ if (strAmount.includes(".")) {
826
+ var splitAmount = strAmount.split(".");
827
+ var strLastSegment = splitAmount[splitAmount.length - 1];
828
+
829
+ if (!isNaN(strLastSegment) && strLastSegment.length == 3 && splitAmount[splitAmount.length - 2] != "0") {
830
+ // Looks like the user only entered thousands separators. Remove all commas and periods.
831
+ // Ensures an entry like "1,147" is not treated as "1.147"
832
+ //
833
+ // Users may be surprised to find that "1.147" is treated as "1,147". "1.147" is either an error or the user
834
+ // really did mean one thousand one hundred and forty seven since no currencies can be split into more than
835
+ // hundredths. If it was an error, the user should notice in the next step of the dialog and can go back and
836
+ // correct it. If they happen to not notice, it is better that we list the item at a higher price than
837
+ // intended instead of lower than intended (which we would have done if we accepted the 1.147 value as is).
838
+ strAmount = splitAmount.join("");
839
+ } else {
840
+ strAmount = `${splitAmount.slice(0, -1).join("")}.${strLastSegment}`;
841
+ }
842
+ }
843
+
844
+ let flAmount = parseFloat(strAmount) * 100;
845
+ nAmount = Math.floor(isNaN(flAmount) ? 0 : flAmount + 0.000001); // round down
846
+
847
+ nAmount = Math.max(nAmount, 0);
848
+ return nAmount;
849
+ }
850
+
851
+ export function isCurrencyWholeUnits(currencyCode) {
852
+ return g_rgCurrencyData[currencyCode] && g_rgCurrencyData[currencyCode].bWholeUnitsOnly && currencyCode !== "RUB";
853
+ }
854
+
855
+ export function isCurrencySymbolBeforeValue(currencyCode) {
856
+ return g_rgCurrencyData[currencyCode] && g_rgCurrencyData[currencyCode].bSymbolIsPrefix;
857
+ }
858
+
859
+ // Return the symbol to use for a currency
860
+ export function getMarketCurrencySymbol(currencyCode) {
861
+ return g_rgCurrencyData[currencyCode]?.strSymbol ?? currencyCode;
862
+ }
863
+
864
+ export function getMarketCurrencyCode(currencyId) {
865
+ currencyId = parseInt(currencyId);
866
+ for (const code in g_rgCurrencyData) {
867
+ if (g_rgCurrencyData[code].eCurrencyCode === currencyId) {
868
+ return code;
869
+ }
870
+ }
871
+ return "Unknown";
872
+ }