From 54eb12b540e96cc3450b72a19ada2a4526513c60 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 22 Feb 2022 22:07:24 +0000 Subject: shuffle donators on app restart --- svelte.config.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'svelte.config.js') diff --git a/svelte.config.js b/svelte.config.js index c6ab18b..45bb644 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -25,6 +25,13 @@ function fetch(url) { req.end() }) } +function shuffle(a) { + for (let i = a.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)) + ;[a[i], a[j]] = [a[j], a[i]] + } + return a +} (async () => { const API_URL = 'https://skyblock-api.matdoes.dev/' @@ -39,7 +46,7 @@ function fetch(url) { .then(r => JSON.parse(r).player) ) ) - await fs.promises.writeFile('src/_donators.json', JSON.stringify(donators), { + await fs.promises.writeFile('src/_donators.json', JSON.stringify(shuffle(donators)), { encoding: 'utf8' }) })() -- cgit