@roninjjj/randomize
v1.0.1
Published
Easily include random number generation in your projects. Whether if it's a 2 item 50/50, or a 20 item lootbox, all you need is a simple object!
Maintainers
Readme
How to use
Using Randomize is straightforward. You only need an object, put the item as the key, and the chance to get the item as it's value.
Make sure the sum of your values is exactly 100.
import randomize from "@roninjjj/randomize"
randomize({
FiftyPercentChance_ToGetThis: 50,
ThirtyPercentChance_ToGetThis: 30,
TwentyPercentChance_ToGetThis: 20
})Examples
import randomize from "@roninjjj/randomize"
randomize({
heads: 50, //50%
tails: 50
}) // "heads" | "tails"
randomize({
silver: 20, // 20%
bronze: 70,
gold: 10
}) // "bronze" | "silver" | "gold"
randomize({
jackpot: 0.1, // 0.1%
fail: 60.4,
success: 39.5
}) // "fail" | "success" | "jackpot"