aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat-1 <github@matdoes.dev>2021-03-01 21:06:04 +0000
committermat-1 <github@matdoes.dev>2021-03-01 21:06:04 +0000
commita5350b51f9afdc6501a7aa9f5674ef973ab28595 (patch)
tree26ce327611eca8be1d2b819403c1bdd2123f9126
parentd00f71b611fd26216bf379df265e53493a1adcb3 (diff)
downloadskyblock-api-a5350b51f9afdc6501a7aa9f5674ef973ab28595.tar.gz
skyblock-api-a5350b51f9afdc6501a7aa9f5674ef973ab28595.tar.bz2
skyblock-api-a5350b51f9afdc6501a7aa9f5674ef973ab28595.zip
Compiled TS into JS
-rw-r--r--build/hypixelCached.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/build/hypixelCached.js b/build/hypixelCached.js
index 48b8ff0..ccb0ca6 100644
--- a/build/hypixelCached.js
+++ b/build/hypixelCached.js
@@ -67,7 +67,7 @@ function waitForSet(cache, key, value) {
const listener = (setKey, setValue) => {
if (setKey === key || (value && setValue === value)) {
cache.removeListener('set', listener);
- return resolve({ key, value });
+ return resolve({ key: setKey, value: setValue });
}
};
cache.on('set', listener);
@@ -86,7 +86,9 @@ async function uuidFromUser(user) {
const username = usernameCache.get(util_1.undashUuid(user));
// if it has .then, then that means its a waitForSet promise. This is done to prevent requests made while it is already requesting
if (username.then) {
- return (await username).key;
+ const { key: uuid, value: _username } = await username;
+ usernameCache.set(uuid, _username);
+ return uuid;
}
else
return util_1.undashUuid(user);
@@ -103,8 +105,10 @@ async function uuidFromUser(user) {
usernameCache.set(util_1.undashUuid(user), waitForSet(usernameCache, user, user));
// not cached, actually fetch mojang api now
let { uuid, username } = await mojang.mojangDataFromUser(user);
- if (!uuid)
+ if (!uuid) {
+ usernameCache.set(uuid, null);
return;
+ }
// remove dashes from the uuid so its more normal
uuid = util_1.undashUuid(uuid);
if (user !== uuid)