@stackedapp/utils 1.9.18 → 1.9.20

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.
Files changed (2) hide show
  1. package/dist/player_data.js +21 -23
  2. package/package.json +1 -1
@@ -9,29 +9,27 @@ exports.aggregatePlayerDataCurrencies = aggregatePlayerDataCurrencies;
9
9
  function aggregatePlayerDataCurrencies(playerDatas) {
10
10
  const aggregatedCurrencies = {};
11
11
  playerDatas?.forEach((playerData) => {
12
- if (playerData.currencies) {
13
- Object.entries(playerData.currencies).forEach(([currencyId, currencyData]) => {
14
- if (!aggregatedCurrencies[currencyId]) {
15
- aggregatedCurrencies[currencyId] = {
16
- balance: 0,
17
- in: 0,
18
- out: 0,
19
- lastUpdated: currencyData.lastUpdated,
20
- };
21
- }
22
- aggregatedCurrencies[currencyId].balance += currencyData.balance || 0;
23
- aggregatedCurrencies[currencyId].in =
24
- (aggregatedCurrencies[currencyId].in || 0) + (currencyData.in || 0);
25
- aggregatedCurrencies[currencyId].out =
26
- (aggregatedCurrencies[currencyId].out || 0) + (currencyData.out || 0);
27
- // Use the most recent lastUpdated timestamp
28
- if (currencyData.lastUpdated &&
29
- (!aggregatedCurrencies[currencyId].lastUpdated ||
30
- currencyData.lastUpdated > (aggregatedCurrencies[currencyId].lastUpdated || 0))) {
31
- aggregatedCurrencies[currencyId].lastUpdated = currencyData.lastUpdated;
32
- }
33
- });
34
- }
12
+ Object.entries(playerData).forEach(([currencyId, currencyData]) => {
13
+ if (!aggregatedCurrencies[currencyId]) {
14
+ aggregatedCurrencies[currencyId] = {
15
+ balance: 0,
16
+ in: 0,
17
+ out: 0,
18
+ lastUpdated: currencyData.lastUpdated,
19
+ };
20
+ }
21
+ aggregatedCurrencies[currencyId].balance += currencyData.balance || 0;
22
+ aggregatedCurrencies[currencyId].in =
23
+ (aggregatedCurrencies[currencyId].in || 0) + (currencyData.in || 0);
24
+ aggregatedCurrencies[currencyId].out =
25
+ (aggregatedCurrencies[currencyId].out || 0) + (currencyData.out || 0);
26
+ // Use the most recent lastUpdated timestamp
27
+ if (currencyData.lastUpdated &&
28
+ (!aggregatedCurrencies[currencyId].lastUpdated ||
29
+ currencyData.lastUpdated > (aggregatedCurrencies[currencyId].lastUpdated || 0))) {
30
+ aggregatedCurrencies[currencyId].lastUpdated = currencyData.lastUpdated;
31
+ }
32
+ });
35
33
  });
36
34
  return aggregatedCurrencies;
37
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackedapp/utils",
3
- "version": "1.9.18",
3
+ "version": "1.9.20",
4
4
  "description": "Public utilities for Stacked platform SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",