ratev is a simple rate value module to rate array of object and return value based on percent 0.1 or higher than 100
npm install ratev
yarn add ratev
const Ratev = require("ratev");
const MyfirstRate = new Ratev();
import Ratev from "ratev";
const MyfirstRate = new Ratev();
const Ratev = require("ratev");
//new Ratev support array of object or ...args of object
const MyfirstRate = new Ratev([
{ rate: 90, value: "BRONZE" }, //90% chance to return BRONZE
{ rate: 70, value: "SILVER" }, //70% chance to return SILVER
{ rate: 50, value: "GOLD" }, //50% chance to return GOLD
{
rate: 20,
value: "PLATINUM", //20% chance to return PLATINUM
},
{
rate: 15,
value: "DIAMOND", //15% chance to return DIAMOND
},
{
rate: 10,
value: "MASTER", //10% chance to return MASTER
},
{
rate: 0.1,
value: "GRANDMASTER", //0.1% chance to return GRANDMASTER
},
]);
setInterval(function () {
console.log(MyfirstRate.value); //return random value based on rate
}, 1000);
MyfirstRate.push(...<Objects>);
//or
MyfirstRate.push([...<Objects>]);
MyfirstRate.push({ rate: 0.1, value: "CHALLENGER" });
//return array of object with new value
MyfirstRate.push([
{ rate: 0.1, value: "CHALLENGER" },
{ rate: 0.1, value: "GRANDMASTER" },
]);
//return array of object with new value
MyfirstRate.push(...<Objects>);
//or
MyfirstRate.push([...<Objects>]);
MyfirstRate.delete(...<valus>);
MyfirstRate.delete("BRONZE", "SILVER", "GOLD");
//return array of object without BRONZE,SILVER,GOLD
MyfirstRate.value;
MyfirstRate.data;