aboutsummaryrefslogtreecommitdiff
path: root/build/cleaners/skyblock/profile.js
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-09-06 21:06:22 +0000
committerGitHub <noreply@github.com>2021-09-06 21:06:22 +0000
commit487f208565894f332ca58c13e1b208c3beb9c8c6 (patch)
treeb3209e94cc63658b5430bc1949b80140cc27efe4 /build/cleaners/skyblock/profile.js
parent4f03cb71b30978b277ff292dbddeba182117a7cb (diff)
downloadskyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.tar.gz
skyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.tar.bz2
skyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.zip
Bump node-fetch from 2.6.1 to 3.0.0 (#116)
* Bump node-fetch from 2.6.1 to 3.0.0 Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 3.0.0. - [Release notes](https://github.com/node-fetch/node-fetch/releases) - [Changelog](https://github.com/node-fetch/node-fetch/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v3.0.0) --- updated-dependencies: - dependency-name: node-fetch dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix issues with node fetch 3.0 * change module to esnext instead of commonjs * fix imports and tests * fix package-lock.json Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mat <github@matdoes.dev> Co-authored-by: mat <27899617+mat-1@users.noreply.github.com>
Diffstat (limited to 'build/cleaners/skyblock/profile.js')
-rw-r--r--build/cleaners/skyblock/profile.js54
1 files changed, 15 insertions, 39 deletions
diff --git a/build/cleaners/skyblock/profile.js b/build/cleaners/skyblock/profile.js
index 6460c3b..42e26b3 100644
--- a/build/cleaners/skyblock/profile.js
+++ b/build/cleaners/skyblock/profile.js
@@ -1,38 +1,16 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
-}) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.cleanSkyblockProfileResponse = exports.cleanSkyblockProfileResponseLighter = void 0;
-const member_1 = require("./member");
-const minions_1 = require("./minions");
-const bank_1 = require("./bank");
-const constants = __importStar(require("../../constants"));
+import { cleanSkyBlockProfileMemberResponse, cleanSkyBlockProfileMemberResponseBasic } from './member.js';
+import { combineMinionArrays, countUniqueMinions } from './minions.js';
+import * as constants from '../../constants.js';
+import { cleanBank } from './bank.js';
/** Return a `CleanProfile` instead of a `CleanFullProfile`, useful when we need to get members but don't want to waste much ram */
-async function cleanSkyblockProfileResponseLighter(data) {
+export async function cleanSkyblockProfileResponseLighter(data) {
// We use Promise.all so it can fetch all the usernames at once instead of waiting for the previous promise to complete
const promises = [];
for (const memberUUID in data.members) {
const memberRaw = data.members[memberUUID];
memberRaw.uuid = memberUUID;
// we pass an empty array to make it not check stats
- promises.push(member_1.cleanSkyBlockProfileMemberResponseBasic(memberRaw));
+ promises.push(cleanSkyBlockProfileMemberResponseBasic(memberRaw));
}
const cleanedMembers = (await Promise.all(promises)).filter(m => m);
return {
@@ -41,11 +19,10 @@ async function cleanSkyblockProfileResponseLighter(data) {
members: cleanedMembers,
};
}
-exports.cleanSkyblockProfileResponseLighter = cleanSkyblockProfileResponseLighter;
/**
* This function is somewhat costly and shouldn't be called often. Use cleanSkyblockProfileResponseLighter if you don't need all the data
*/
-async function cleanSkyblockProfileResponse(data, options) {
+export async function cleanSkyblockProfileResponse(data, options) {
// We use Promise.all so it can fetch all the users at once instead of waiting for the previous promise to complete
const promises = [];
if (!data)
@@ -53,13 +30,13 @@ async function cleanSkyblockProfileResponse(data, options) {
for (const memberUUID in data.members) {
const memberRaw = data.members[memberUUID];
memberRaw.uuid = memberUUID;
- promises.push(member_1.cleanSkyBlockProfileMemberResponse(memberRaw, [
- !(options === null || options === void 0 ? void 0 : options.basic) ? 'stats' : undefined,
- (options === null || options === void 0 ? void 0 : options.mainMemberUuid) === memberUUID ? 'inventories' : undefined
+ promises.push(cleanSkyBlockProfileMemberResponse(memberRaw, [
+ !options?.basic ? 'stats' : undefined,
+ options?.mainMemberUuid === memberUUID ? 'inventories' : undefined
]));
}
const cleanedMembers = (await Promise.all(promises)).filter(m => m !== null && m !== undefined);
- if (options === null || options === void 0 ? void 0 : options.basic) {
+ if (options?.basic) {
return {
uuid: data.profile_id,
name: data.cute_name,
@@ -70,19 +47,18 @@ async function cleanSkyblockProfileResponse(data, options) {
for (const member of cleanedMembers) {
memberMinions.push(member.minions);
}
- const minions = minions_1.combineMinionArrays(memberMinions);
+ const minions = combineMinionArrays(memberMinions);
const { max_minions: maxUniqueMinions } = await constants.fetchConstantValues();
- const uniqueMinions = minions_1.countUniqueMinions(minions);
- if (uniqueMinions > (maxUniqueMinions !== null && maxUniqueMinions !== void 0 ? maxUniqueMinions : 0))
+ const uniqueMinions = countUniqueMinions(minions);
+ if (uniqueMinions > (maxUniqueMinions ?? 0))
await constants.setConstantValues({ max_minions: uniqueMinions });
// return more detailed info
return {
uuid: data.profile_id,
name: data.cute_name,
members: cleanedMembers,
- bank: bank_1.cleanBank(data),
+ bank: cleanBank(data),
minions: minions,
minion_count: uniqueMinions
};
}
-exports.cleanSkyblockProfileResponse = cleanSkyblockProfileResponse;