This is a flexible factory that can pick out random objects by serveral simple algorithms.
There are two methods on v1.0.0:
- amount: Select by setting the total number in a similar way as through the weight.
- probability: Select purely by chance
Basic usages are already included in the test cases:
const factory = new rand.RandFactory();
const amount = factory.createRand("amount", {
"hi": 1,
"hello": 3,
});
const r1 = amount.rand(3);
// hi: 10%, hello: 30%, null: 60%
const prob = factory.createRand("probability", {
"hi": 10,
"hello": 30,
});
const r2 = prob.rand(3);- v1.0.0: Release two method: amount and probability
- v1.0.2: Release README
- v2.0.0: Simplify input
Contributes are very welcome.
