Initial commit

This commit is contained in:
2026-08-24 22:20:36 +02:00
commit 62f7b1278a
251 changed files with 16670 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
function chooseWeightedRandom(items, weights) {
let i;
let length = weights.length;
weights = [...weights];
for (i = 0; i < length; i++) weights[i] += weights[i - 1] || 0;
const random = Math.random() * weights[length - 1];
for (i = 0; i < length; i++) if (weights[i] > random) break;
return items[i];
};
module.exports = chooseWeightedRandom;