aboutsummaryrefslogtreecommitdiff
path: root/build/util.js
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-04-27 14:29:07 -0500
committerGitHub <noreply@github.com>2021-04-27 14:29:07 -0500
commit4ce80d0af8f53e93aa3a936b1ad4c5b6c065c881 (patch)
treef5ffb4d7a23d7c6edee01fb605ff81348feea40d /build/util.js
parent562cd341f75bfb2701cc844cf30f1191e4170ca7 (diff)
downloadskyblock-api-4ce80d0af8f53e93aa3a936b1ad4c5b6c065c881.tar.gz
skyblock-api-4ce80d0af8f53e93aa3a936b1ad4c5b6c065c881.tar.bz2
skyblock-api-4ce80d0af8f53e93aa3a936b1ad4c5b6c065c881.zip
Add unit tests (#12)
* start adding unit tests * add more to test/data/mojang.json * fix sending http requests in tests when it shouldn't * add a few more tests * try to add a github action to run tests * Update test.yml
Diffstat (limited to 'build/util.js')
-rw-r--r--build/util.js12
1 files changed, 1 insertions, 11 deletions
diff --git a/build/util.js b/build/util.js
index e7ec9a6..c0bbd42 100644
--- a/build/util.js
+++ b/build/util.js
@@ -3,21 +3,11 @@
* Random utility functions that are not related to Hypixel
*/
Object.defineProperty(exports, "__esModule", { value: true });
-exports.isUuid = exports.sleep = exports.colorCodeFromName = exports.minecraftColorCodes = exports.shuffle = exports.jsonToQuery = exports.queryToJson = exports.undashUuid = void 0;
+exports.isUuid = exports.sleep = exports.colorCodeFromName = exports.minecraftColorCodes = exports.shuffle = exports.jsonToQuery = exports.undashUuid = void 0;
function undashUuid(uuid) {
return uuid.replace(/-/g, '').toLowerCase();
}
exports.undashUuid = undashUuid;
-function queryToJson(queryString) {
- const query = {};
- const pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
- for (let i = 0; i < pairs.length; i++) {
- const pair = pairs[i].split('=');
- query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
- }
- return query;
-}
-exports.queryToJson = queryToJson;
function jsonToQuery(data) {
return Object.entries(data || {}).map(e => e.join('=')).join('&');
}